Add timezone to datetime objects. Refs #962.

Based on https://github.com/getpelican/pelican/pull/977, but it adds
timezone information before formatting.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
This commit is contained in:
OGINO Masanori 2014-06-10 09:47:14 +09:00
commit 2c50ccb764
92 changed files with 259 additions and 247 deletions

View file

@ -538,7 +538,9 @@ def set_date_tzinfo(d, tz_name=None):
"""Set the timezone for dates that don't have tzinfo"""
if tz_name and not d.tzinfo:
tz = pytz.timezone(tz_name)
return tz.localize(d)
d = tz.localize(d)
return SafeDatetime(d.year, d.month, d.day, d.hour, d.minute, d.second,
d.microsecond, d.tzinfo)
return d