Example Code
from datetime import datetime, timezone, timedelta
import pytz
t11 = datetime(1918, 4, 15, 0, 0, tzinfo=timezone.utc).astimezone(pytz.timezone('Europe/Berlin'))
t12 = t11 + timedelta(hours=1)
t2 = datetime(1918, 4, 15, 1, 0, tzinfo=timezone.utc).astimezone(pytz.timezone('Europe/Berlin'))
print(t12)
print(t2)
Observed
1918-04-15 02:00:00+01:00
1918-04-15 03:00:00+02:00
Expected
I expected both to be what I see for t2
. The crucial difference is t2.hour
vs t12.hour
. For a timezone-aware datetime object, I expected the hour to be the local hour.
Question
How can I change this behaviour? What is the reason for having it like this?