Created
January 25, 2013 11:40
-
-
Save romanbsd/4633781 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveSupport | |
class TimeZone | |
module Google | |
API = 'https://maps.googleapis.com/maps/api/timezone/json'.freeze | |
def from_coordinates(lat, lng) | |
params = { | |
location: "#{lat},#{lng}", | |
timestamp: Time.now.to_i, | |
sensor: false | |
} | |
resp = Faraday.get(API, params) | |
zone_id = MultiJson.load(resp.body)['timeZoneId'] | |
ActiveSupport::TimeZone[zone_id] | |
end | |
end | |
extend Google | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment