[ python-Bugs-1045381 ] strptime doesn't work with %U

SourceForge.net noreply at sourceforge.net
Mon Oct 18 05:50:02 CEST 2004


Bugs item #1045381, was opened at 2004-10-13 03:04
Message generated for change (Comment added) made by anadelonbrin
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1045381&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Closed
Resolution: Fixed
Priority: 4
Submitted By: Sebastien JUST (sebastienjust)
Assigned to: Brett Cannon (bcannon)
Summary: strptime doesn't work with %U

Initial Comment:
It seems that strptime() ignores %U. 

For example when trying to get the first day of the
42th week of year 2004. Please test on the command line : 

import time
time.strftime("%Y-%m-%d",time.strptime("2004 42 1","%Y
%U %w"))

the result is 2004-01-01 and not 2004-10-11
seems that strptime() is ignoring %U indications.

Works fine on Python 2.2, bad on Python 2.3.3 , 2.3.4
and 2.4a1.
Tested on Fedora Core 2.

Thanks

----------------------------------------------------------------------

Comment By: Tony Meyer (anadelonbrin)
Date: 2004-10-18 16:50

Message:
Logged In: YES 
user_id=552329

FWIW, with the example given the correct answer is
2004-10-18, which CVS now gives, not 2004-10-11.

However, this doesn't look right:

>>> time.strptime("2008 52 1", "%Y %U %w")
(2009, 1, 5, 0, 0, 0, 0, 371, -1)

It ought to be 

>>> time.strptime("2008 52 1", "%Y %U %w")
(2008, 12, 29, 0, 0, 0, 0, 364, -1)

By my figuring.

----------------------------------------------------------------------

Comment By: Brett Cannon (bcannon)
Date: 2004-10-18 14:56

Message:
Logged In: YES 
user_id=357491

In rev. 1.36 in HEAD has the fix as well as rev. 1.23.4.6 for 2.3 .

----------------------------------------------------------------------

Comment By: Brett Cannon (bcannon)
Date: 2004-10-18 12:10

Message:
Logged In: YES 
user_id=357491

OK, I have the algorithm written.  Now I am waiting for python-dev to 
make a decision on whether this should go into 2.4b2 or wait until 2.5 .

----------------------------------------------------------------------

Comment By: Brett Cannon (bcannon)
Date: 2004-10-13 14:57

Message:
Logged In: YES 
user_id=357491

Forgot the link to the glibc page: http://www.gnu.org/software/libc/
manual/html_node/Low-Level-Time-String-Parsing.html#Low-
Level%20Time%20String%20Parsing

----------------------------------------------------------------------

Comment By: Brett Cannon (bcannon)
Date: 2004-10-13 14:57

Message:
Logged In: YES 
user_id=357491

Well, it looks like glibc 2.3.x doesn't even support %U or %W for 
strptime(); this might take a while to implement...

----------------------------------------------------------------------

Comment By: Brett Cannon (bcannon)
Date: 2004-10-13 14:42

Message:
Logged In: YES 
user_id=357491

Yeah, right now it isn't supported since the calculation, at least when I 
first implemented strptime() seemed useless in terms of reversing back 
into a time tuple.  Guess there at least one way there is enough info to 
make it useful.

Now I just need to figure out how to make the calculation work.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1045381&group_id=5470


More information about the Python-bugs-list mailing list