Skip to content

Instantly share code, notes, and snippets.

@makmac213
Created April 16, 2014 10:54
Show Gist options
  • Save makmac213/10852009 to your computer and use it in GitHub Desktop.
Save makmac213/10852009 to your computer and use it in GitHub Desktop.
get_google_time_zone
def get_google_time_zone(lat, lng):
ret = False
try:
api_url = 'https://maps.googleapis.com/maps/api/timezone/json'
payload = {
'location': '%s,%s' % (lat, lng),
'timestamp': int(time.time()),
'sensor': 'true',
}
response = requests.get(api_url, params=payload)
json = response.json()
if response.status_code == 200:
ret = json['timeZoneId']
except:
print "Unable to connect to %s" % api_url
return ret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment