-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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
timedelta fails to consider fold #112638
Comments
As the docs say for
So it's working as designed and documented. The intended way to do timezone-aware arithmetic is to convert inputs to UTC first, and do the arithmetic on UTC objects. Within a single timezone ("same tzinfo attribute"), arithmetic acts as if the |
It looks like this implementation behaviour of
This should be extended to "have the same tzinfo and fold attributes, the tzinfo attributes are ignored". |
I don't think so, alas. datetime arithmetic within a time zone was always intended to be naïve. If a
Again, like it or not 😉, time zone aware arithmetic is intended to be done by converting to UTC first. |
Note that the referenced PEP does address this case explicitly:
And reiterates the intended approach:
Since everything is working here as designed and as documented, I'm going to close this. |
Closing as "not planned". |
By the way, the timedelta docs don't inform about lack of support of folded tzaware timestamps nor about the necessity of converting to UTC). I think they should as someone could expect different behavior knowing about the fold attribute. I will try to issue a PR to extend the docs in this regard. |
I was also thinking about amending the documentation to explain this somewhat; please do ping me if a PR is raised to call the behaviour out. |
Bug report
Bug description:
CPython versions tested on:
3.12
Operating systems tested on:
macOS
The text was updated successfully, but these errors were encountered: