isValidUtcRange
Signature
Section titled “Signature”isValidUtcRange(props: { value1: string; value2: string; options?: { allowEqual?: boolean; }; }): booleanReturn true if value1 and value2 form a valid UTC range — both parseable as ISO UTC datetime strings and the instant at value1 is before the instant at value2.
- Both inputs must be ISO 8601 UTC datetime strings (e.g.
"2024-01-01T10:00:00Z"), asisValidUtcaccepts, annotations included. - Leap-second strings return
false. - Invalid input or malformed strings return
false.
Options
Section titled “Options”props
The two ends of the range, and whether equal ends are valid
| Option | Type | Default | Description |
|---|---|---|---|
value1 | string | Required | The start of the range, as an ISO UTC datetime string. |
value2 | string | Required | The end of the range, as an ISO UTC datetime string. |
options? | object | None. Two values at the same instant are not a valid range. | The settings for the comparison. It must be an object or omitted; any other value, null included, returns false. |
options.allowEqual? | boolean | false | Whether value1 at the same instant as value2 is a valid range. false requires value1 to be before value2. |
Returns
Section titled “Returns”boolean indicating whether the UTC range is valid
Examples
Section titled “Examples”import { isValidUtcRange } from "@northguild/gmt/utc/validate";
isValidUtcRange({ value1: "2024-01-01T10:00:00Z", value2: "2024-12-31T23:59:59Z" }) // true