Given a geographic coordinate in degrees of lattitude & longitude I used to use the tzwhere library [1[] which worked just fine, but did throw value errors [2] for almost two years now which never got fixed.

Because I have it in my jupyter startup scripts as it’s used by some Astropy convenience methods I wrote, it started to really bother me as with eevry upgrade I had to fix the bug manually.

After some digging around I found a replacement which is almost a drop-in, timezonefinder [3].

Old code, using tzwhere, was:

from tzwhere import tzwhere
tzwhere = tzwhere.tzwhere()
lat, lon = 41.89332029999999, 12.4829321
tz = tzwhere.tzNameAt(lat, lon)

And simply using timezonefinder is:

from timezonefinder import timezone_at
lat, lon = 41.89332029999999, 12.4829321
tz = timezone_at(lng=lon, lat=lat)

References: