I am asking whether there exists a python library which either converts a country based time-zone string to the corresponding GMT offset based time-zone string. For example, 'America/Los Angeles' would be converted to 'Etc/GMT+8'. Alternatively, is there a python library that can yield 'Etc/GMT+8' timezone from latitude and longitude of a location in Los Angeles, CA ?
Asked
Active
Viewed 83 times
1 Answers
0
Try this (note that you will need to throttle your geopy
requests to avoid breaching the API limit)
from geopy import geocoders
g = geocoders.GoogleV3()
place, (lat, lng) = g.geocode('New York')
tz = g.timezone((lat, lng))
Which I think gives what you are after
In [19]: place, tz
Out[19]: (u'New York, NY, USA', <DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD>)
Alternative methods of getting the Lat/Lon into a timezone can be found here:

Alexander McFarlane
- 10,643
- 9
- 59
- 100
-
Thank you, but what I want is the DST independent timezone. In your case the desired answer would be 'Etc/GMT+5' for New York. – Ambarish Nag Sep 11 '18 at 17:39