Repository navigation
Preserve four-digit years when parsing week and ordinal dates - #1400
Open
charan-rathore wants to merge 1 commit into
Open
charan-rathore wants to merge 1 commit into
charan-rathore wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1400 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 10 10
Lines 2315 2315
Branches 358 358
=========================================
Hits 2315 2315 ☔ View full report in Codecov by Harness. |
agammann
approved these changes
Nov 1, 2026
agammann
left a comment
There was a problem hiding this comment.
I reviewed the two reconstruction paths at 9fd3c50. Both values are integer years before formatting, and four-digit padding matches strptime requirements for years below 1000 without changing modern years. The new ordinal and ISO-week cases, including modern-year controls, pass locally (24 focused tests on Python 3.14.8). I did not run the full interpreter matrix; GitHub currently shows three setup failures outside the changed parser path.
This branch has not been deployed
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.
Pull Request Checklist
2224255.Description of Changes
Parsing valid ISO week or ordinal dates with a year below 1000 fails after the parser converts the year to an integer and reconstructs an unpadded string for
strptime. For example,0001-W01-1becomes1-1-1, and0001-002becomes1-2. Python'sstrptimerequires years below 1000 to be zero-filled to four digits.Preserve that four-digit year width in the two intermediate strings. The tests cover years 1, 4, 12, 99, 400 and 999, with 1000 and 2024 as controls, both ordinal tokens, and ISO week parsing through the parser and public API. Week-date expectations use
datetime.fromisocalendar.This follows up on #1328, which was closed by its author without merging. Credit to @santhreal for the earlier repair. This change keeps the year-padding correction and adds regression coverage; it excludes the earlier PR's unrelated CI edits. It is separate from #1371's formatter output and #1338's factory tuple/week-53 validation.
Validation on Python 3.12/macOS:
git diff --checkpass.Prepared with OpenAI Codex assistance through source inspection and local regression testing; this was not encountered in production.
Upstream CI checkpoint
Three matrix jobs failed before running tests: Ubuntu 26.04 could not provide Python 3.8/3.9 through setup-python, and Windows PyPy failed during dependency installation with
IncompleteReaddownload errors while building PyYAML dependencies. Existing #1393 discusses CI compatibility; this parser PR does not change workflows or dependency policy. The remaining completed checks pass, including the coverage check at this checkpoint. These failures are not counted as passing validation.