[issue23134] datetime.strptime at the turn of the year
Tomasz Ryczkowski
report at bugs.python.org
Tue Dec 30 19:04:02 CET 2014
New submission from Tomasz Ryczkowski:
I've found wrong behaviour datetime.strptim function at the turn of the year.
I've created datetime object base on the week number (%W), year (%Y) and day of week (%w). The date for Tuesday in the first week in 2015 is wrong:
>>> from datetime import datetime
>>> datetime.strptime('%s %s %s' % (0, 2015, 1), '%W %Y %w').date()
datetime.date(2014, 12, 29) # OK
>>> datetime.strptime('%s %s %s' % (0, 2015, 2), '%W %Y %w').date()
datetime.date(2015, 1, 1) # WRONG !!!
>>> datetime.strptime('%s %s %s' % (0, 2015, 3), '%W %Y %w').date()
datetime.date(2014, 12, 31) # OK
>>> datetime.strptime('%s %s %s' % (0, 2015, 4), '%W %Y %w').date()
datetime.date(2015, 1, 1) # OK
>>> datetime.strptime('%s %s %s' % (0, 2015, 5), '%W %Y %w').date()
datetime.date(2015, 1, 2) # OK
>>> datetime.strptime('%s %s %s' % (0, 2015, 6), '%W %Y %w').date()
datetime.date(2015, 1, 3) # OK
>>> datetime.strptime('%s %s %s' % (0, 2015, 0), '%W %Y %w').date()
datetime.date(2015, 1, 4) # OK
The same error exists in another years.
Link to my post about this on stackoverflow:
http://stackoverflow.com/questions/27708833/why-does-datetime-strptime-get-an-incorrect-date-for-tuesday-in-the-week-0-of
----------
messages: 233213
nosy: torm
priority: normal
severity: normal
status: open
title: datetime.strptime at the turn of the year
type: behavior
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23134>
_______________________________________
More information about the Python-bugs-list
mailing list