mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
utils: Use pytz instead of datetime.timezone for timezones
datetime.timezone is new in Python 3.2 [1], so pytz allows us to keep support for Python 2.7. [1]: http://docs.python.org/dev/library/datetime.html#datetime.timezone
This commit is contained in:
parent
228fc82fc9
commit
1102143c33
2 changed files with 9 additions and 7 deletions
|
|
@ -15,7 +15,7 @@ from collections import Hashable
|
|||
from functools import partial
|
||||
|
||||
from codecs import open, BOM_UTF8
|
||||
from datetime import datetime, timezone
|
||||
from datetime import datetime
|
||||
from itertools import groupby
|
||||
from jinja2 import Markup
|
||||
from operator import attrgetter
|
||||
|
|
@ -210,7 +210,7 @@ def get_date(string):
|
|||
except ValueError:
|
||||
continue
|
||||
if date_format.endswith('Z'):
|
||||
date = date.replace(tzinfo=timezone.utc)
|
||||
date = date.replace(tzinfo=pytz.timezone('UTC'))
|
||||
return date
|
||||
raise ValueError('{0!r} is not a valid date'.format(string))
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue