-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
gh-107078: fix astimezone on Windows
#107176
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
Conversation
|
Hello! Bumping the PR in case someone can take a look |
| else | ||
| u2 = u1 - max_fold_seconds; | ||
| #ifdef MS_WINDOWS | ||
| u2 += max_fold_seconds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we only want to do this if it's too small? Otherwise it has the potential to do the conversion wrong if you put in a "normal" time that's within max_fold_seconds of an offset change (either DST or legal change). We probably assume that none of these happened on the first day after epoch.
Otherwise, this seems like a fine way to handle it. A "real" fix would be much more complex, and probably inconsistent with actual timezone aware datetimes, which I'm sure are the preferred approach these days.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @zooba. See the Windows-specific comment in datetime_from_timet_and_us().
Also this change needs tests.
| else | ||
| u2 = u1 - max_fold_seconds; | ||
| #ifdef MS_WINDOWS | ||
| u2 += max_fold_seconds; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @zooba. See the Windows-specific comment in datetime_from_timet_and_us().
Also this change needs tests.
|
A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated. Once you have made the requested changes, please leave a comment on this pull request containing the phrase |
|
I merged #143463 instead. Thanks for your contribution anyway ;-) |
_datetimemodule.cwhen callingdatetime.datetime.fromtimestamp(0).astimezone()withOSErroron Windowsdatetime.fromtimestamp(t).astimezone()fails for0<=t<86400in Windows #107078