Parsing ISO 8601 timestamps
Well this isn’t very encouraging:
Python’s time.strptime, which has been the subject of well-deserved abuse by many developers, has no way to handle proper ISO 8601 time zone offsets. The closest format specifier, %Z, which only accepts civil time zone names such as MST, is not permitted in ISO-8601.
Here’s an example of the issue:
>>> ISO_8601_DATETIME = '%Y-%m-%dT%H:%M:%S%Z'
>>> time.strptime(iso,ISO_8601_DATETIME)
Traceback (most recent call last):
...
ValueError: unconverted data remains: Z
I know I could use mxDateTime to do the conversions for me, but I was hoping to code it myself using only the standard Python libraries.
There’s some more info on the Python wiki and other places, so I’ll keep working on it for a little longer before I give up.