Skip to content

fix(date): keep full year in getDaysInMonth/getFirstDayOfMonth (#22943) - #22944

Open
AryanSingh2029 wants to merge 1 commit into
neomjs:devfrom
AryanSingh2029:fix/date-month-fields-early-years
Open

AryanSingh2029 wants to merge 1 commit into
neomjs:devfrom
AryanSingh2029:fix/date-month-fields-early-years

Conversation

@AryanSingh2029

Copy link
Copy Markdown
Contributor

Resolves #22943

Neo.util.Date.getDaysInMonth() and getFirstDayOfMonth() rebuilt the month with new Date(year, month, day), which
reads the years 0-99 as 1900-1999. For those years getFirstDayOfMonth() returned the weekday of the wrong century, so
DateSelector and date.DayViewComponent placed the 1st of the month under the wrong column, and getDaysInMonth()
gave February of the year 0 28 days because 1900 is not a leap year. Both now build the date with setUTCFullYear() and
read it with the UTC getters, as getWeekOfYear() and convertToyyyymmdd() in the same file already do. Results for
years 100 and later do not change, and there is no public API change.

Evidence: L2 (new unit spec fails on dev and passes on this branch, plus the unit tiers below) -> L2 required (#22943).

AC Evidence

AC Proof
AC-1 test/playwright/unit/util/Date.spec.mjs › getDaysInMonth and getFirstDayOfMonth keep the full year for years below 100

No 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:

    Expected: 29
    Received: 28
  1 failed
    [unit-engine-tz-Pacific/Kiritimati] › test/playwright/unit/util/Date.spec.mjs:99:5 › Neo.util.Date › getDaysInMonth and getFirstDayOfMonth keep the full year for years below 100
  15 passed (1.7s)

Same command on this branch: 16 passed.

Also run on this branch, all passing:

  • NEO_UNIT_TZ=Pacific/Kiritimati npm run test-unit-tz and NEO_UNIT_TZ=Pacific/Niue npm run test-unit-tz
  • TZ=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-parse and check-coding-guidelines on 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() and date.SelectorContainer.changeMonth() still pass new Date(year, month, 1) to getDaysInMonth(), so the day clamp there reads 1900 for the year 0; this PR leaves
those 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).

…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
neo-gpt-euclid self-requested a review December 1, 2026 09:04

@neo-gpt-euclid neo-gpt-euclid left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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, and date.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 bug and core.
  • Its reported expectation is the direct 29, 6, 4 utility 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.mjs covers 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.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

util.Date: getDaysInMonth and getFirstDayOfMonth read the years 0-99 as 1900-1999

2 participants