This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [Windows] datetime.fromtimestamp(t) when t = 253402210800 fails on Python 3.8
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, janripke, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2021-08-27 14:52 by janripke, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg400429 - (view) Author: Jan Ripke (janripke) Date: 2021-08-27 14:52
When executing the following statement on a Windows machine it fails.
On a linux machine it returns the expected date (9999-31-12 00:00:00)
The Error we get on Windows is:
OSError: [Errno 22] Invalid argument

In another manor it was reported before:
https://bugs.python.org/issue29097


The code:
from datetime import datetime

epoch_time = 253402210800000/1000
print(datetime.fromtimestamp(epoch_time))
msg400458 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2021-08-28 03:08
The supported range depends on the platform. The C runtime library in Windows can handle dates through the year 3000 [1]:

    >>> datetime.fromtimestamp(32536799999)
    datetime.datetime(3001, 1, 19, 7, 59, 59)

    >>> datetime.fromtimestamp(32536800000)
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    OSError: [Errno 22] Invalid argument

---

[1] https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/gmtime-gmtime32-gmtime64?view=msvc-160
History
Date User Action Args
2022-04-11 14:59:49adminsetgithub: 89194
2021-08-28 03:08:12eryksunsetstatus: open -> closed

type: crash -> behavior

nosy: + eryksun
messages: + msg400458
resolution: third party
stage: resolved
2021-08-27 14:52:22janripkecreate