About date-fns
date-fns is an agent skill for working with date-fns v4 and its timezone packages. It guides code changes by checking installed versions and time-zone intent, then points to focused documentation and verification steps.
Key features
- 01Guidance for date-fns v4 date operations
- 02Formatting and parsing recommendations
- 03Timezone and DST handling guidance
- 04FP mode, locales, and TypeScript guidance
- 05Migration and verification checklists
Use cases
- 01Choosing date-fns APIs for calendar calculations
- 02Handling UTC or named IANA time zones
- 03Reviewing date formatting and parsing code
- 04Planning date-fns version migrations
Install
Copy the command and run it in a terminal.
$
npx skills add https:/ / github.com/ dobroslavradosavljevic/ skills --skill date-fnsAfter installing, type/date-fnsin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/format-parse.mdfp-locales-types.mdmanipulate-compare.mdmigration-pitfalls.mdsetup-core.mdsource-map.mdtimezones.mdDetails
From the project READMEdate-fns
Use this skill for date-fns v4 date math, formatting, parsing, FP mode, locales, and official timezone packages @date-fns/tz / @date-fns/utc.
Workflow
- Inspect the local surface before changing code:
- Packages:
date-fns, optional@date-fns/tz,@date-fns/utc(and legacydate-fns-tzif present). - Versions: prefer date-fns ≥ 4 for first-class
{ in }/TZDate/UTCDateinterop. v3 is common but local-only unless usingdate-fns-tz. - Zone intent: system-local UI, UTC-normalized server math, or named IANA zones (user/venue/HQ).
- Imports: named from
"date-fns","date-fns/fp","date-fns/locale/*","date-fns/constants".
- Packages:
- Refresh docs when versions are unclear or work touches timezones, Unicode tokens, SSR, or major upgrades. Start from source-map.md.
- Route deeper detail:
- Install, imports, core concepts, Invalid Date: setup-core.md.
format/parse/parseISO, Unicode tokens: format-parse.md.- Add/set/boundaries, diffs, Interval, Duration: manipulate-compare.md.
TZDate,UTCDate,tz/utc,transpose, DST, SSR: timezones.md.- FP, locales, TypeScript: fp-locales-types.md.
- v2→v3→v4 and
date-fns-tzmigration: migration-pitfalls.md.
- Match the project's installed major and existing import style. Do not add
@date-fns/tzor@date-fns/utcunless zone semantics require them. - Verify with typecheck plus focused tests for Invalid Date, calendar vs elapsed diffs, and zone/SSR edges when relevant.
Zone Decision Tree
System-local calendar / host TZ only?
→ plain Date + date-fns
UTC-only math (server day, charts, no IANA zones)?
→ @date-fns/utc (UTCDate / UTCDateMini or { in: utc })
Named IANA zone or multi-zone product?
→ @date-fns/tz (TZDate / TZDateMini or { in: tz("…") })
Stuck on date-fns v3?
→ upgrade to v4 + official packages, or use legacy date-fns-tz until then
Core Judgment
- Bare date-fns is system-local, not a UTC library. Use
@date-fns/utcor@date-fns/tzfor non-local calendar fields. - Prefer named imports. Constants come from
"date-fns/constants", not the main barrel. - Always
isValidbeforeformat—formatthrowsRangeErroron Invalid Date. - Unicode tokens: use
yyyy-MM-dd, never Moment-styleYYYY-MM-DD/DD(week-year / day-of-year). See format-parse.md. parseISO("YYYY-MM-DD")→ local midnight;new Date("YYYY-MM-DD")→ UTC midnight. Do not conflate.- Prefer
differenceInCalendar*for calendar-day questions;differenceIn*for elapsed full units. - With mixed zones or primitives, pin context with
{ in: tz("…") }or{ in: utc }— first objectDate/extension argument otherwise wins and order can flip day math. new TZDate(iso, zone)≠ legacytoZonedTime. Same instant, different wall clock. Wall-clock remapping usestranspose.- Prefer full
TZDate/UTCDateat library boundaries; Mini variants skip zone-awaretoString/ locale formatters (system-zone leak). - Do not confuse
@date-fns/tzwith third-partydate-fns-tz.
Verification
Prefer repository-owned commands. Cover the relevant subset:
bun pm ls date-fns @date-fns/tz @date-fns/utc(anddate-fns-tzif migrating).- Typecheck for
DateArg, options types, and extension return types. - Tests: valid/invalid parse, Unicode tokens, calendar vs elapsed diffs, reversed intervals, DST spring-forward/fall-back,
{ in }vs argument-order zone selection. - SSR/hydration smoke when formatting “today” or local day boundaries across server (often UTC) and client (local).
Report which checks ran, which did not, and version assumptions that remain.
Comments
Markdown supported