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

  • now ZonedDateTime (system TZ)
  • today PlainDate (optional TZ)
  • nowZoned ZonedDateTime (explicit TZ)
  • fromISO parse ISO string
  • toPlainDate toPlainDateTime toZonedDateTime

🔍 Comparison

  • isBefore isAfter isSame
  • isBetween clamp range checks
  • min max extremes
  • isSameDay isSameWeek isSameMonth
  • compare raw comparison (-1/0/1)

🧮 Arithmetic

  • add subtract durations
  • startOf endOf period boundaries
  • floor ceil round rounding
  • nextDay addBusinessDays

📆 Ranges

  • rangesOverlap interval check
  • stepInterval generic iterator
  • eachDayOfInterval daily steps
  • eachWeekOfInterval weekly steps
  • eachMonthOfInterval monthly steps
  • eachYearOfInterval yearly steps

🌐 Formatting

  • format localized date string
  • formatTime formatDateTime
  • formatRelative "2 days ago"
  • formatCalendar context-aware label

✅ Validation

  • isValidDateString isValidTimeString
  • isValidDateTimeString
  • isValidInstantString
  • isValidZonedString
  • isValidTimezone getTimezoneName

📦 Collections

  • sortAsc sortDesc sort dates
  • closestTo find nearest

🛡️ Guards & Functional

  • isPlainDate isInstant isDuration
  • isZonedDateTime isDateLike
  • isWeekend
  • pipe compose