fix(customParseFormat): correct meridiem parsing for non-English locales#3129
Open
sukvvon wants to merge 1 commit into
Open
fix(customParseFormat): correct meridiem parsing for non-English locales#3129sukvvon wants to merge 1 commit into
sukvvon wants to merge 1 commit into
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
customParseFormat'smeridiemMatchmisread PM strings as AM for locales that define ameridiemfunction (e.g.ko오전/오후), causing strict-mode parsing to fail.The loop iterated
1..24and decided AM/PM withi > 12. Because dayjs uses a 12-hour clock, the PM string first matched ati = 12, where12 > 12isfalse, so it was treated as AM and strict parsing returnedInvalid Date.This changes the loop to iterate
0..23and decide withi >= 12. TheindexOfmatch is kept intact: with CJK formats such asYYYY年M月D日A...the literal separators bleed into theAtoken (the parser receives"年月日晚上"), so the partial match is required and the existingzh-cnbehavior is preserved.Fixes #2031
Before
After
Tests
Added strict-mode
komeridiem cases (AM, PM, noon, midnight, 11 PM) intest/plugin/customParseFormat.test.js. Full suite passes (778 tests), including existingzh-cnAM/PM cases.