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 jeffknupp
Recipients hywl51, jeffknupp
Date 2017-01-08.05:15:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1483852520.99.0.656379540822.issue29081@psf.upfronthosting.co.za>
In-reply-to
Content
I believe this is working as intended. Remember, the '%w' directive instructs strptime to consider 0 to be Sunday, while tm_wday considers 0 Monday. In 2016, the %W directive means that the first week (week #1) starts on Monday, January 4th. If you go 52 weeks forward from the 4th, you get to Monday, December 26th. By asking for day 0 (%w=0), you want the *Sunday* of the 52nd week *from the first Monday of the year*. Since Monday is day 0 of that week, you want the Sunday that is 6 days from the 26th, or Jan 1, 2017.

One can certainly argue that tm_yday is documented to return an integer between [0,366] and thus we should never see 367, but it's the correct value given your input. The only other choice would be to raise an exception, which definitely shouldn't happen since the values you entered clearly match the format string spec.

Perhaps the docs should be updated, but when you consider that %W goes from [0,53], tm_yday can go well past 366 and still represent a semantically valid value.
History
Date User Action Args
2017-01-08 05:15:21jeffknuppsetrecipients: + jeffknupp, hywl51
2017-01-08 05:15:20jeffknuppsetmessageid: <1483852520.99.0.656379540822.issue29081@psf.upfronthosting.co.za>
2017-01-08 05:15:20jeffknupplinkissue29081 messages
2017-01-08 05:15:20jeffknuppcreate