PureScript bindings for the JavaScript Temporal API.
spago install js-temporalModule documentation is published on Pursuit.
The examples/ directory is a separate Spago package containing PureScript translations of recipes from the Temporal Cookbook. Run all examples:
nix develop
just run-examplesOr run a single example:
spago run -p js-temporal-examples -m Examples.Cookbook.CurrentDateTimeThe 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.