[issue45884] datetime.strptime incorrectly handling hours and minutes with bad format string
Jon Oxtoby
report at bugs.python.org
Tue Nov 23 14:11:12 EST 2021
New submission from Jon Oxtoby <joxtoby27 at gmail.com>:
Running datetime.strptime against a string containing year, month, day but with a formatter including %H causes a two-digit day to be split across the day and hour fields of the datetime:
datetime.datetime.strptime('20140812', '%Y%m%d%H')
returns: datetime.datetime(2014, 8, 1, 2, 0)
expected: ValueError: time data '20140812' does not match format '%Y%m%d%H'
datetime.datetime.strptime('2014081201', '%Y%m%d%H%M')
returns: datetime.datetime(2014, 8, 12, 0, 1)
expected: ValueError: time data '2014081201' does not match format '%Y%m%d%H%M'
----------
components: Library (Lib)
messages: 406877
nosy: joxtoby27
priority: normal
severity: normal
status: open
title: datetime.strptime incorrectly handling hours and minutes with bad format string
type: behavior
versions: Python 3.8, Python 3.9
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue45884>
_______________________________________
More information about the Python-bugs-list
mailing list