Skip to content

Conversation

@Xiphoseer
Copy link

@Xiphoseer Xiphoseer commented Oct 15, 2025

Alternative to #2251 to fix #2249. Adjust the bounds check instead of introducing a helper function. Added test cases making use of existing locale data.

Had to use belarussian locale because that's the only one with a monthsShort where the string for december actually differs between format and standalone variants.

Fixes #2249
Fixes #2483
Fixes #2511

When the months/monthsShort locale date is split
into standalone and format parts the matchIndex
will be 12n + 11 for december, which ends up as 0
if one is added before the modulo, which results
in e.g. 0 || 23 == 23, interpreted by dayjs as dec
next year, since it's invalid to assume that the
original matchIndex is <= 12.

Instead do the modulo before adding one and adjust
the bounds check.

Fixes iamkun#2249
Copy link
Contributor

@Ayo1984 Ayo1984 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants