Check argument type in get_date utility function before processing it

Sitemap plugin calls this method to convert `modified` metadate into
datetime. Depending on the version of Pelican `modified` can be string
or a datetime object.

Therefore get_date should check for the type of argument otherwise
Pelican fails with a critical error.
This commit is contained in:
Talha Mansoor 2013-11-10 01:38:44 +05:00
commit 5fbea6202f

View file

@ -180,6 +180,8 @@ def get_date(string):
If no format matches the given date, raise a ValueError.
"""
if isinstance(string, datetime):
return string
string = re.sub(' +', ' ', string)
formats = [
# ISO 8601