isValidDateTimeInterval
Signature
Section titled “Signature”isValidDateTimeInterval(start: string, end: string): booleanReturn true if start and end form a valid datetime interval — both parseable as ISO PlainDateTime strings and start <= end.
- Both inputs must be ISO 8601 datetime strings (e.g.
"2024-01-01T10:00:00"). - Equal
start === endis valid. - Invalid input, malformed strings, or leap-second strings return
false. - Each endpoint must satisfy
isValidDateTime, so annotations are read as Temporal reads them: a time zone annotation ([Europe/Paris]),[u-ca=iso8601]and an elective annotation ([foo=bar]) are ignored; an unknown critical annotation ([!foo=bar]) and a non-ISO calendar is rejected.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
start | string | ISO 8601 datetime string (interval start) |
end | string | ISO 8601 datetime string (interval end) |
Returns
Section titled “Returns”true if start and end form a valid datetime interval, or false on invalid input
Examples
Section titled “Examples”import { isValidDateTimeInterval } from "@northguild/gmt/plain/interval";
isValidDateTimeInterval("2024-01-01T10:00:00", "2024-12-31T23:59:59") // true