Temporal
Temporal is the modern date/time API, a global namespace that needs no import. This page samples Cruft's implementation, the PlainDate, Duration, Instant, and ZonedDateTime types and their arithmetic, rounding, and correct daylight-saving handling, with runnable examples.
Temporal is the modern date/time API, a global namespace, no import. Cruft's implementation is broad and behaves spec-conformantly across the operations shown here, including the DST, overflow, and calendar-unit rounding edge cases. This page samples the surface.
The surface
A representative slice of the supported operations (not exhaustive; the arithmetic, rounding, and conversion families extend further than shown):
| Type | Operations |
|---|---|
Now | instant(), plainDateISO(), zonedDateTimeISO() |
PlainDate | from, add, subtract, until, since, with, compare, dayOfWeek, weekOfYear |
PlainTime | from, add, until |
PlainDateTime | from, add (and the rest of the arithmetic family) |
Duration | from, total(unit), add, round, negated |
Instant | from, add, until, epochMilliseconds, epochNanoseconds |
ZonedDateTime | from, add, including correct DST handling |
PlainYearMonth, PlainMonthDay | from, toString |
A few worth showing:
Temporal.PlainDate.from("2026-07-25").add({ days: 10 }).toString(); // "2026-08-04"
Temporal.PlainDate.from("2026-01-01").until("2026-07-25").toString(); // "P205D"
Temporal.Duration.from({ hours: 25 }).total("days"); // 1.0416666666666667
Temporal.Duration.from({ minutes: 150 }).round({ largestUnit: "hours" }).toString(); // "PT2H30M"
// DST is handled correctly — spring-forward skips the 2 AM hour:
Temporal.ZonedDateTime.from("2026-03-08T01:00[America/New_York]")
.add({ hours: 2 }).toString(); // "2026-03-08T04:00:00-04:00[America/New_York]"
The DST result reflects real timezone arithmetic.
For the broader web-platform surface see Web platform globals.