Given the latitude and longitude of a location, how does one know what time zone is in effect in that location?
In most cases, we are looking for an IANA/Olson time z
There are several sources online that have geojson data for timezones (here's one, here's another)
Use a geometry library to create polygon objects from the geojson coordinates (shapely [python], GEOS [c++], JTS [java], NTS [.net]).
Convert your lat/lng to a point object (however your library represents that) and check if it intersects the timezone polygon.
from shapely.geometry import Polygon, Point
def get_tz_from_lat_lng(lat, lng):
for tz, geojson in timezones.iteritems():
coordinates = geojson['features'][0]['geometry']['coordinates']
polygon = Polygon(coordinates)
point = Point(lng, lat)
if polygon.contains(point):
return tz