New submission from Jon Oxtoby <joxtob...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue45884>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to