[New-bugs-announce] [issue44255] strptime and week numbers without week days

Jaap van der Velde report at bugs.python.org
Thu May 27 18:12:07 EDT 2021

New submission from Jaap van der Velde <jaapvandervelde at gmail.com>:

When running:
datetime.strptime('2013 23', '%Y %W')
The result is `datetime.datetime(2013, 1, 1, 0, 0)`. When running:
datetime.strptime('2013 23 1', '%Y %W %w')
The result is `datetime.datetime(2013, 6, 10, 0, 0)`.

It seems that `%W` is ignored, unless `%w` is also provided. But instead of throwing an error, a result is returned that is needlessly inaccurate. It could (and should?) return the first day of the week as a default, if an error is undesirable. Similar to:
datetime.strptime('2013 3', '%Y %m')

components: Library (Lib)
messages: 394611
nosy: Jaap van der Velde
priority: normal
severity: normal
status: open
title: strptime and week numbers without week days
type: enhancement
versions: Python 3.9

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list