parseAsDuration
const parseAsDuration: Parser<Temporal.Duration>;Defined in: tanstack/temporal.ts:163
A length of time — ISO-8601 duration (PT30M, P1DT2H). Equality is by
length, not spelling: PT90M equals PT1H30M, and P1D equals PT24H
(a day is 24 h, as in Temporal.Duration.compare without relativeTo).
Years, months and weeks have no fixed length, so they must match exactly:
P1M ≠ P30D, P1Y ≠ P12M, P1W ≠ P7D.
Example
Section titled “Example”import { Temporal } from "@js-temporal/polyfill";import { parseAsDuration } from "@xtandard/lib/tanstack/temporal";
parseAsDuration.parse("PT90M")?.total("minutes"); // → 90parseAsDuration.serialize(Temporal.Duration.from({ hours: 1, minutes: 30 })); // → "PT1H30M"parseAsDuration.parse("90 minutes"); // → nullparseAsDuration.eq(Temporal.Duration.from("PT90M"), Temporal.Duration.from("PT1H30M")); // → true