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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Alexey Borzenkov Sent: Wednesday, August 23, 2006 9:26 PM To: Discussion of IronPython Subject: [IronPython] IronPython strptime for %H Hi, # 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 [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com _______________________________________________ users mailing list [email protected] http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
