[issue44610] Format issue with strftime and %Y
New submission from Bartosz Kaznowski : When you convert a date pre the year 1000 to a string with `%Y` as the formatter and then back to a date again then it fails. This is because `%Y` expects it to be formatted with leading zeroes. For example, the year 1/01/01 (/mm/dd) should be 0001/01/01 when formatting using %Y/%m/%d. However, %Y returns 1. You can see this in action here: from datetime import date, datetime format = "%Y-%m-%d" formatted = date.min.strftime("%Y-%m-%d") datetime.strptime(formatted, format).date() `ValueError: time data '1-01-01' does not match format '%Y-%m-%d'` is raised on the forth line. -- components: Library (Lib) messages: 397329 nosy: bkaznowski priority: normal severity: normal status: open title: Format issue with strftime and %Y type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue44610> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44610] Format issue with strftime and %Y
Change by Bartosz Kaznowski : -- versions: +Python 3.9 -Python 3.7 ___ Python tracker <https://bugs.python.org/issue44610> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44610] Format issue with strftime and %Y
Change by Bartosz Kaznowski : -- versions: +Python 3.10, Python 3.6, Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue44610> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44610] Format issue with strftime and %Y
Bartosz Kaznowski added the comment: Ok, thanks @iritkatriel. I have closed it as a duplicate. I did notice after posting this that in the cpython source code people work around this issue. Now I can see why. I guess I will just have to work around this issue too. Luckily it doesn't cause too many problems for what I need. Thanks! -- resolution: -> duplicate stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue44610> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com