Repository navigation
Accept era years of three or more digits in Date._jisx0301 - #195
Open
Shaisolaris wants to merge 1 commit into
Open
Shaisolaris wants to merge 1 commit into
Shaisolaris wants to merge 1 commit into
Conversation
Date#jisx0301 writes the era year as is, so dates from 2118 on are written as R100.01.01 and later. Date._jisx0301 only accepted two digits there, so Date.jisx0301 could not read such strings back and raised Date::Error. Accept three or more digits when an era initial is given, as Date._parse already does.
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.
Date#jisx0301writes the era year without a limit on its width, so dates from 2118 on (Reiwa 100) come out with three digits, butDate._jisx0301only accepts two digits there. The output of#jisx0301then cannot be read back:This change accepts three or more digits for the era year when an era initial is present. Without an initial, the year still has to be two digits, so a string like
100.05.01is still rejected.Tests:
test__jisx0301forR100.05.01,R100.05.01T04:05:06+09:00,100.05.01and aDate.jisx0301(d.jisx0301)round trip. They fail on master and pass with this change.iso8601,rfc3339,xmlschema,rfc2822,httpdateandjisx0301over 100,000 random dates in years 1 to 9999 now passes for all of them. Before the change,jisx0301failed for every date from 2118 on.test/date/test_*.rblocally (Ruby 3.3.8): the failures and errors I see are the same on master and with this change (test__plus__ex,test_new_offset, and tests that needassert_warning,assert_ractorand similar helpers from ruby core that my setup does not load). I did not run the CI matrix.