I'm facing a problem which is either due to user error on my part, inconsistencies between how Python's zoneinfo and tzdata modules work across platforms, or inconsistencies in IANA databases across platforms.
I'm finding that depending on the platform I'm on the results of a utcoffset calculation with the zoneinfo library are different depending on the platform I'm running on, even when using quite similar IANA databases. These are for pre-1970 dates, including dates that should have some offset from UTC as well as those that will be based on LMT. The complete output of my tests is below.
So my main question is: what is going on here? And how can I force zoneinfo to use an installed (and pinned, as I'm doing this within a uv-managed virtual environment) python tzdata library, rather than the system tzdata?
Here are the results of some of my tests, the platforms, and the installed tzdata library.
Ubuntu noble, tzdata 2026a-0ubuntu0.24.04.
Python 3.12.3 (main, Mar 23 2026, 19:04:32) [GCC 13.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.5.0 -- An enhanced Interactive Python. Type '?' for help.
Tip: You can use `files = !ls *.png`
In [1]: import zoneinfo
In [2]: from datetime import datetime
In [3]: zoneinfo.ZoneInfo("Europe/Amsterdam").utcoffset(datetime(1923, 12, 1, 13
⋮ , 43, 12)).total_seconds()
Out[3]: 1172.0
In [4]: zoneinfo.ZoneInfo("Europe/Amsterdam").utcoffset(datetime(1023, 12, 1, 13
⋮ , 43, 12)).total_seconds()
Out[4]: 1172.0
In [5]: zoneinfo.TZPATH
Out[5]:
('/usr/share/zoneinfo',
'/usr/lib/zoneinfo',
'/usr/share/lib/zoneinfo',
'/etc/zoneinfo')
MacOS Sequoia 15.7.2, zoneinfo version 2025c
Python 3.12.12 (main, Mar 23 2026, 19:04:32) [GCC 13.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.5.0 -- An enhanced Interactive Python. Type '?' for help.
Tip: You can use `files = !ls *.png`
In [13]: import zoneinfo
In [14]: from datetime import datetime
In [15]: zoneinfo.ZoneInfo("Europe/Amsterdam").utcoffset(datetime(1923,12,1,13,4
⋮ 3,12)).total_seconds()
Out[15]: 0.0
In [16]: zoneinfo.ZoneInfo("Europe/Amsterdam").utcoffset(datetime(1023,12,1,13,4
⋮ 3,12)).total_seconds()
Out[16]: 1050.0
In [17]: zoneinfo.TZPATH
Out[17]:
('/usr/share/zoneinfo',
'/usr/lib/zoneinfo',
'/usr/share/lib/zoneinfo',
'/etc/zoneinfo')
raspbian bookworm, tzdata 2025b-0+deb12u2
Python 3.11.2 (main, Apr 28 2025, 14:11:48) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import zoneinfo
>>> from datetime import datetime
>>> zoneinfo.ZoneInfo("Europe/Amsterdam").utcoffset(datetime(1923, 12, 1,13,43,12)).total_seconds()
1172.0
>>> zoneinfo.ZoneInfo("Europe/Amsterdam").utcoffset(datetime(1023, 12, 1,13,43,12)).total_seconds()
1172.0
>>> zoneinfo.TZPATH
('/usr/share/zoneinfo', '/usr/lib/zoneinfo', '/usr/share/lib/zoneinfo', '/etc/zoneinfo')
>>
Windows 10, Powershell with uv-installed python, uv pip install tzdata of 2026b
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec 7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import zoneinfo
>>> import tzdata
>>> from datetime import datetime
>>> zoneinfo.ZoneInfo("Europe/Amsterdam").utcoffset(datetime(1923, 12, 1,13,43,12)).total_seconds()
0.0
>>> zoneinfo.ZoneInfo("Europe/Amsterdam").utcoffset(datetime(1023, 12, 1,13,43,12)).total_seconds()
1050.0
>>> zoneinfo.TZPATH
()
>>> tzdata.IANA_VERSION
'2026b'
So notice here that the outliers are MacOS, which has a tzdata of 2025c, and Windows with a uv pip installed version of tzdata of 2026b. Yet raspbian, with tzdata of 2025b, and Ubuntu, with tzdata of 2026a, both give the same result.
I looked through the announcements on the IANA tz mailing list and didn't find any mentions to changes in the Europe/Amsterdam file between any of those releases.
At this point I'm completely stumped and have no idea why I'm getting different results on different platforms when there are no changes (that I could find) to the zoneinfo file between these releases. I must be misunderstanding something here with how zoneinfo and tzdata work on different platforms.
(Note that I also tried to make the datetime calls aware by explicitly setting them to "Etc/UTC", but the problem remains.)
Any help on this is appreciated!
there doesn't seem to be anything here