Parsing ISO date/time strings - where did the parser go?

Roy Smith roy at panix.com
Thu Sep 6 19:34:22 EDT 2012


In article <k2atej$4rq$1 at dont-email.me>, John Nagle <nagle at animats.com> 
wrote:

> In Python 2.7:
> 
>    I want to parse standard ISO date/time strings such as
> 
> 	2012-09-09T18:00:00-07:00
> 
> into Python "datetime" objects.  The "datetime" object offers
> an output method , datetimeobj.isoformat(), but not an input
> parser.  There ought to be
> 
> 	classmethod datetime.fromisoformat(s)
> 
> but there isn't.  I'd like to avoid adding a dependency on
> a third party module like "dateutil".

I'm curious why?  I really think dateutil is the way to go.

It's really amazing (and unfortunate) that datetime has isoformat(), but 
no way to go in the other direction.



More information about the Python-list mailing list