class GoogleMaps::Services::Timezone
Performs requests to the Google Maps Timezone
API.
@example
timezone = GoogleMaps::Services::Timezone.new(client) result = timezone.query(location: "38.908133,-77.047119")
Attributes
client[RW]
@return [Symbol] The HTTP client.
Public Class Methods
new(client)
click to toggle source
# File lib/googlemaps/services/timezone.rb, line 15 def initialize(client) self.client = client end
Public Instance Methods
query(location:, timestamp: nil, language: nil)
click to toggle source
Get time zone for a location on the earth, as well as that location's time offset from UTC.
@param [String, Hash] location The lat/lng value representing the location to look up. @param [Integer, Time, Date] timestamp Specifies the desired time as seconds since midnight, January 1, 1970 UTC.
The Time Zone API uses the timestamp to determine whether or not Daylight Savings should be applied. Times before 1970 can be expressed as negative values. Optional. Defaults to Util.current_utctime.
@param [String] language The language in which to return results.
@return [Hash] Valid JSON or XML response.
# File lib/googlemaps/services/timezone.rb, line 28 def query(location:, timestamp: nil, language: nil) params = { 'location' => Convert.to_latlng(location), 'timestamp' => Convert.unix_time(timestamp || Util.current_utctime) } if language params['language'] = language end self.client.request(url: "/maps/api/timezone/#{self.client.response_format}", params: params) end