Skip to content

Refactor dates.ts to use native Intl APIs - #238

Merged
jrmybtlr merged 1 commit into
mainfrom
cursor/dates-native-intl-cde2
Sep 8, 2026
Merged

Refactor dates.ts to use native Intl APIs#238
jrmybtlr merged 1 commit into
mainfrom
cursor/dates-native-intl-cde2

Conversation

@jrmybtlr

@jrmybtlr jrmybtlr commented Sep 8, 2026

Copy link
Copy Markdown
Owner

Summary

src/dates.ts was carrying a lot of hand-rolled English relative-time and duration label logic. This PR leans on native Intl instead and drops ~130 lines while keeping the public API stable.

Changes

  • timeFrom: always formats with Intl.RelativeTimeFormat. English short maps to RTF narrow so documented compact outputs (3d ago, 1h ago) stay the same.
  • timeDifference: removes DURATION_LABELS_* tables; segments use Intl.NumberFormat { style: 'unit', unitDisplay }. Short auto labels now follow ICU (e.g. 5 hr instead of 5 hrs).
  • combineDates / day-month helpers: share one Intl.DateTimeFormat#formatToParts calendar path.

Verification

  • pnpm exec vitest run src/* — 339 tests passed
  • Existing dates.test.ts expectations unchanged
Open in Web Open in Cursor 

Replace hand-rolled English relative-time phrases and duration label
tables with Intl.RelativeTimeFormat and Intl.NumberFormat unit style,
and unify calendar day/month extraction via DateTimeFormat formatToParts.

Co-authored-by: Jeremy Butler <jrmybtlr@users.noreply.github.com>
@jrmybtlr
jrmybtlr marked this pull request as ready for review September 8, 2026 20:11
@jrmybtlr
jrmybtlr merged commit 1c6c44f into main Sep 8, 2026
10 checks passed
@jrmybtlr
jrmybtlr deleted the cursor/dates-native-intl-cde2 branch September 8, 2026 20:12
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.

2 participants