isValidZonedRange
Signature
Section titled “Signature”isValidZonedRange({ value1, value2, options, }: { value1: string; value2: string; options?: { allowEqual?: boolean; }; }): booleanimport { isValidZonedRange } from "@northguild/gmt/zoned/validate";Return true if value1 and value2 form a valid zoned range — both parseable as
- ISO ZonedDateTime strings and the instant at
value1is <= the instant atvalue2. - Both inputs must be valid ISO 8601 zoned datetime strings.
- Equal
value1 === value2is valid whenoptions.allowEqualis true. - Comparison is done by instant, so intervals spanning DST transitions are compared by absolute time.
- Invalid input, malformed strings, or leap-second strings return
false.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value1 |
`` | first ISO ZonedDateTime string |
value2 |
`` | second ISO ZonedDateTime string |
options |
`` | optional allowEqual flag |
Returns
Section titled “Returns”boolean indicating whether the zoned range is valid
Examples
Section titled “Examples”isValidZonedRange({ value1: "2024-01-01T10:00:00+00:00[UTC]", value2: "2024-12-31T23:59:59+00:00[UTC]" }) // trueisValidZonedRange({ value1: "2024-12-31T23:59:59+00:00[UTC]", value2: "2024-01-01T10:00:00+00:00[UTC]" }) // falseisValidZonedRange({ value1: "2024-06-15T12:00:00-04:00[America/New_York]", value2: "2024-06-15T12:00:00-04:00[America/New_York]", options: { allowEqual: true } }) // true