Skip to content

Instantly share code, notes, and snippets.

@bjmc
Last active August 29, 2015 14:02
Show Gist options
  • Save bjmc/59d8650ae3d2aebb7584 to your computer and use it in GitHub Desktop.
Save bjmc/59d8650ae3d2aebb7584 to your computer and use it in GitHub Desktop.
Why don't these match?
3.4.0 (default, Apr 11 2014, 13:05:11)
[GCC 4.8.2]
2014.4
<DstTzInfo 'Europe/Berlin' LMT+0:53:00 STD>
<DstTzInfo 'Europe/Berlin' CET+1:00:00 STD>
Traceback (most recent call last):
File "example.py", line 16, in <module>
assert result.tzinfo == tz, "Why aren't these the same timezone?"
AssertionError: Why aren't these the same timezone?
import sys
print(sys.version)
#3.4.0 (default, Apr 11 2014, 13:05:11)
#[GCC 4.8.2]
import pytz
print(pytz.VERSION)
# '2014.4'
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 DST>
assert result.tzinfo == tz, "Why aren't these the same timezone?"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment