isValidZonedInterval
Signature
Section titled “Signature”isValidZonedInterval(start: string, end: string): booleanReturn true if start and end form a valid zoned interval — both valid ISO ZonedDateTime strings (isValidZonedDateTime) and the instant at start is <= the instant at end.
- Both inputs must be valid ISO 8601 zoned datetime strings.
- Equal
start === endis valid. - Comparison is done by instant, so intervals spanning DST transitions are compared by absolute time.
- Reads RFC 9557 annotations as
isValidZonedDateTimedoes:[u-ca=iso8601]and elective annotations ([foo=bar]) are accepted, an unknown critical annotation ([!foo=bar]) is rejected, and a non-ISO calendar isisValidCalendarZonedInterval’s input. - Invalid input, malformed strings, or leap-second strings return
false.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
start | string | ISO ZonedDateTime string (interval start) |
end | string | ISO 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 { isValidZonedInterval } from "@northguild/gmt/zoned/interval";
isValidZonedInterval("2024-01-01T10:00:00+00:00[UTC]", "2024-12-31T23:59:59+00:00[UTC]") // true