Comment 1 for bug 1324158

Revision history for this message
Stuart Bishop (stub) wrote :

Per the README, you need to use the following method to construct a localized datetime:

>>> import pytz
>>> pytz.__version__
'2014.3'
>>> import datetime
>>> pytz.timezone("US/Pacific").localize(datetime.datetime(2011, 6, 27, 2, 0, 0)).strftime('%Y-%m-%d %H:%M:%S %Z%z')
'2011-06-27 02:00:00 PDT-0700'

Note that your original working code is not actually working, as it is reporting standard time when that timestamp is in the daylight savings time period starting 13th March 2011. What you are retrieving is the first timezone period stored in the database. Lots of early timezone transitions were added in 2013c.