mxDateTime: does strptime not exist?

M.-A. Lemburg mal at lemburg.com
Thu May 3 12:57:59 EDT 2001


Ruediger Maehl wrote:
> 
> Hi,
> 
> I am trying to convert a string expression into a
> DateTime object and found the strptime constructor
> in the docs of mxDateTime. But it throws the
> following error (and does not show strptime as
> available method in PythonWin's Interactive
> Window).
> 
> >>> import DateTime
> >>> a = "09:49"
> >>> f = "%H:%M"
> >>> dt = DateTime.strptime(a, f)
> Traceback (innermost last):
>   File "<interactive input>", line 1, in ?
> AttributeError: strptime
> 
> Any hints?

As others have already pointed out to you: the Windows C lib
doesn't have strptime().

Note that there's a much more elaborte date/time parser
available in mxDateTime though: the submodules Parser, ISO
and ARPA.

These will do a pretty good job on a very wide range of
possible formats, e.g.

>>> from mx.DateTime import *
>>> DateTimeFrom('09:49')
<DateTime object for '2001-05-03 09:49:00.00' at 8177198>
>>> DateTimeDeltaFrom('09:49')
<DateTimeDelta object for '09:49:00.00' at 816f058>

-- 
Marc-Andre Lemburg
______________________________________________________________________
Company & Consulting:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/




More information about the Python-list mailing list