[Python-Dev] mxDatTime parser (was: New Subscriber Introduction)
Tue, 25 Jun 2002 12:50:32 +0200
Oleg Broytmann wrote:
> On Tue, Jun 25, 2002 at 12:21:31PM +0200, M.-A. Lemburg wrote:
>>>>Just curious: have you taken a look at the mxDateTime parser ?
>>>is that an extension of the rfc822.parsedate approach?
>>Yes, but it goes far beyond RFC822 style dates and times.
>>>>from mx import DateTime
>>>>dt = DateTime.DateTimeFrom("21/12/2002")
> <DateTime object for '2002-06-25 20:02:00.00' at 819d7f8>
>>>>dt = DateTime.DateTimeFrom("21/08/2002")
> <DateTime object for '2002-06-25 20:02:00.00' at 819b860>
>>>>dt = DateTime.DateTimeFrom("21-08-2002")
> <DateTime object for '2021-08-20 00:00:00.00' at 819d7f8>
> I am not sure I understand the logic. Because of this I always use ISO
> date format (2002-08-21).
The problem with the first two is that the parser
parses date *and* time (it defaults to today for entries
which are not found in the string; this can be changed
The last one is parsed as ISO date (21-08-20), the trailing
02 is omitted.
As you can see date parsing is very difficult, and even though
the mxDateTime parser already recognizes tons of different
formats, it doesn't always work. It is getting better with
each release, though :-)
CEO eGenix.com Software GmbH
Company & Consulting: http://www.egenix.com/
Python Software: http://www.egenix.com/files/python/
Meet us at EuroPython 2002: http://www.europython.org/