Skip to content
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

Add test illustrating mismatched time zone time and zoned datetime #6239

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sffc
Copy link
Member

@sffc sffc commented Mar 6, 2025

I realized that ZonedDateTime can contain two different datetimes: the "main" datetime and the reference datetime for the time zone.

It's fairly easy to get into this state. For example, someone might pick "Unix epoch" or "current datetime" to put into the fairly obscure at_time function when constructing their TimeZoneInfo, which is almost always wrong.

This might be partially mitigated if we change the reference datetime to be an absolute time (#6238) so that there isn't a categorical mismatch, but it can still happen.

Maybe fine to ignore. If people use infer_zone_offsets, they won't get a specific non-location zone name that is wrong, only not applicable at the given time, which is confusing but not wrong. (However, if they pull the zone variant from isdst, maybe things could go wrong.)

@robertbastian

@sffc sffc requested a review from zbraniecki as a code owner March 6, 2025 02:11
@robertbastian
Copy link
Member

I don't think this is a bug, and I don't think absolute timestamps are the solution here, because they don't solve the problem of having two inputs that need to agree.

We could change the GetField implementations on ZonedDateTime to ignore the .at_time value in favour of the date and time values. This does, however, add a calendar conversion if the ZDT is not in ISO time, and the user will still need to supply that second time, and it will still be used for infer_zone_variant.

I'm leaning more and more in the direction of having infer_zone_variant happen internally. I have yet to find a client who can actually guarantee a rearguard isdst anyway.

@sffc
Copy link
Member Author

sffc commented Mar 6, 2025

Discussed: OK to ignore this edge case in 2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants