isValidUtcRange
Signature
Section titled “Signature”isValidUtcRange({ value1, value2, options, }: { value1: string; value2: string; options?: { allowEqual?: boolean; }; }): booleanimport { isValidUtcRange } from "@northguild/gmt/utc/validate";Return true if value1 and value2 form a valid UTC range — both parseable as
- ISO UTC datetime strings and the instant at
value1is <= the instant atvalue2. - Both inputs must be ISO 8601 UTC datetime strings (e.g.
"2024-01-01T10:00:00Z"). - Equal
value1 === value2is valid whenoptions.allowEqualis true. - Leap-second strings return
false. - Invalid input or malformed strings return
false.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value1 |
`` | first ISO UTC datetime string |
value2 |
`` | second ISO UTC datetime string |
options |
`` | optional allowEqual flag |
Returns
Section titled “Returns”boolean indicating whether the UTC range is valid
Examples
Section titled “Examples”isValidUtcRange({ value1: "2024-01-01T10:00:00Z", value2: "2024-12-31T23:59:59Z" }) // trueisValidUtcRange({ value1: "2024-12-31T23:59:59Z", value2: "2024-01-01T10:00:00Z" }) // falseisValidUtcRange({ value1: "2024-01-01T10:00:00Z", value2: "2024-01-01T10:00:00Z", options: { allowEqual: true } }) // true