New submission from laurent chriqui <[email protected]>:
When you use strftime with a 2 digit year i.e. '32' it outputs a '32' instead
of '0032'.
This prevents parsing the string again with the same format through strftime.
Exemple:
import datetime
datetime_format="%Y"
date=datetime.date(32,1,1)
date_str=datetime.datetime.strftime(date, datetime_format)
datetime.datetime.strptime(date_str, datetime_format)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.8/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/lib/python3.8/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data '32' does not match format '%Y'
----------
components: Library (Lib)
messages: 370971
nosy: laurent chriqui
priority: normal
severity: normal
status: open
title: datetime strftime with %Y and 2 digit years
type: behavior
versions: Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40908>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com