Repository navigation
fix(date): keep full year in getDaysInMonth/getFirstDayOfMonth (#22943) - #22944
AryanSingh2029 wants to merge 1 commit into
Conversation
…s#22943) Both helpers rebuilt the month with new Date(year, month, day), which reads the years 0-99 as 1900-1999. getFirstDayOfMonth then returned the weekday of the wrong century, so the DateSelector and calendar grids placed the 1st of the month under the wrong column for those years, and getDaysInMonth gave February of the year 0 (a leap year) 28 days because 1900 is not one. Build the date with setUTCFullYear() and read it with the UTC getters, as getWeekOfYear() and convertToyyyymmdd() already do.
neo-gpt-euclid
left a comment
There was a problem hiding this comment.
PR Review Summary
Status: Approved
🪜 Strategic-Fit Decision
- Decision: Approve
- Rationale: The user reported three wrong outputs from two shared utility methods. The repair preserves the input's local year and month, then performs calendar arithmetic without the constructor's 1900 offset.
Peer-Review Opening: Thanks, Aryan, for the concise reproducer and the red-on-base test. Exercising the downstream day-offset helper in the same spec makes the change easy to verify. What Neo is · Local setup · Contributor issues
🧭 Patch-Blind Premise Snapshot
- Inputs Read Before Patch: Grounded in #22943's reported values, the two documented utility methods, the existing
setUTCFullYear()precedent in the file, and the selector call sites at the candidate head. - Expected Solution Shape: Keep both methods' existing Date argument and primitive result. Derive calendar coordinates from the input's local fields and preserve the full year during day-count and weekday calculations.
- Patch Verdict: Matches. The two helpers produce the correct month length and weekday for their supplied year and month, and the day-offset call uses the corrected weekday.
- Premise Coherence: The small utility fix keeps the calculation shared by existing consumers and covers the report's concrete failure.
🕸️ Context & Graph Linking
- Target Epic / Issue ID: Resolves #22943
- Related Graph Nodes:
Neo.util.Date,DateSelector, anddate.DayViewComponent - Origin Session ID: f92c60d6-fedd-43ef-8da3-dbc60d556f29
- PR body identifies the contributor and discloses AI assistance.
🔬 Depth Floor
Challenge: I ran the exact methods from base and head. For the ticket's inputs, base returned 28, 0, 5 and head returned 29, 6, 4 in UTC, Pacific/Kiritimati and Pacific/Niue. On head I checked all 1,200 months in years 0–99 plus six representative later years in each zone. Month lengths matched Gregorian leap-year arithmetic and weekdays matched ISO dates parsed in UTC. Invalid dates still returned NaN.
Rhetorical-Drift Audit: There is one independently observed exception to the PR body's later-year statement. In Pacific/Kiritimati the old helper returned 1 for December 1994 because the local calendar skipped its last date. The new helper returns the Gregorian month length, 31. This improves the same calendar calculation. The separate month/year selection paths still construct an intermediate date using the legacy year constructor, as the body records. The closure evidence covers the helpers and their day-offset consumer.
🧠 Graph Ingestion Notes
[RETROSPECTIVE]Read the year and month in the caller's local calendar, then calculate the resulting Gregorian month on a stable UTC reference date.
N/A Audits — 📡 🔗
N/A across listed dimensions: no MCP description or cross-skill change.
🎯 Close-Target Audit
- #22943 is the single close target, labelled
bugandcore. - Its reported expectation is the direct
29, 6, 4utility output. The new regression covers the report.
Findings: The unchanged selector navigation paths are documented. They do not alter the direct helper results that close #22943.
📑 Contract Completeness Audit
Findings: The existing Date input and numeric outputs remain. The named issue and method docs specify the calendar data the two helpers return. Candidate behavior agrees with the proleptic Gregorian results in the exact-source probe.
🪜 Evidence Audit
- #22943 provides a unit-level reproducer and the PR cites a red-on-base test.
- Exact-head hosted regression passed in the default project and the Kiritimati and Niue projects. Independent base/head results agreed across three zones.
Findings: The helper fix has the unit evidence the issue asks for. The selector's full navigation journey is outside this proof.
🧪 Test-Evidence & Location Audit
- Exact-head required CI passed at
4d7a20b749c9ee63f5cab27ec279cee595f38dd2. - The new case ran in all three projects of hosted unit job 142512666628.
- The owning
test/playwright/unit/util/Date.spec.mjscovers the report and the public day-offset call. - The independent comparison checked 1,272 months per timezone and the invalid-Date fallback.
Findings: The exact-head test and source probe agree, with the original failure reproduced on base.
📋 Required Actions
No required actions — eligible for human merge.
📊 Evaluation Metrics
[ARCH_ALIGNMENT]: 96. The two calculations stay in the shared Date utility and reuse the file's UTC arithmetic convention.[CONTENT_COMPLETENESS]: 88. The reproducer, regression and consumer scope are documented. The historical skipped-day exception qualifies the later-year statement.[EXECUTION_QUALITY]: 97. Reported values, month-length and weekday controls, invalid input and hosted timezone coverage agree.[PRODUCTIVITY]: 96. The two reported helper outputs and their day-offset consumer are repaired.[IMPACT]: 49. Corrects early-year calendar values used by multiple components.[COMPLEXITY]: 15. Two existing methods and one focused regression.[EFFORT_PROFILE]: Quick Win. A narrow repair to shared calendar arithmetic.
Resolves #22943
Neo.util.Date.getDaysInMonth()andgetFirstDayOfMonth()rebuilt the month withnew Date(year, month, day), whichreads the years 0-99 as 1900-1999. For those years
getFirstDayOfMonth()returned the weekday of the wrong century, soDateSelectoranddate.DayViewComponentplaced the 1st of the month under the wrong column, andgetDaysInMonth()gave February of the year 0 28 days because 1900 is not a leap year. Both now build the date with
setUTCFullYear()andread it with the UTC getters, as
getWeekOfYear()andconvertToyyyymmdd()in the same file already do. Results foryears 100 and later do not change, and there is no public API change.
Evidence: L2 (new unit spec fails on
devand passes on this branch, plus the unit tiers below) -> L2 required (#22943).AC Evidence
test/playwright/unit/util/Date.spec.mjs›getDaysInMonth and getFirstDayOfMonth keep the full year for years below 100No structured ACs on #22943; the row above covers the reported values.
Deltas from ticket
None substantive.
Test Evidence
New spec on
dev(53c5e38),NEO_UNIT_TZ=Pacific/Kiritimati npm run test-unit-tz -- test/playwright/unit/util/Date.spec.mjs:Same command on this branch:
16 passed.Also run on this branch, all passing:
NEO_UNIT_TZ=Pacific/Kiritimati npm run test-unit-tzandNEO_UNIT_TZ=Pacific/Niue npm run test-unit-tzTZ=UTC npm run test-unit -- test/playwright/unit/util(205 passed)TZ=UTC npm run test-unit -- test/playwright/unit/date test/playwright/unit/calendar test/playwright/unit/selection(82 passed)TZ=UTC npm run test-unit -- test/playwright/unit/form test/playwright/unit/component(538 passed)check-whitespace,check-shorthand,check-jsdoc-types,check-parseandcheck-coding-guidelineson both files.Not covered: I did not run the component or e2e browser tiers, and I did not check the DateSelector grid for an early
year in a browser.
DateSelector.onMonthYearSelect()anddate.SelectorContainer.changeMonth()still passnew Date(year, month, 1)togetDaysInMonth(), so the day clamp there reads 1900 for the year 0; this PR leavesthose callers unchanged.
Post-Merge Validation
None required.
Parts of this change were written with an AI coding assistant. The bug was reproduced on the base branch, and the new test fails there and passes here.
Authored by @AryanSingh2029 (Claude Opus 5.5, reasoning: default, Claude Code).