isValidCalendarZonedInterval
Signature
Section titled “Signature”isValidCalendarZonedInterval(start: string, end: string): booleanReturn true if start and end form a valid GMT zoned interval — both parseable as bare ISO or RFC 9557 calendar-annotated ZonedDateTime strings, and the instant at start is <= the instant at end.
- Parallel to
isValidZonedInterval, which accepts only ISO-calendar endpoints and rejects every non-ISO[u-ca=...]annotation (E7, issue #152). Only the calendar-awarezoned/interval/*functions gate on this one. - Mixed calendars are accepted (E7’s D4-zoned, matching E5’s D4): ordering is calendar-independent. Verified against
@js-temporal/polyfill@0.5.1—Temporal.Instantcarries no calendar field at all, andZonedDateTime.compare/Instant.compareboth return0for the same instant expressed in hebrew, islamic-civil, japanese and iso8601. A Hebrew start with an Islamic end is a well-formed interval. - Equal
start === endis valid. - Comparison is done by instant, so intervals spanning DST transitions are compared by absolute time.
- Rejects a calendar annotation before the zone (not RFC 9557), leap seconds, non-strings, and any unparseable endpoint.
- Compatibility: since 1.16.0 calendar strings are RFC 9557 (ISO digits, the
[u-ca=<id>]annotation after the zone, canonical calendar ids); seeisValidCalendarZonedDateTime.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
start | string | ISO or RFC 9557 calendar-annotated ZonedDateTime string (interval start) |
end | string | ISO or RFC 9557 calendar-annotated ZonedDateTime string (interval end) |
Returns
Section titled “Returns”true if start and end form a valid zoned interval, or false on invalid input
Examples
Section titled “Examples”import { isValidCalendarZonedInterval } from "@northguild/gmt/zoned/interval";
isValidCalendarZonedInterval("2024-01-01T10:00:00+00:00[UTC]", "2024-12-31T23:59:59+00:00[UTC]") // true