[New-bugs-announce] [issue19162] datetime.datetime.min.strftime('%Y') not working

Filip Zyzniewski report at bugs.python.org
Fri Oct 4 13:00:07 CEST 2013


New submission from Filip Zyzniewski:

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.

----------
components: Library (Lib)
messages: 198941
nosy: filip.zyzniewski
priority: normal
severity: normal
status: open
title: datetime.datetime.min.strftime('%Y') not working
type: behavior
versions: Python 2.7, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19162>
_______________________________________


More information about the New-bugs-announce mailing list