FormatJS

Temporal for Rust

formatjs_temporal is an allocation-free no_std Temporal core. It provides typed dates, times, durations, calendars, time zones, and Now.

Installation

cargo add formatjs_temporal --features compiled_data

The published crate includes generated calendar and time-zone data and a Cargo build script.

Parse a zoned date and time

use formatjs_temporal::{TemporalContext, ZonedParseOptions};

fn main() -> Result<(), formatjs_temporal::Error> {
    let context = TemporalContext::compiled()?;
    let meeting = context.parse_zoned(
        "2020-03-07T12:00-05:00[America/New_York]",
        ZonedParseOptions::default(),
    )?;

    println!("{}", meeting.instant());
    // 2020-03-07T17:00:00Z
    Ok(())
}

Reuse the context across calls. Parsed values keep their calendar and time-zone providers.

Choose how to supply data

FeatureIncluded data or integration
DefaultArithmetic calendars, UTC, and fixed offsets
compiled_calendarsChinese, Dangi, and Umm al-Qura tables
compiled_time_zonesIANA history and recurring future rules
compiled_dataBoth sets of tables
ffiOptional JSON bridge for JavaScript backends

For arithmetic calendars and UTC or fixed offsets, start with empty data registries:

use formatjs_temporal::{CalendarRegistry, TemporalContext, TimeZoneRegistry};

let context = TemporalContext::new(
    CalendarRegistry::arithmetic(),
    TimeZoneRegistry::empty(),
);
let date = context.parse_date("2026-11-17")?;

To use your own data, pass a CalendarRegistry and TimeZoneRegistry to TemporalContext::new. The registries borrow the underlying tables and transition records. Keep that storage alive for as long as values use it. Time-zone records must be sorted by primary identifier, without duplicates. Callers own data loading and decoding.

Missing tables return MissingCalendarData or MissingTimeZoneData. Unknown zones return an error. For host-default lookup, TimeZoneRegistry::system falls back to UTC when the name is missing or unresolvable. Rust's Now takes a clock and time-zone provider from the embedding application.

Calendar-unit totals validate both interpolation endpoints. Exact results and zero zoned totals can fail near date limits. Plain zero totals return zero.

JavaScript and Hermes

The TypeScript polyfill exposes JavaScript Temporal. The native Hermes SDK delegates typed operations to Rust while JavaScript handles coercion, option order, and brands.

Verification

The implementation guide links to current conformance tests and calendar authority ranges. See the Rust API reference for types and methods.