datetime iso8601 string input
- From: "Rubic" <rubic88@xxxxxxxxx>
- Date: 23 Feb 2006 09:13:46 -0800
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.
.
- Follow-Ups:
- Re: datetime iso8601 string input
- From: Magnus Lycka
- Re: datetime iso8601 string input
- Prev by Date: Re: Using repr() with escape sequences
- Next by Date: problem with newlines in regexp substitution
- Previous by thread: need help regarding compilation
- Next by thread: Re: datetime iso8601 string input
- Index(es):
Relevant Pages
|
|