-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
datetime.timestamp() fails before 1970-01-02T01:00:00.000000 #94414
Comments
|
Cannot reproduce this on Arch with python 3.10.5 with the system clock set to UTC+1. Perhaps this only affects Windows. Are you able to reproduce this using python 3.10? sam@samtop ~ % python
Python 3.10.5 (main, Jun 6 2022, 18:49:26) [GCC 12.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from datetime import datetime, timezone
>>> datetime(1970,1,1,0,0,0, tzinfo=None).timestamp()
-3600.0
>>> datetime(1970,1,1,0,0,0, tzinfo=timezone.utc).timestamp()
0.0
>>> import time
>>> time.tzname
('GMT', 'BST')
>>> |
This should come from the fact that without any timezone specified, the lib relies on the Windows function which does not support times before the Epoch. The strange thing is that the whole day after the Epoch is unusable, which cannot be explained only by time zone. |
While running property-based tests with Hypothesis, I discovered that Specifically:
I suspect this is related to the max value of the argument to |
This issue is present on Windows 10 for Python 9, Python10 and Python11, and on Windows 11 for Python 11. I did not tested it on Python 9 and Python 10 on Windows 11. In addition to the import dateime
a = datetime.datetime(1901, 12, 25)
b = a.astimezone(tz=datetime.timezone.utc) Note: This issue is likely related to #81708 |
This issue is present on Python 3.12.7 on Windows 10 32bit and is causing me issues between production and development enviroments |
@picnixz Maybe you could clean this up (since you seem to like triaging ;-) and decide which one should stay (at least please do add the os-windows labels, this project really needs some triaging :-( and unfortunately there is no way for most people to help with that) ? They are all because we use localtime_s
|
Python 3.8.10
datetime 4.4
Windows 10
Minimal datetime where timestamp() is fine:
The text was updated successfully, but these errors were encountered: