[issue31212] datetime: min date (0001-01-01 00:00:00) can't be converted to local timestamp

Alexander Belopolsky report at bugs.python.org
Wed Aug 16 17:44:01 EDT 2017


Alexander Belopolsky added the comment:

The question is whether -62135658000.0 is the "correct" or even meaningful value:

>>> datetime.utcfromtimestamp(-62135658000.0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: year is out of range

(I ran the above in Python 2.7 to avoid any 3.x datetime innovations.)

I don't see much of a value in allowing datetime.timestamp() to produce values that correspond to out of bounds datetimes in UTC.  In most cases this will only result in error later on in the program, or worse an error passing undetected.

What is the use case for datetime.min.timestamp()?  I suspect OP encountered this issue in an overly aggressive edge case testing and not in a real user scenario.

----------

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


More information about the Python-bugs-list mailing list