Is there anyone who can help me understand what's going on here?
import pytz
from datetime import datetime
tz = pytz.timezone('Europe/Berlin')
print repr(tz)
# <DstTzInfo 'Europe/Berlin' LMT+0:53:00 STD>
dt = datetime(2011, 1, 3, 18, 40)
result = tz.localize(dt)
print repr(result.tzinfo)
# <DstTzInfo 'Europe/Berlin' CET+1:00:00 STD>
assert result.tzinfo == tz, "Why aren't these the same timezone?"
My understanding was that the localize()
method on a pytz timezone object would take a naive datetime object, and add a tzinfo
property that matches the timezone object performing the localization. That does not appear to be happening in this case.
Clearly, there's something I'm misunderstanding about timezones, or about the way that pytz handles timezones. Can anyone explain?