THE INVESTIGATION
The year that rewrites the month
Changing only the year unexpectedly moves an ordinary date to the end of its month.
Real incidentsCalendar arithmeticRegression testing
What’s going wrong
Input is an array of at most 100 {date, year} rows. date is a valid YYYY-MM-DD date with year 1900..2399; year is an integer in 1900..2399. Replace only the year, preserving month and day except that February 29 becomes February 28 when the destination year is not leap. Use Gregorian leap-year rules and UTC only. Return YYYY-MM-DD strings. Ordinary dates from leap years must not change their day of month.
Expected behavior
Limit special-case repair to the date that needs it.
Reproduction
01 Unrelated date in a leap year
[{"date":"2024-07-09","year":2023}]["2023-07-09"]
02 February 29 clamps control
[{"date":"2024-02-29","year":2023}]["2023-02-28"]
03 Non-leap source control
[{"date":"2023-07-04","year":2025}]["2025-07-04"]
Before you begin
- JavaScript Date UTC methods
- Gregorian leap years
Need a nudge?
Reveal one investigation hint at a time. Try each clue before opening the next.
The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
Ready when you are
Every fix starts with a failing test.
Read the report, then sign in to start your investigation.