Skip to content

fix(gottext): write a bare calendar day with only the parts it is handed - #152

Merged
SirLouen merged 2 commits into
mainfrom
fix/151-gottext-day-options
Nov 9, 2026
Merged

SirLouen merged 2 commits into
mainfrom
fix/151-gottext-day-options

Conversation

@SirLouen

@SirLouen SirLouen commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Closes #151

What

  • formatDate reads each date option of a bare calendar day by name from the object it is handed, then shows the day in UTC.
  • Options still come through their prototype, from a getter, and from a frozen object naming another zone.

Why

The options of a bare day were rebuilt from resolvedOptions, which reads letters inside quoted pattern text as fields. So es-ES, pt-BR and ca-ES gained a day on { month: 'long', year: 'numeric' }, eu gained an hour, and a calendar such as -u-ca-chinese lost its year.

Testing

  • The new es-ES and calendar tests failed first, with 30 de septiembre de 2026 and 08-07.
  • A table test checks that every option that changes the output is kept, with a bare day written as midnight UTC on that day.
  • A sweep of 557 locales with 19 option sets found 867 pairs where a bare day and a timestamp disagreed before the fix, and none after, on Node 22 and 26.
  • 277 tests at 100 percent coverage, types, lint, knip and the build pass on Node 22 and 26.

Summary by CodeRabbit

  • Bug Fixes
    • Bare calendar dates now honor the date components and locale you provide, while preserving the date’s year across calendar systems.
    • Bare dates and equivalent timestamps now format consistently at UTC midnight across supported date-format options.
    • Using timeStyle when formatting either a bare date or a timestamp now raises a TypeError.

@greptile-apps

This comment has been minimized.

@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

formatDate now formats bare calendar-day strings with caller-supplied date options and a UTC time zone. Tests cover locale and calendar output, option handling, and timeStyle errors. The Unreleased changelog records the change.

Changes: Bare calendar date formatting

Layer / File(s) Summary
Apply UTC date options and validate formatting
gottext/src/format.ts, gottext/test/format.test.ts, gottext/CHANGELOG.md
Bare calendar-day strings use caller-supplied date options with UTC. Tests compare output across locales, calendars, and date options, and check that timeStyle throws for dates and timestamps. The changelog records the change.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: Minimal · up to 587ec

No merge-blocking issue was identified for bare-date formatting.

Pre-merge checks: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: formatDate for bare calendar days now writes only the date parts the caller supplies, rather than parts rebuilt from resolvedOptions. The changelog, format.ts, and tes…
Linked Issues check Passed [#151] Objective: for a bare calendar day, read each date option by name from the object handed in, through its prototype and getters, then show the day in UTC. Add tests for es-ES and for a calendar …
Out of Scope Changes check Passed The changed files are gottext/src/format.ts, gottext/test/format.test.ts and gottext/CHANGELOG.md. The change summaries state that the source change only affects bare calendar-day option handling (DAT…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check

Explanation

The title names the main change: formatDate for bare calendar days now writes only the date parts the caller supplies, rather than parts rebuilt from resolvedOptions. The changelog, format.ts, and tests all concern this behavior, and the linked issue asks for the same fix. The title follows the conventional commit style and is specific, so it passes.

Full details: Linked Issues check

Explanation

[#151] Objective: for a bare calendar day, read each date option by name from the object handed in, through its prototype and getters, then show the day in UTC. Add tests for es-ES and for a calendar extension. Evidence at the reviewed head: gottext/src/format.ts defines DATE_OPTIONS, which lists every Intl.DateTimeFormatOptions key except timeZone. inUTC(options) builds its option set with Object.fromEntries(DATE_OPTIONS.map((name) => [name, options[name]])). Property access reads inherited and getter-defined values. The function then sets timeZone: 'UTC', which replaces any zone named by a frozen object. writeDay passes this set to toLocaleDateString only when the input matches CALENDAR_DAY. Timestamps keep the caller's options. The rebuild from resolvedOptions is gone, so letters inside quoted pattern text are no longer read as fields. The es-ES test in gottext/test/format.test.ts expects 'septiembre de 2026' for { month: 'long', year: 'numeric' } and matches the timestamp output. The calendar test uses es-ES-u-ca-chinese and expects the year and a match with the 12:00Z timestamp. A table test covers output-changing options, including calendar, era, dayPeriod, hour12, hourCycle, timeZoneName and fractionalSecondDigits, and checks each against midnight UTC. Tests for prototype, getter and frozen-object inputs are not present. The issue does not require them. Test results were not run in this review.

Full details: Out of Scope Changes check

Explanation

The changed files are gottext/src/format.ts, gottext/test/format.test.ts and gottext/CHANGELOG.md. The change summaries state that the source change only affects bare calendar-day option handling (DATE_OPTIONS and inUTC). The changelog adds one Unreleased entry that documents the same fix. The added tests cover bare-day output, the calendar-extension case and output-changing options, all tied to #151. At the reviewed head, formatTime, formatWeekday, formatNumber, formatList and formatMoney show no behavior unrelated to bare-day formatting. The writeDay path that formatWeekday uses now applies inUTC only for bare calendar days, which is part of the same fix. Limitation: the whole-PR diff tool and the base revision blob were unavailable, so the exact added and removed lines were not compared against base. This assessment relies on head file contents and the change summaries.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Finishing Touches

Generate docstrings

  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 13088902-6280-4399-9caf-b153b3e2805b
Commits

Reviewing files that changed from the base of the PR and between 462494d and 587ec81.

Files selected for processing: 1

  • gottext/test/format.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

codescene-access[bot]

This comment was marked as outdated.

@greptile-apps

greptile-apps Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge, with no outstanding findings.

Summary

formatDate now copies the supplied date options by name and keeps bare calendar days in UTC.

  • Bare calendar days keep your chosen date parts and calendar year.

Reviews (2) · Last reviewed commit: "test(gottext): pin the bare day options ..." · Reviewed by Greptile

Comment thread gottext/test/format.test.ts Resolved

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Gates Passed
4 Quality Gates Passed

See analysis details in CodeScene

Quality Gate Profile: Clean Code Collective
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

@SirLouen
SirLouen merged commit 5afdccb into main Nov 9, 2026
50 checks passed
@SirLouen
SirLouen deleted the fix/151-gottext-day-options branch November 9, 2026 12:05
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.

formatDate adds parts to a bare calendar day handed options

1 participant