[Python-bugs-list] [ python-Bugs-656817 ] Bug in week calculation of time module
noreply@sourceforge.net
noreply@sourceforge.net
Sat, 21 Dec 2002 01:45:04 -0800
Bugs item #656817, was opened at 2002-12-20 14:37
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=656817&group_id=5470
Category: Python Library
Group: Python 2.2.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Christian Loth (chloth)
Assigned to: Nobody/Anonymous (nobody)
Summary: Bug in week calculation of time module
Initial Comment:
Noticed while writing an application in connection with
PostgreSQL.
Because of Leapyears, the year 1998 had 53 weeks,
instead of
the normal 52 weeks. PostgreSQL does ist correctly:
SELECT EXTRACT(WEEK FROM TIMESTAMP'1998-31-12 20:38:40');
date_part
-----------
53
(1 row)
However the python equivalent fails, neither U nor W gets
it right:
>>> int(strftime("%U", strptime("1998-12-31", "%Y-%m-%d")))
52
>>> int(strftime("%W", strptime("1998-12-31", "%Y-%m-%d")))
52
>>>
----------------------------------------------------------------------
>Comment By: Christian Loth (chloth)
Date: 2002-12-21 10:45
Message:
Logged In: YES
user_id=553797
If that is so, how do you explain the following (again
PostgreSQL vs.
Python comparison).
SELECT EXTRACT(WEEK FROM TIMESTAMP'1999-12-31 20:38:40');
date_part
-----------
52
(1 row)
>>> int(strftime("%U", strptime("1999-12-31", "%Y-%m-%d")))
52
Does that mean, according to your explaination, that 1999
had 53 weeks? (which of course it hadn't).
----------------------------------------------------------------------
Comment By: Tim Peters (tim_one)
Date: 2002-12-20 18:13
Message:
Logged In: YES
user_id=31435
Have you read the docs for strftime()? strftime() is defined by
the ANSI C standard, not by SQL 1998-01-01 was in "week
0" according to ANSI C, so the 53rd week of the year is week
52.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=656817&group_id=5470