This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Steve.J.Borba
Recipients Steve.J.Borba
Date 2013-11-25.19:23:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1385407385.23.0.963319097072.issue19774@psf.upfronthosting.co.za>
In-reply-to
Content
OS: Windows 7 Professional (64-bit)
Hardware: Intel

datetime.strptime returns an incorrect value when calculating a date using a week number format, such as "%Y-%W-%w" (Year-Week-Weekday). The value returned for weekday '0' of a given week is consistently 7 days greater than it should be. The following code illustrates:

from datetime import datetime
for i in range(0,53):
    if i == 0:
        yr=input("Enter a valid year: ")
        print("Wk#\tBeginning of week\tEnd of week")
    BegWk = datetime.strptime((yr + "-" + str(i) + "-0"),"%Y-%W-%w")
    EndWk = datetime.strptime((yr + "-" + str(i) + "-6"),"%Y-%W-%w")
    print(str(i) + "\t" + str(BegWk) + "\t" +str(EndWk))

Here is a clip (7 lines) of the output from the code above:
Enter a valid year: 2013
Wk#	Beginning of week	End of week
0	2013-01-06 00:00:00	2013-01-05 00:00:00
1	2013-01-13 00:00:00	2013-01-12 00:00:00
2	2013-01-20 00:00:00	2013-01-19 00:00:00
3	2013-01-27 00:00:00	2013-01-26 00:00:00
4	2013-02-03 00:00:00	2013-02-02 00:00:00
5	2013-02-10 00:00:00	2013-02-09 00:00:00
6	2013-02-17 00:00:00	2013-02-16 00:00:00

The value returned for the first column of each week is exactly 7 days higher than the correct result.
History
Date User Action Args
2013-11-25 19:23:05Steve.J.Borbasetrecipients: + Steve.J.Borba
2013-11-25 19:23:05Steve.J.Borbasetmessageid: <1385407385.23.0.963319097072.issue19774@psf.upfronthosting.co.za>
2013-11-25 19:23:05Steve.J.Borbalinkissue19774 messages
2013-11-25 19:23:04Steve.J.Borbacreate