[IronPython] IronPython strptime for %H

Dino Viehland dinov at exchange.microsoft.com
Fri Aug 25 02:33:51 CEST 2006

It's a bug - I've opened CodePlex bug #2557 to track it  http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&WorkItemId=2557 .  I've tentatively set this as a 1.01 bug, unfortunately the only workaround I can think of is to call the .NET DateTime.ToString() directly.

What's happening here is we prepend the % sign to tell the .NET DateTime parser that this is a custom date-time specifier.  But when there are multiple specifiers we shouldn't be adding it (as it's obviously a custom specifier) and it's actually invalid for us to do that.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Alexey Borzenkov
Sent: Wednesday, August 23, 2006 9:26 PM
To: Discussion of IronPython
Subject: [IronPython] IronPython strptime for %H


# 1.py
from System.Threading.Thread import CurrentThread from System.Globalization import CultureInfo CurrentThread.CurrentCulture = CultureInfo("en-US")

import time, datetime
d = time.strptime("July 3, 2006 At 0724 GMT", "%B %x, %Y At %H%M GMT") print d

# ipy 1.py
Traceback (most recent call last):

  File D:\Alex\IronPython\1.py, line 6, in Initialize

  File , line 0, in ParseString##20

ValueError: The string was not recognized as a valid DateTime. There is a unknown word starting at index 13.

data=July 3, 2006 At 0724 GMT, fmt=%B %x, %Y At %H%M GMT, to: MMMM'
'D', 'yyyy' At '%Hmm' GMT'

Why does it let % be in .NET format string (1.0 rc2)?
users mailing list
users at lists.ironpython.com

More information about the Ironpython-users mailing list