Created
April 16, 2014 10:54
-
-
Save makmac213/10852009 to your computer and use it in GitHub Desktop.
get_google_time_zone
This file contains 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
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