fix(customParseFormat): preserve years below 100 - #3214
Open
sridharkalaibala wants to merge 1 commit into
Open
sridharkalaibala wants to merge 1 commit into
sridharkalaibala wants to merge 1 commit into
Conversation
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.
Custom-format parsing currently turns
0002-08-01into1902-08-01, while strict parsing rejects it. Year zero is also treated as a missing year. These conversions affect controlled date inputs that pass through low years while the user edits the year, as reported in decaporg/decap-cms#7939.Preserve explicit years 0–99 in local, UTC, and offset parsing. Construct in the corresponding year one Gregorian cycle later, then subtract that cycle from the normalized result. This preserves leap days and month/offset rollovers; the existing
YYcentury convention stays unchanged. Distinguish an absent year from year zero when selecting defaults.This targets the custom-format parser. Existing PRs #1862 and #2551 change the separate core parser; #2076 concerns years longer than four digits.
Validation:
YYconvention. Before the fix: 14 failed, 2 passed.linebreak-styledisabled for the Windows checkout; unmodified files otherwise report CRLF errors.DateTimeControlin a controlled React harness (only button styles stubbed). Starting from2025-08-01, selected the year using Tab/Right/Right and pressed2,0,2,6separately. With the original Day.js 1.11.18 plugin, the stored date ends at1906-08-01; with the built patched plugin it progresses through0002-08-01,0020-08-01,0202-08-01, and2026-08-01. Both the visible input and stored value agree. This verifies the reported native year-entry failure and its correction in the widget harness; a full CMS integration was not run.Developed and validated with OpenAI Codex assistance.