CodeVetter · Repo Unpack · Feature catalog
date-fns/date-fns
The primary user surface is a broad collection of date APIs, with individual imports and functional-programming variants. Formatting and parsing combine Unicode-style tokens with locale-specific behavior. Calendar operations and interval enumeration preserve date-extension context. Companion packages expose UTC and arbitrary-zone dates, while repository examples and documentation tooling support integration and publication.
- Calendar APIs include addition, subtraction, calendar differences, predicates, and start/end boundaries; addMonths clamps dates to the destination month's last day.
- format supports escaped literals, localized P/p expansion, locale preprocessing, and token dispatch; formatDate is an alias.
- parse consumes text against a format and reference date, rejects incompatible token combinations, permits trailing whitespace, and validates setters before returning a date.
- eachDayOfInterval returns cloned midnight dates inclusively, supports reversed intervals and negative steps, and returns an empty array for a zero step.
- formatDistance selects localized second-to-year phrases using elapsed time and offset correction; locale objects also supply relative formats, long formats, localization, and parsing matches.
- The FP surface curries functions with reversed arguments; generated WithOptions variants retain the options argument, while @pure false functions are skipped.
- Time-zone APIs provide tz/utc context factories, zone conversion preserving timestamps, UTC offsets, offset-change scanning, and four zone-name styles.
- Maintainer-facing features include documentation publication and --rollback; integration examples display yyyy-MM-dd in React and log UTC TZDate representations in the playground.