Python datetime not including DST when using pytz timezone

Posted by Jesper on Stack Overflow See other posts from Stack Overflow or by Jesper
Published on 2010-04-17T20:24:02Z Indexed on 2010/04/17 20:53 UTC
Read the original article Hit count: 361

Filed under:
|
|
|
|

If I convert a UTC datetime to swedish format, summertime is included (CEST). However, while creating a datetime with sweden as the timezone, it gets CET instead of CEST. Why is this?

>>> # Modified for readability
>>> import pytz
>>> import datetime
>>> sweden = pytz.timezone('Europe/Stockholm')
>>>
>>> datetime.datetime(2010, 4, 20, 16, 20, tzinfo=pytz.utc).astimezone(sweden)
datetime(2010, 4, 20, 18, 20, tzinfo=<... 'Europe/Stockholm' CEST+2:00:00 DST>)
>>> 
>>> datetime.datetime(2010, 4, 20, 18, 20, tzinfo=sweden)
datetime(2010, 4, 20, 18, 20, tzinfo=<... 'Europe/Stockholm' CET+1:00:00 STD>)
>>>

© Stack Overflow or respective owner

Related posts about python

Related posts about datetime