This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author torm
Recipients torm
Date 2014-12-30.18:04:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1419962642.25.0.70032949175.issue23134@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2014-12-30 18:04:02tormsetrecipients: + torm
2014-12-30 18:04:02tormsetmessageid: <1419962642.25.0.70032949175.issue23134@psf.upfronthosting.co.za>
2014-12-30 18:04:02tormlinkissue23134 messages
2014-12-30 18:04:01tormcreate