Skip to content

error in datetime.timestamp on windows #94757

@kecmen

Description

@kecmen

Hi,

i found few similar bugs but all of them seems to be closed in older versions of python.
On windows (10, 64b) I get an OSError if I try to get timestamp from datetime.datetime object for some dates:

>>> datetime.datetime(year=2021, month=11, day=13).timestamp()

1636758000.0

>>> datetime.datetime(year=3021, month=11, day=13).timestamp()

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

OSError: [Errno 22] Invalid argument

>>> datetime.datetime(year=1021, month=11, day=13).timestamp()

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

OSError: [Errno 22] Invalid argument

>>> sys.version

'3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)]'

>>> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    OS-windowsextension-modulesC modules in the Modules dirstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions