Repository navigation
Parse two-digit years relative to today in parse_date - #1449
Merged
akx merged 3 commits intoNov 9, 2026
Merged
Conversation
parse_date('3/9/99', locale='en_US') gave 2099-03-09, so a date formatted in
a short pattern did not parse back. Use the same window as ICU: 80 years
before and 20 years after today.
akx
requested changes
Nov 9, 2026
akx
left a comment
Member
There was a problem hiding this comment.
Could you augment the comment/docstring with a reference to the relevant ICU implementation source code, or better yet, a spec document?
Contributor
Author
|
Added to the docstring, with a link to ICU's |
akx
approved these changes
Nov 9, 2026
akx
left a comment
Member
There was a problem hiding this comment.
Augmented the tests a bit, etc. Thanks.
akx
enabled auto-merge (squash)
November 9, 2026 13:21
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1449 +/- ##
==========================================
+ Coverage 93.62% 93.64% +0.01%
==========================================
Files 27 27
Lines 4973 4986 +13
==========================================
+ Hits 4656 4669 +13
Misses 317 317
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
parse_date('3/9/99', locale='en_US')returns2099-03-09. A date fromformat_date(date(1999, 3, 9), 'short', locale='en_US')doesn't parse back to itself, and old dates such as birth dates land a century in the future.Two-digit years now fall within 80 years before and 20 years after today, the window ICU and Java use.
4/1/04is still 2004.Added a test, it fails without the change. The test suite passes.