stub42/pytz

Trouble with Australia/Sydney timezone

stoiver opened this issue · 1 comments

I needed to convert between UTC and 'Australia/Sydney' times. But ran into a problem. First an example which works:

>>> import pytz
>>> from datetime import datetime
>>> UTC = pytz('UTC')
>>> AEDT = pytz.timezone('Australia/Sydney')
>>> dt = datetime(1990,1,1)
>>> utc_dt = UTC.localize(dt)
>>> aedt_dt = utc_dt.astimezone(AEDT)
>>> print(utc_dt, aedt_dt)
1990-01-01 00:00:00+00:00 1990-01-01 11:00:00+11:00

Which is fine. But with an earlier dt = datetime(1900,1,1) I get

>>> dt = datetime(1990,1,1)
>>> utc_dt = UTC.localize(dt)
>>> aedt_dt = utc_dt.astimezone(AEDT)
>>> print(utc_dt, aedt_dt)
1900-01-01 00:00:00+00:00 1900-01-01 10:05:00+10:05

Why the strange timezone offset of 10:05?

It seems that a change occurs between dt = datetime(1901,12,13) and dt = datetime(1901,12,14) which produce the following results

1901-12-13 00:00:00+00:00 1901-12-13 10:05:00+10:05
1901-12-14 00:00:00+00:00 1901-12-14 10:00:00+10:00

I am using pytz version 2022.1 installed via conda, using python 3.9.12

This would be the transition from solar time, where the sun is directly overhead at noon. It is hard to say exactly when the clocks transitioned, so the date will be somewhat arbitrary.