mxDateTime function DateFromString gives wrong year

Sibylle Koczian Sibylle.Koczian at Bibliothek.Uni-Augsburg.de
Fri Mar 26 06:00:18 EST 2004


Tim Roberts schrieb:
> Sibylle Koczian <Sibylle.Koczian at Bibliothek.Uni-Augsburg.de> wrote:
> 
> 
>>This is very nearly a repetition of a post by Peter Hansen from 
>>2002-07-07 which never got an answer:
>>
>>
>>>>>x = mx.DateTime.Parser.DateFromString('Nov 2003')
>>>>>x
>>
>><DateTime object for '2004-11-20 00:00:00.00' at a61ba0>
>>
>>Using mx.DateTime Version 2.0.5 for Python 2.3 and ActivePython 2.3.2.
>>
>>The original posting had the same problem with 'October 29/2000'. This 
>>isn't corrected either, it still converts to 2004-10-29.
> 
> 
> I'm not convinced that's a bug.  The slash is not a valid separator for
> DateFromString once it finds a named month, so the parse terminates there.
> It sees "October 29" and assumes the current year.  Replace the slash with
> a comma and it will work fine.

This case is a citation from the original post from 2002. My actual 
problem is with "Nov 2003" which is converted to a date in November 
2004. And I think what P. Hansen cited from the mx.DateTime 
documentation in his original posting is equally valid here:

"The module knows about quite a few different date and time formats and 
will try very hard to come up with a reasonable output given a valid input."

For the example "October 29/2000" replacing the slash with ', ' does 
work. For my "Nov 2003" inserting a comma doesn't help.

-- 
Dr. Sibylle Koczian
Universitaetsbibliothek, Abt. Naturwiss.
D-86135 Augsburg

Tel.: (0821) 598-2400, Fax : (0821) 598-2410
e-mail : Sibylle.Koczian at Bibliothek.Uni-Augsburg.DE




More information about the Python-list mailing list