[issue23134] datetime.strptime at the turn of the year
Serhiy Storchaka
report at bugs.python.org
Tue Dec 30 19:45:17 CET 2014
Serhiy Storchaka added the comment:
In C the strptime function doesn't return valid data if an input is invalid.
$ ./strptimetest "0 2015 1" "%W %Y %w"
2015-00--2 00:00:00
$ ./strptimetest "0 2015 2" "%W %Y %w"
2015-00--1 00:00:00
$ ./strptimetest "0 2015 3" "%W %Y %w"
2015-00-00 00:00:00
$ ./strptimetest "0 2015 4" "%W %Y %w"
2015-01-01 00:00:00
$ ./strptimetest "0 2015 5" "%W %Y %w"
2015-01-02 00:00:00
$ ./strptimetest "0 2015 6" "%W %Y %w"
2015-01-03 00:00:00
$ ./strptimetest "0 2015 7" "%W %Y %w"
2015-01-00 00:00:00
So this behavior likely is not a bug and doesn't need to be fixed in maintained releases. But it would be good to make strptime() more consistant and either extend it to support week and weekday numbers out of current valid range, or raise an exception.
----------
nosy: +belopolsky, serhiy.storchaka
versions: +Python 3.5
Added file: http://bugs.python.org/file37566/strptimetest.c
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23134>
_______________________________________
More information about the Python-bugs-list
mailing list