Skip to content

Instantly share code, notes, and snippets.

@akscram
Created August 25, 2017 08:32
Show Gist options
  • Save akscram/1c0256ccb2b9d19b32b1c4b1391aaf96 to your computer and use it in GitHub Desktop.
Save akscram/1c0256ccb2b9d19b32b1c4b1391aaf96 to your computer and use it in GitHub Desktop.
pypi/iso8601
>>> import iso8601
>>> d = iso8601.parse_date("2007-01-25T12:00:00Z")
>>> d
datetime.datetime(2007, 1, 25, 12, 0, tzinfo=<iso8601.Utc>)
>>> df = d.strftime('%Y-%m-%dT%H:%M:%S%Z')
>>> df
'2007-01-25T12:00:00UTC'
>>> d2 = iso8601.parse_date(df)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/ash/.iso8601/lib/python2.7/site-packages/iso8601/iso8601.py", line 195, in parse_date
raise ParseError("Unable to parse date string %r" % datestring)
iso8601.iso8601.ParseError: Unable to parse date string '2007-01-25T12:00:00UTC'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment