[issue40236] datetime.datetime.strptime get day error

Paul Ganssle report at bugs.python.org
Thu Apr 9 11:10:43 EDT 2020


Paul Ganssle <p.ganssle at gmail.com> added the comment:

Likely relevant is bpo-23136, where they dealt with similar issues in the past.

I don't see any explicit test for this behavior, but it seems that the solution is to try to be consistent and to not raise a ValueError.

Looking at this issue, I think it's a manifestation of a similar bug that hits when a year starts with a Monday.

It seems like the behavior is that the following days (%W-%w) should be sequential in any year: 00-1, 00-2, 00-3, 00-4, 00-5, 00-6, 00-0, 01-1, 01-2, ...

Since 2024 starts in a Monday, the first day of the year should be 2024-01-1, and the 2024-00-1 week should start 2023-12-25 rather than duplicating the following week.

I think there's an equivalent issue with dates of the form "%Y-%U-%w", but happening on years that start with a Sunday.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40236>
_______________________________________


More information about the Python-bugs-list mailing list