mxDateTime: does strptime not exist?

Remco Gerlich scarblac at pino.selwerd.nl
Thu May 3 04:26:02 EDT 2001


Ruediger Maehl <ruediger.maehl at dzsh.de> wrote in comp.lang.python:
> 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?

The docs also say: "Availability: most modern Unix systems".
Windows simply doesn't have the function.

Andrew Markebo made a pure Python version you can use (LGPL license):
http://www.fukt.hk-r.se/~flognat/hacks/strptime.py

-- 
Remco Gerlich



More information about the Python-list mailing list