R. David Murray added the comment:
from the man page for strptime:
%w The weekday number (0-6) with Sunday = 0.
%W The week number with Monday the first day of the week (0-53).
The first Monday of January is the first day of week 1.
Python's documentation is just a tiny bit clearer about %W:
%W Week number of the year (Monday as the first day of the week) as
a decimal number. All days in a new year preceding the first Monday are
considered to be in week 0.
So, the result is correct, albeit very unintuitive (the week day numbers for
the purposes of %W are the sequence 1-2-3-4-5-6-0). You will note that if you
call strftime with the same format string, you will get your input strings out
as the output.
Call this a design bug in posix that python has inherited. You will get the
exact same behavior if you write a C program that calls strptime/strftime.
----------
nosy: +r.david.murray
resolution: -> invalid
stage: -> committed/rejected
status: open -> closed
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue19774>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com