temporal_js 0.0.2 copy "temporal_js: ^0.0.2" to clipboard
temporal_js: ^0.0.2 copied to clipboard

Platformweb

TC39 Temporal date/time API for Dart, backed by the JS Temporal API via dart:js_interop. Lightweight, immutable date and time types for Dart web apps.

temporal_js #

A Dart web implementation of the TC39 Temporal proposal, backed by the browser's native Temporal JS API via dart:js_interop.

This package is the web half of the temporal umbrella package. It is typically used indirectly — temporal automatically selects temporal_js on web and temporal_native on Dart VM / Flutter native.

Features #

  • PlainDate — a calendar date (year, month, day) with no time or timezone
  • PlainTime — a wall-clock time with no date or timezone
  • PlainDateTime — a combined calendar date and wall-clock time
  • PlainYearMonth — a year and month with no day or timezone
  • PlainMonthDay — a month and day with no year or timezone
  • Instant — an exact UTC point in time
  • ZonedDateTime — an exact moment tied to a specific IANA timezone
  • TemporalDuration — a duration spanning calendar and time units
  • Calendar — a calendar system (ISO 8601, Buddhist, Hebrew, etc.)
  • TimeZone — an IANA timezone identifier

All types are thin wrappers over the browser's native Temporal objects — zero parsing or arithmetic is reimplemented in Dart.

Getting started #

Use the temporal package for cross-platform code. Add temporal_js directly only when you are building a web-only package:

dependencies:
  temporal_js: ^0.0.1

Requires a browser with native Temporal support (or the temporal_js_polyfill package for older browsers).

Usage #

import 'package:temporal_js/temporal_js.dart';

// Calendar date with no time ambiguity
final birthday = PlainDate(1990, 6, 15);
final nextBirthday = birthday.add(TemporalDuration(years: 34));

// Exact moment in a specific timezone
final meeting = ZonedDateTime.now(timeZone: TimeZone('America/New_York'));

Additional information #

0
likes
140
points
155
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

TC39 Temporal date/time API for Dart, backed by the JS Temporal API via dart:js_interop. Lightweight, immutable date and time types for Dart web apps.

Repository (GitHub)
View/report issues

Topics

#date #time #temporal #datetime #js

License

unknown (license)

Dependencies

meta

More

Packages that depend on temporal_js