mxDateTime function DateFromString gives wrong year

Tim Roberts timr at probo.com
Fri Mar 26 02:39:15 EST 2004


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.
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list