Date-fns-style utilities for the Temporal API.
Read the documentation.
Experimental. The API and behavior may change.
ESM with TypeScript declarations and tree-shakable named imports.
The full API, including /calendar, bundles to approximately 23.5 kB minified (8.6 kB gzipped) with Rolldown 1.2.15, excluding any Temporal polyfill.
npm install @frantss/temporal-fnsRequires a global Temporal. If your runtime does not provide it, install the polyfill:
npm install temporal-polyfillLoad it once in your application entry point, before using the library:
import 'temporal-polyfill/global';import { addBusinessDays, format, tryParse } from '@frantss/temporal-fns';
const reference = Temporal.PlainDate.from('2026-10-22');
const nextWorkingDate = addBusinessDays(reference, 1, { weekendDays: [5, 6] });
format(nextWorkingDate, 'yyyy-MM-dd'); // 2026-10-25
const [error, parsed] = tryParse('2024-02-29', 'yyyy-MM-dd', reference);
if (error === null) {
console.log(parsed.toString()); // 2024-02-29
}- Calendar operations support ISO 8601 only.
- Calendar operations on
Instantrequire an explicittimeZone. - Relative descriptions and duration labels support
en-USonly. Token text uses the host'sIntllocale data. tryParseandtryParseDurationreturn[null, result]or[error, null]. Invalid patterns, options, and incompatible inputs still throw.
Browse the API reference for descriptions, examples, related APIs, and behavior specifications. Calendar-widget adapters use the @frantss/temporal-fns/calendar entry point.
Use the Node version in .node-version.
npm ci
npm run build
npm run checkRun the executable Gherkin specifications with npm test. Tests use the Temporal polyfill by default; use npm run test:native on a runtime with native Temporal.
Run the Fumadocs site with npm run docs:dev. Build static files with npm run docs:build. The site uses the reusable @frantss/fumadocs-theme package.