temporal library
TC39 Temporal date/time API for Dart.
On web targets (where dart:js_interop is available), this library
delegates to temporal_js, which calls the browser's native Temporal API.
On all other platforms (Dart VM, Flutter mobile/desktop) it delegates to
temporal_native, which is backed by temporal_rs via FFI.
Both implementations expose an identical public API, so code written against this package runs unchanged on every platform.
now()timezone note: On native platforms thenow()factories return the current instant expressed in UTC. On web they return the current instant expressed in the system's local timezone, following the behaviour of the browser'sTemporal.NowAPI. UseZonedDateTime.now(timeZone: tz)when you need consistent timezone semantics across platforms.
Classes
- Calendar
- A calendar system used to interpret dates.
- Instant
- An exact point in time, represented as milliseconds since the Unix epoch (1970-01-01T00:00:00Z).
- PlainDate
- A calendar date (year, month, day) with no time component and no timezone.
- PlainDateTime
- A combined calendar date and wall-clock time with no timezone.
- PlainMonthDay
- A month and day with no year, time, or timezone.
- PlainTime
- A wall-clock time (hour, minute, second, sub-second) with no date and no timezone.
- PlainYearMonth
- A year and month with no day, time, or timezone.
- TemporalDuration
- A duration spanning both calendar units (years, months, weeks, days) and time units (hours, minutes, seconds, milliseconds, microseconds, nanoseconds).
- TimeZone
-
An IANA timezone identifier (e.g.
'America/New_York','UTC'). - ZonedDateTime
- A date and time anchored to an IANA timezone.
Exceptions / Errors
- TemporalException
-
Thrown when a Temporal operation fails due to invalid input or out-of-range
values. kind contains the error category name from the TC39 spec
(e.g.
'range','type','syntax','generic').