[issue36439] Inconsistencies with datetime.fromtimestamp(t) when t < 0

Paul Anton Letnes report at bugs.python.org
Wed Jun 10 09:55:16 EDT 2020


Paul Anton Letnes <paul.anton.letnes at gmail.com> added the comment:

I've encountered an issue on anaconda python on windows 10 v1909 which I suspect is related. It looks like no dates in 1970 can be converted to datetime.timestamp():

Python 3.8.2 (default, Apr 14 2020, 19:01:40) [MSC v.1916 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import datetime

In [2]: datetime.datetime(1970, 1, 2, 0, 0, 1, 123456).timestamp()
---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-2-0ac473af013b> in <module>
----> 1 datetime.datetime(1970, 1, 2, 0, 0, 1, 123456).timestamp()

OSError: [Errno 22] Invalid argument

In [3]: datetime.datetime(1971, 1, 2, 0, 0, 1, 123456).timestamp()
Out[3]: 31618801.123456

----------
nosy: +Paul Anton Letnes

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36439>
_______________________________________


More information about the Python-bugs-list mailing list