-
-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datetime.datetime.min.strftime('%Y') not working #63361
Comments
The datetime class provides a min datetime object which is not formattable: on Python 2: $ python
Python 2.7.3 (default, Apr 10 2013, 05:13:16)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.min.strftime('%Y')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: year=1 is before 1900; the datetime strftime() methods require year >= 1900
>>> and on Python 3: $ python3
Python 3.2.3 (default, Apr 10 2013, 05:07:54)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.min.strftime('%Y')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: year=1 is before 1000; the datetime strftime() methods require year >= 1000
>>> It seems to me that either datetime.datetime.min.year should be increased to 1900/1000 or strftime should be able to format year=1 - it is strange that the API doesn't support its own constants. |
works correctly on python3.3:
Python 3.3.2 (default, Oct 4 2013, 12:21:07)
[GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd9
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.min.strftime('%Y')
'0001'
issue on 2.7:
Python 2.7.5 (default, Sep 17 2013, 12:11:31)
[GCC 4.2.1 20070831 patched [FreeBSD]] on freebsd9
Type "help", "copyright", "credits" or "license" for more information.
>>> import datetime
>>> datetime.datetime.min.strftime('%Y')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: year=1 is before 1900; the datetime strftime() methods require year >= 1900 |
Indeed, this is already fixed. This issue is a duplicate of bpo-1777412. The bug will not be fixed in earlier versions for the reasons discussed in that issue. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: