fix(time): reject nonexistent local times - #4719
Open
Excelius-Wang wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Reject nonexistent local wall times during UTC offset transitions instead of silently converting them with the pre-transition offset.
Server Details
convert_timetoolMotivation and Context
Python allows
datetimevalues to be constructed inside a forward clock-change gap even though those wall times never occurred. For example,2026-03-08 02:30inAmerica/New_Yorkwas previously accepted and converted to07:30 UTC.The conversion now round-trips the source time through UTC and rejects it when the local wall time changes. Valid times immediately before and after the gap keep their existing behavior.
How Has This Been Tested?
uv run --python 3.12 pytest -q— 41 passeduv run --python 3.12 ruff check .uv run --python 3.12 pyright— 0 errors, 0 warningsThis is a conversion validation change and was not tested through an LLM client.
Breaking Changes
None. Inputs that do not represent a real local time now return an error instead of a misleading conversion.
Types of changes
Checklist
Additional context
This uses only the standard library and the server's existing
ZoneInfoconversion path. Python documents these skipped wall times as missing times in PEP 495.