Way to get local standard time offset for at a given location and date in Python

Viewed 31

I am looking for a way to, given a location (i.e. a lon/lat pair) and date, find out the UTC offset at that location at that time, ignoring DST. In other words, if a location remained in standard time all year, what would the UTC offset be? This UTC offset could still change over time, because many places have changed their actual timezone throughout history.

Ignoring DST is what is causing me issues. I am able to get the UTC offset for a some lon, lat, and date values like this:

tf           = timezonefinder.TimezoneFinder()
timezone_str = tf.certain_timezone_at(lat = lat, lng = lon)
tz           = pytz.timezone(timezone_str)
utc_offset   = tz.utcoffset(date).total_seconds()/60/60

But pytz automatically accounts for daylights saving time changes. The is_dst parameter which can be passed to utcoffset was promising initially, but after looking through the docs, it appears as if this parameter is usually ignored, except for ambiguous cases.

The ._tzinfos class of pytz timezone objects seems to have some promising information...but I'm not sure how to parse through it.

0 Answers
Related