Skip to content

isValidCalendarZonedInterval

isValidCalendarZonedInterval(start: string, end: string): boolean

Return 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-aware zoned/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.Instant carries no calendar field at all, and ZonedDateTime.compare / Instant.compare both return 0 for 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 === end is 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); see isValidCalendarZonedDateTime.
ParameterTypeDescription
startstringISO or RFC 9557 calendar-annotated ZonedDateTime string (interval start)
endstringISO or RFC 9557 calendar-annotated ZonedDateTime string (interval end)

true if start and end form a valid zoned interval, or false on invalid input

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
output 

zoned/interval/validate/isValidCalendarZonedInterval.ts