Ready for the future of JavaScript dates
A lightweight, tree-shakable library for JavaScript's Temporal API. Functional design, full TypeScript support, and zero dependencies.
npm install temporal-kit
Functional & Composable
Build complex logic with pipe and compose. Data-last design for better readability.
Tree-Shakable
Modular architecture. Import only what you need, keep your bundle size tiny.
Type-Safe
Written in TypeScript with strict mode. Catch errors at compile time, not runtime.
Future-Proof
Built directly on the ECMAScript Temporal API. No proprietary date objects to learn.
Locale-Aware
Leverages Intl for robust, localized date formatting and relative time strings.
Universal
Runs anywhere JavaScript runs. Works with native Temporal or any standard polyfill.
API Overview
A quick look at the available utilities.
🔄 Conversion
nowZonedDateTime (system TZ)todayPlainDate (optional TZ)nowZonedZonedDateTime (explicit TZ)fromISOparse ISO stringtoPlainDatetoPlainDateTimetoZonedDateTime
🔍 Comparison
isBeforeisAfterisSameisBetweenclamprange checksminmaxextremesisSameDayisSameWeekisSameMonthcompareraw comparison (-1/0/1)
🧮 Arithmetic
addsubtractdurationsstartOfendOfperiod boundariesfloorceilroundroundingnextDayaddBusinessDays
📆 Ranges
rangesOverlapinterval checkstepIntervalgeneric iteratoreachDayOfIntervaldaily stepseachWeekOfIntervalweekly stepseachMonthOfIntervalmonthly stepseachYearOfIntervalyearly steps
🌐 Formatting
formatlocalized date stringformatTimeformatDateTimeformatRelative"2 days ago"formatCalendarcontext-aware label
✅ Validation
isValidDateStringisValidTimeStringisValidDateTimeStringisValidInstantStringisValidZonedStringisValidTimezonegetTimezoneName
📦 Collections
sortAscsortDescsort datesclosestTofind nearest
🛡️ Guards & Functional
isPlainDateisInstantisDurationisZonedDateTimeisDateLikeisWeekendpipecompose