fix: preserve unsupported year tokens in format (#3015)#3016
fix: preserve unsupported year tokens in format (#3015)#3016iamkun merged 3 commits intoiamkun:devfrom
Conversation
|
Perhaps it would be better to update the REGEX_FORMAT regex constant to YYYY|YY to address this issue at the source. |
|
Thanks, I agree that tightening I also agree that One point I want to clarify is the expected behavior for My current preference is to treat If you agree with that interpretation, I can adjust the implementation and tests in that direction. |
|
Thanks for the clarification. I agree that interpreting YYY as YY + a literal Y makes sense. It keeps the rule simple: supported tokens are parsed normally, and the remaining characters fall back to literal text. That behavior looks reasonable to me. |
|
Thanks for confirming. I’ve updated the implementation accordingly. |
|
THX |
Summary
This changes
format()so unsupported year tokens are preserved literally instead of falling through to the timezone-offset fallback.Closes #3015.
Root Cause
REGEX_FORMATmatchesY{1,4}, butformat()only implementsYYandYYYY.Previously, unmatched tokens fell through to:
That fallback was intended for
ZZ, but it also affected unsupported tokens such asYandYYY, causing them to be formatted as timezone offsets.Changes
ZZexplicitly informat()display.test.jsfor:YYYY