isValidCalendarZonedInterval
Signature
Section titled “Signature”isValidCalendarZonedInterval(start: string, end: string): booleanimport { isValidCalendarZonedInterval } from "@northguild/gmt/zoned/interval";Return true if start and end form a valid GMT zoned interval — both parseable as bare ISO
- or GMT calendar-annotated ZonedDateTime strings, and the instant at
startis <= the instant atend. - Parallel to
isValidZonedInterval, which is deliberately left unchanged and still rejects every[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 Temporal’s
[timeZone][u-ca=...]ordering, leap seconds, non-strings, and any unparseable endpoint.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
start |
string |
ISO or GMT calendar-annotated ZonedDateTime string (interval start) |
end |
string |
ISO or GMT 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”isValidCalendarZonedInterval("2024-01-01T10:00:00+00:00[UTC]", "2024-12-31T23:59:59+00:00[UTC]") // trueisValidCalendarZonedInterval("5784-06-15T14:30:00-05:00[u-ca=hebrew][America/New_York]", "5784-07-15T14:30:00-04:00[u-ca=hebrew][America/New_York]") // trueisValidCalendarZonedInterval("5784-06-15T14:30:00-05:00[u-ca=hebrew][America/New_York]", "1445-09-15T14:30:00-04:00[u-ca=islamic-civil][America/New_York]") // true (mixed calendars accepted)isValidCalendarZonedInterval("2024-12-31T23:59:59+00:00[UTC]", "2024-01-01T10:00:00+00:00[UTC]") // false (start after end)isValidCalendarZonedInterval("2024-01-01T10:00:00+00:00[UTC][u-ca=hebrew]", "2024-12-31T23:59:59+00:00[UTC]") // false (Temporal's segment ordering)isValidCalendarZonedInterval("invalid", "2024-12-31T23:59:59+00:00[UTC]") // false