datetime iso8601 string input
Rubic
rubic88 at gmail.com
Thu Feb 23 12:13:46 EST 2006
I was a little surprised to recently discover
that datetime has no method to input a string
value. PEP 321 appears does not convey much
information, but a timbot post from a couple
years ago clarifies things:
http://tinyurl.com/epjqc
> You can stop looking: datetime doesn't
> support any kind of conversion from string.
> The number of bottomless pits in any datetime
> module is unbounded, and Guido declared this
> particular pit out-of-bounds at the start so
> that there was a fighting chance to get
> *anything* done for 2.3.
I can understand why datetime can't handle
arbitrary string inputs, but why not just
simple iso8601 format -- i.e. the default
output format for datetime?
Given a datetime-generated string:
>>> now = str(datetime.datetime.now())
>>> print now
'2006-02-23 11:03:36.762172'
Why can't we have a function to accept it
as string input and return a datetime object?
datetime.parse_iso8601(now)
Jeff Bauer
Rubicon, Inc.
More information about the Python-list
mailing list