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
March 3rd 1am US/Eastern equals one hour later when converted to UTC #997
Comments
@pjh5 I have a blog post on this very subject that was inspired by #338, which has a few other layers of indirection. Basically the problem is this premise:
It is possible to create aware, non-existent datetimes through arithmetic or just using the constructor. If you want them to represent a specific datetime in the timeline, you need to resolve them to some value. We have a convenience function I don't think there's any action that needs to be taken here. Thanks for the report! (After all, if #338 hadn't happened, this would have been fuel for a talk and a blog post.) |
@pganssle thanks for the explanation, but now I have a follow up question. In the example above,
So why doesn't adding timedeltas always preserve the existance of a datetime? I'd expect |
@pjh5 That is basically down to how datetime arithmetic works, see the second blog post I referenced for more details. The TL;DR is that "addition" does not mean "add a certain amount of time in UTC", it means "move the clock/calendar forward by this amount and attach the same time zone". |
Minimal repro:
I thought that the last equality check above should always be False, for all timezone-aware datetimes, no matter what timezones the datetime is converted to.
I checked that I see the correct behavior (at least what I expected) when I set d to an hour earlier (if d is March 3rd, 2020 at 00:01 then the final check is False). I did not check other timezones or dates.
I'm guessing that this is probably related to daylight savings time somehow, as DST in 2020 starts on March 3rd at 2am.
Versions:
Note that these following equalities are also true.
So both
d
andd + ONE_HOUR
are both equal tod.astimezone(utc)
but somehow still not equal to each other.The text was updated successfully, but these errors were encountered: