Module: GoogleMapsApis::Services::TimeZone

Included in:
Client
Defined in:
lib/google_maps_apis/services/time_zone.rb

Overview

Performs requests to the Google Maps TimeZone API."""

Instance Method Summary collapse

Instance Method Details

#timezone(location, timestamp: Time.now, language: nil) ⇒ Hash

Get time zone for a location on the earth, as well as that location's time offset from UTC.

Examples:

Current time zone

timezone = client.timezone([39.603481, -119.682251])

Time zone at certain time

timezone = client.timezone([39.603481, -119.682251], timestamp: Time.at(1608))

Parameters:

  • location (Hash, Array)

    The latitude/longitude value representing the location to look up.

  • timestamp (Integer, DateTime) (defaults to: Time.now)

    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 Time.now.

  • language (String) (defaults to: nil)

    The language in which to return results.

Returns:

  • (Hash)

    Time zone object.



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/google_maps_apis/services/time_zone.rb', line 27

def timezone(location, timestamp: Time.now, language: nil)
  location = GoogleMapsApis::Convert.latlng(location)
  timestamp = GoogleMapsApis::Convert.time(timestamp)

  params = {
    location: location,
    timestamp: timestamp
  }

  params[:language] = language if language

  return get('/maps/api/timezone/json', params)
end