[Python-bugs-list] [Bug #110698] strptime gives format mismatch when time zone present (PR#164)
noreply@sourceforge.net
noreply@sourceforge.net
Fri, 8 Sep 2000 09:13:03 -0700
Bug #110698, was updated on 2000-Jul-31 14:29
Here is a current snapshot of the bug.
Project: Python
Category: None
Status: Closed
Resolution: Invalid
Bug Group: Platform-specific
Priority: 5
Summary: strptime gives format mismatch when time zone present (PR#164)
Details: Jitterbug-Id: 164
Submitted-By: python-bugreport@derf.net
Date: Tue, 21 Dec 1999 08:27:27 -0500 (EST)
Version: 1.5.2
OS: RedHat 5.2; Linux 2.2.12
time.strptime() seems to fail when the time zone ('%Z') appears in the format
string. when it is omitted from the format string (and from the string being
parsed), strptime() works fine.
here is a sample script which demonstrates the bug:
------
#!/usr/bin/python
import time
timetuple0 = time.localtime(time.time())
print timetuple0
format1 = '%a %b %d %H:%M:%S %Y'
timestring1 = time.strftime( format1 , timetuple0 )
print timestring1
timetuple1 = time.strptime( timestring1 , format1 )
print timetuple1
format2 = '%a %b %d %H:%M:%S %Z %Y'
timestring2 = time.strftime( format2 , timetuple0 )
print timestring2
timetuple2 = time.strptime( timestring2 , format2 )
print timetuple2
------
when i run the above, i get the following output:
------
(1999, 12, 21, 5, 25, 35, 1, 355, 0)
Tue Dec 21 05:25:35 1999
(1999, 12, 21, 5, 25, 35, 1, 355, 0)
Tue Dec 21 05:25:35 PST 1999
Traceback (innermost last):
File "./test.py", line 17, in ?
timetuple2 = time.strptime( timestring2 , format2 )
ValueError: format mismatch
------
====================================================================
Audit trail:
Tue Dec 21 11:47:04 1999 guido changed notes
Tue Dec 21 11:47:05 1999 guido moved from incoming to platformbug
Follow-Ups:
Date: 2000-Aug-01 14:03
By: none
Comment:
From: Guido van Rossum <guido@CNRI.Reston.VA.US>
Subject: Re: [Python-bugs-list] strptime gives format mismatch when time zone present (PR#164)
Date: Tue, 21 Dec 1999 09:12:15 -0500
> time.strptime() seems to fail when the time zone ('%Z') appears in
> the format string. when it is omitted from the format string (and
> from the string being parsed), strptime() works fine.
Reporting this as a Python bug is not going to fix it. The
time.strptime() function in Python is a very thin wrapper around the
strptime() function in the C library. We get a lot of complaints
about this, but there's no way that we're able to fix this -- it's the
C strptime() function that needs to be fixed. Write to your friendly
Linux support people!
--Guido van Rossum (home page: http://www.python.org/~guido/)
-------------------------------------------------------
Date: 2000-Aug-01 14:03
By: none
Comment:
The C library strptime() needs fixin'.
-------------------------------------------------------
Date: 2000-Sep-07 15:06
By: jhylton
Comment:
Please do triage on this bug.
-------------------------------------------------------
Date: 2000-Sep-08 05:27
By: lemburg
Comment:
FYI, you could check out mxDateTime which provides a parser
for various date/time formats instead of waiting for your strptime()
C API to get fixed.
mxDateTime is available at http://starship.python.net/~lemburg/.
-------------------------------------------------------
Date: 2000-Sep-08 09:13
By: tim_one
Comment:
Closed it, as it's not a Python bug but a bug in the platform libc (if a non-std fnc can be called "buggy" at all ...).
-------------------------------------------------------
For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=110698&group_id=5470