Timezones are not easy.
But with the pytz release 2014.3
it got even more insane.
For example:
>>> import pytz
>>> pytz.timezone('Europe/Berlin')
<DstTzInfo 'Europe/Berlin' LMT+0:53:00 STD>
LMT is for local mean time which was the timezone system till 1893.
After version 2014.3 of pytz you should not use tzinfo to set timezone:
>>> import pytz
>>> from datetime import datetime
>>> datetime(2014, 8, 29, 18, 0, tzinfo=pytz.timezone('Europe/Berlin'))
datetime(2014, 8, 29, 18, 0, tzinfo=<DstTzInfo 'Europe/Berlin' LMT+0:53:00 STD>)
now you really should use .localize()
of your timezone object:
>>> import pytz
>>> from datetime import datetime
>>> pytz.timezone('Europe/Berlin').localize(datetime(2014, 8, 29, 18, 0))
datetime(2014, 8, 29, 18, 0, tzinfo=<DstTzInfo 'Europe/Berlin' CEST+2:00:00 DST>)
for more information see http://stackoverflow.com/questions/24359540/why-doesnt-pytz-localize-produce-a-datetime-object-with-tzinfo-matching-the-t
Tell us what you think about this. Is something unclear? Do you have questions or ideas? Leave your comments below.
comments powered by Disqus