Skip to content

Instantly share code, notes, and snippets.

@romanbsd
Created January 25, 2013 11:40
Show Gist options
  • Save romanbsd/4633781 to your computer and use it in GitHub Desktop.
Save romanbsd/4633781 to your computer and use it in GitHub Desktop.
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