Package

purescript-js-temporal

Repository
pete-murphy/purescript-js-temporal
License
MIT
Uploaded by
pacchettibotti
Published on
2026-03-08T20:29:54Z

PureScript bindings for the JavaScript Temporal API.

Installation

spago install js-temporal

Documentation

Module documentation is published on Pursuit.

Examples

The examples/ directory is a separate Spago package containing PureScript translations of recipes from the Temporal Cookbook. Run all examples:

nix develop
just run-examples

Or run a single example:

spago run -p js-temporal-examples -m Examples.Cookbook.CurrentDateTime

purescript-datetime Interop

The library provides conversion functions between js-temporal types and purescript-datetime types, so you can integrate with existing code that uses Data.Date, Data.Time, Data.DateTime, or Data.DateTime.Instant.

js-temporal purescript-datetime
PlainDate Data.Date.Date
PlainTime Data.Time.Time
PlainDateTime Data.DateTime.DateTime
Instant Data.DateTime.Instant
Duration Data.Time.Duration.Milliseconds

Each module exports fromX / toX functions for its corresponding type — for example, PlainDate.fromDate and PlainDate.toDate. All conversions round-trip at the precision supported by purescript-datetime (milliseconds). Microsecond and nanosecond components are dropped when converting to purescript-datetime types.

Duration.fromMilliseconds and Duration.toMilliseconds support fixed-unit durations only (days, hours, minutes, seconds, milliseconds); calendar units (years, months, weeks) are not supported.

ZonedDateTime, PlainYearMonth, and PlainMonthDay have no purescript-datetime equivalents.