[IronPython] datetime.strptime is missing in IronPython?

Vernon Cole vernondcole at gmail.com
Tue Jun 8 06:46:23 CEST 2010


The issue tracker for CPython  [if I read it correctly] lists
datetime.strptime as a new feature to be supported in python 2.7 and
3.2. It is not documented in the Python 2.6 manual.  The current way
of doing it seems to be:

>>> import datetime
>>> import time
>>> d = datetime(*(time.strptime(date_string, format)[0:6]))

I have not tested that, I just cut it out of the issue tracker.

And, Yes, you are running an obsolete version of IronPython. You
should upgrade to 2.6. But that will not fix your problem, since
datetime.strptime is not present in the current version, either.
--
Vernon Cole

On Mon, Jun 7, 2010 at 1:56 PM, Peter Masiar <peter.masiar at gmail.com> wrote:
> Seems like datetime in Ironpython has only strftime, but no strptime?
>
> IronPython 2.0.3 (2.0.0.0) on .NET 2.0.50727.3603
> Type "help", "copyright", "credits" or "license" for more information.
>>>> import datetime
>>>> dir(datetime.datetime)
> ['CompareTo', '__add__', '__class__', '__delattr__', '__doc__', '__eq__', '__ge_
> _', '__getattribute__', '__getnewargs__', '__gt__', '__hash__', '__init__', '__l
> e__', '__lt__', '__ne__', '__new__', '__nonzero__', '__radd__', '__reduce__', '_
> _reduce_ex__', '__repr__', '__rsub__', '__setattr__', '__str__', '__sub__', 'ast
> imezone', 'combine', 'ctime', 'date', 'day', 'dst', 'fromordinal', 'fromtimestam
> p', 'hour', 'isocalendar', 'isoformat', 'isoweekday', 'max', 'microsecond', 'min
> ', 'minute', 'month', 'now', 'replace', 'resolution', 'second', 'strftime', 'tim
> e', 'timetuple', 'timetz', 'today', 'toordinal', 'tzinfo', 'tzname', 'utcfromtim
> estamp', 'utcnow', 'utcoffset', 'utctimetuple', 'weekday', 'year']
>>>>
>
> Or do I have wrong/obsolete IronPython? Which one has datetime.strptime()?
> What I am missing?
>
> What is recommended way in IronPython to parse date/time string back
> to date object?
>
> Thanks!
> --
> -----
> Peter Masiar
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>



More information about the Ironpython-users mailing list