-
-
Notifications
You must be signed in to change notification settings - Fork 30k
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.fromtimestamp(t).astimezone()
fails for 0
<=t
<86400
in Windows
#107078
Comments
I think the bug was introduced by cpython/Modules/_datetimemodule.c Line 6336 in 7fc9be3
If the t is not large enough, the local method will return -1 since it will minus an epoch time(62135683200).
|
The thing is that if the |
Signed-off-by: OjusWiZard <ojuswimail@gmail.com>
Signed-off-by: OjusWiZard <ojuswimail@gmail.com>
Signed-off-by: OjusWiZard <ojuswimail@gmail.com>
Signed-off-by: OjusWiZard <ojuswimail@gmail.com>
Signed-off-by: OjusWiZard <ojuswimail@gmail.com>
On Linux timestamp can be negative. Why the interval 0-86400 is so important that it is worth to support it on Windows, but not negative timestamps? It is just a limitation of the platform. |
I suspect the value I guess people are less surprised that There was some discussion about adopting ICU for this kind of stuff... maybe if we ever do that we can have consistent timezone handling? |
Bug report
dt.datetime.fromtimestamp(t).astimezone()
fails for0
<=t
<86400
in Windows for at least python 3.9, 3.10, 3.11.Works fine in Linux, Mac.
A screenshot also:
Your environment
Additional information
This looks very very related to this issue: #73283 but now it seems to happen for
astimezone
.Linked PRs
astimezone
on Windows #107176The text was updated successfully, but these errors were encountered: