isValidUtcInterval
Signature
Section titled “Signature”isValidUtcInterval(start: string, end: string): booleanimport { isValidUtcInterval } from "@northguild/gmt/utc/interval";Return true if start and end form a valid UTC interval — both parseable as
- ISO UTC datetime strings and the instant at
startis <= the instant atend. - Both inputs must be ISO 8601 UTC datetime strings (e.g.
"2024-01-01T10:00:00Z"). - Equal
start === endis valid. - Leap-second strings return
false. - Invalid input or malformed strings return
false.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
start |
string |
ISO 8601 UTC datetime string (interval start) |
end |
string |
ISO 8601 UTC datetime string (interval end) |
Returns
Section titled “Returns”true if start and end form a valid UTC interval, or false on invalid input
Examples
Section titled “Examples”isValidUtcInterval("2024-01-01T10:00:00Z", "2024-12-31T23:59:59Z") // trueisValidUtcInterval("2024-01-01T10:00:00Z", "2024-01-01T10:00:00Z") // trueisValidUtcInterval("2024-12-31T23:59:59Z", "2024-01-01T10:00:00Z") // falseisValidUtcInterval("invalid", "2024-12-31T23:59:59Z") // false