Created
November 5, 2013 19:19
-
-
Save estebistec/7324558 to your computer and use it in GitHub Desktop.
yes, parsing utc datetimes works (!??!)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ pip freeze -l | |
python-dateutil==1.5 | |
pytz==2013.8 | |
$ python | |
... | |
>>> from dateutil.parser import parse | |
>>> import datetime | |
>>> import pytz | |
>>> d = datetime.datetime.now(pytz.UTC) | |
>>> d | |
datetime.datetime(2013, 11, 5, 19, 14, 9, 142824, tzinfo=<UTC>) | |
>>> sz = '2013-11-05T19:14:09.142824Z' | |
>>> s = d.isoformat() | |
>>> s | |
'2013-11-05T19:14:09.142824+00:00' | |
>>> sz | |
'2013-11-05T19:14:09.142824Z' | |
>>> parse(s) | |
datetime.datetime(2013, 11, 5, 19, 14, 9, 142824, tzinfo=tzutc()) | |
>>> parse(sz) | |
datetime.datetime(2013, 11, 5, 19, 14, 9, 142824, tzinfo=tzutc()) | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment