|
|
@ -814,9 +814,11 @@ def parse_iso8601(date_str, delimiter='T', timezone=None):
|
|
|
|
if date_str is None:
|
|
|
|
if date_str is None:
|
|
|
|
return None
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
date_str = re.sub(r'\.[0-9]+', '', date_str)
|
|
|
|
|
|
|
|
|
|
|
|
if timezone is None:
|
|
|
|
if timezone is None:
|
|
|
|
m = re.search(
|
|
|
|
m = re.search(
|
|
|
|
r'(\.[0-9]+)?(?:Z$| ?(?P<sign>\+|-)(?P<hours>[0-9]{2}):?(?P<minutes>[0-9]{2})$)',
|
|
|
|
r'(?:Z$| ?(?P<sign>\+|-)(?P<hours>[0-9]{2}):?(?P<minutes>[0-9]{2})$)',
|
|
|
|
date_str)
|
|
|
|
date_str)
|
|
|
|
if not m:
|
|
|
|
if not m:
|
|
|
|
timezone = datetime.timedelta()
|
|
|
|
timezone = datetime.timedelta()
|
|
|
@ -829,9 +831,12 @@ def parse_iso8601(date_str, delimiter='T', timezone=None):
|
|
|
|
timezone = datetime.timedelta(
|
|
|
|
timezone = datetime.timedelta(
|
|
|
|
hours=sign * int(m.group('hours')),
|
|
|
|
hours=sign * int(m.group('hours')),
|
|
|
|
minutes=sign * int(m.group('minutes')))
|
|
|
|
minutes=sign * int(m.group('minutes')))
|
|
|
|
date_format = '%Y-%m-%d{0}%H:%M:%S'.format(delimiter)
|
|
|
|
try:
|
|
|
|
dt = datetime.datetime.strptime(date_str, date_format) - timezone
|
|
|
|
date_format = '%Y-%m-%d{0}%H:%M:%S'.format(delimiter)
|
|
|
|
return calendar.timegm(dt.timetuple())
|
|
|
|
dt = datetime.datetime.strptime(date_str, date_format) - timezone
|
|
|
|
|
|
|
|
return calendar.timegm(dt.timetuple())
|
|
|
|
|
|
|
|
except ValueError:
|
|
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def unified_strdate(date_str, day_first=True):
|
|
|
|
def unified_strdate(date_str, day_first=True):
|
|
|
|