[Ironpython-users] IronPython 2.7.0 vs 2.7.5

Djordje Spasic issworld2000 at yahoo.com
Wed Feb 8 06:54:17 EST 2017


Thank you for the quick response Pawel!

So I need to change:

import timedate = "JAN/30/2017"date_timeStruct = time.strptime(date,"%m/%d/%Y")
To:

import timedate = "JAN/30/2017"date_timeStruct = time.strptime(date,"%b/%d/%Y")
Did I understand that correctly?

And time.strptime(date,"%b/%d/%Y") will work on both IronPython 2.7.0 and IronPython 2.7.5?
It is essential for me to have a solution which will work on both versions. 

    On Wednesday, February 8, 2017 12:48 PM, Pawel Jasinski <pawel.jasinski at gmail.com> wrote:
 

 hi,

prior to 2.7.5, the strptime had a non standard fallback. If a format didn't match, it tried to guess format.
This is not what standard lib from cpython does. If the string can not be converted using format, it fails.

In you case %m translates to zero padded month decimal, 01 for January
Try %b instead.

--pawel

On Wed, Feb 8, 2017 at 11:02 AM, Djordje Spasic via Ironpython-users <ironpython-users at python.org> wrote:

Hello,

I am using Rhino 5, and Rhino WIP applications shipped with IronPython 2.7.0 and 2.7.5 version respectively.
I have an issue with time.strptime function.
The following code works perfectly on IronPython 2.7.0:
import timedate = "JAN/30/2017"date_timeStruct = time.strptime(date,"%m/%d/%Y")

Once IronPython 2.7.5 is installed, it fails with this error message on the third line:

Runtime error (ValueErrorException): time data does not match format
data=JAN/30/2017, fmt=%m/%d/%Y, to: M'/'d'/'yyyy


Is there a way of making the time.strptime function work on both 2.7.0 and 2.7.5 versions?

I would appreciate any kind of reply.

Thank you in advance.

______________________________ _________________
Ironpython-users mailing list
Ironpython-users at python.org
https://mail.python.org/ mailman/listinfo/ironpython- users





   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20170208/28246c34/attachment.html>


More information about the Ironpython-users mailing list