Re: datetime iso8601 string input

2006-03-27 Thread Rubic
Could [RFC 3339] be a candidate for a default consumption format for date-time strings? +1 -- http://mail.python.org/mailman/listinfo/python-list

Re: datetime iso8601 string input

2006-03-23 Thread Magnus Lycka
[EMAIL PROTECTED] wrote: Why not dt = datetime.datetime(*time.strptime(s, %Y-%m-%dT%H:%M:%S)[0:6]) ? Maybe due to neglection of the 7th commandment? Most of the other commandments can be ignored while coding Python, but the 7th certainly applies here.

Re: datetime iso8601 string input

2006-03-23 Thread Ben Finney
Magnus Lycka [EMAIL PROTECTED] writes: As I've written before, the ISO 8601 spec contains many variations in date formats. Making a full ISO 8601 parser is probably possible if we ignore time deltas, but it's hardly worth the effort. Writing something that parses a few percent of the possible

Re: datetime iso8601 string input

2006-03-21 Thread skip
aurora I agree. I just keep rewriting the parse method again and again. aurora def parse_iso8601_date(s): aurora Parse date in iso8601 format e.g. 2003-09-15T10:34:54 and aurora returns a datetime object. aurora ... Why not dt =

Re: datetime iso8601 string input

2006-03-20 Thread aurora
I agree. I just keep rewriting the parse method again and again. wy def parse_iso8601_date(s): Parse date in iso8601 format e.g. 2003-09-15T10:34:54 and returns a datetime object. y=m=d=hh=mm=ss=0 if len(s) not in [10,19,20]: raise ValueError('Invalid

Re: datetime iso8601 string input

2006-03-20 Thread Sybren Stuvel
aurora enlightened us with: I agree. I just keep rewriting the parse method again and again. I just use the parser from mx.DateTime. Works like a charm, and can even guess the used format. Sybren -- The problem with the world is stupidity. Not saying there should be a capital punishment for

Re: datetime iso8601 string input

2006-02-24 Thread Magnus Lycka
Rubic wrote: 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? Have you actually read the ISO 8601 standard? If you have, you would know that parsing valid ISO 8601 is fairly close to

Re: datetime iso8601 string input

2006-02-24 Thread Rubic
Magnus, Thanks for your reply. I wasn't clear in my prior post. Rather than support the entire range of iso8601 formats, how about *just* the format that datetime emits? Call it the parse_datetime() function. Then it would be possible to take the output string of a datetime object and read it

Re: datetime iso8601 string input

2006-02-24 Thread Peter Hansen
Rubic wrote: Thanks for your reply. I wasn't clear in my prior post. Rather than support the entire range of iso8601 formats, how about *just* the format that datetime emits? Call it the parse_datetime() function. Then it would be possible to take the output string of a datetime object

Re: datetime iso8601 string input

2006-02-24 Thread Rubic
Yeah, it's a trivial function that's rewritten for each new project that passes datetime objects as strings 0.2 wink. On the basis of it being a trivial convenience, I could propose removing hundreds of redundant functions from the library. ;-) Never mind. I'll drop it. Jeff Bauer Rubicon,

Re: datetime iso8601 string input

2006-02-24 Thread Magnus Lycka
Rubic wrote: Yeah, it's a trivial function that's rewritten for each new project that passes datetime objects as strings 0.2 wink. On the basis of it being a trivial convenience, I could propose removing hundreds of redundant functions from the library. ;-) I think the big issue is that it

datetime iso8601 string input

2006-02-23 Thread Rubic
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