Repository navigation
Fix week formatting at the maximum supported year - #1403
Closed
KennyMcSimpson wants to merge 1 commit into
Closed
KennyMcSimpson wants to merge 1 commit into
KennyMcSimpson wants to merge 1 commit into
Conversation
Derive the next January weekday from December 31 to avoid constructing an out-of-range date for valid date.max and datetime.max values. Cover all six CLDR week rules at both supported date boundaries.
Member
|
Sorry, I don't think this is necessary. We can get back to this once formatting such datetimes are a pressing issue. |
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.
Formatting
date.maxordatetime.maxwith a week field raisesValueError: year 10000 is out of rangefor locales such as en_US, en_AU and aa_DJ.get_week_of_year()constructs the following January 1 only to obtain its weekday. Derive that weekday from the current December 31 instead, keeping the calculation inside Python's date range and preserving the existing locale week rules.Add 24 regression/control cases for both public formatters at both supported date boundaries across all six CLDR week rules. Against unchanged production code, eight maximum-year cases fail and sixteen controls pass. With the fix, all 24 pass; an independent all-locale boundary audit also passes all 4,484 checks (previously 1,944 failures).
Validation: complete Python 3.13 suite (7,853 passed, nine skipped, two expected failures; 93% coverage), date tests and doctests on Python 3.10 (2,464 passed, two expected failures), full Ruff and whitespace checks. Tested on Windows with repository-pinned CLDR 48.2 data.
Prepared with OpenAI Codex assistance; no independent human review is claimed.