isValidDateInterval
Signature
Section titled “Signature”isValidDateInterval(start: string, end: string): booleanimport { isValidDateInterval } from "@northguild/gmt/plain/interval";Return true if start and end form a valid date interval — both parseable as
- ISO PlainDate strings and
start <= end. - Both inputs must be ISO 8601 date strings (e.g.
"2024-01-01"). - Equal
start === endis valid. - Invalid input, malformed strings, or leap-second strings return
false. - Accepts GMT calendar-annotated PlainDate strings — E5 (issue #78). Ordering is calendar-independent, so
start/endmay carry different or no calendar tags (D4).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
start |
string |
ISO 8601 date string (interval start), optionally calendar-annotated |
end |
string |
ISO 8601 date string (interval end), optionally calendar-annotated |
Returns
Section titled “Returns”true if start and end form a valid date interval, or false on invalid input
Examples
Section titled “Examples”isValidDateInterval("2024-01-01", "2024-12-31") // trueisValidDateInterval("2024-01-01", "2024-01-01") // trueisValidDateInterval("2024-12-31", "2024-01-01") // falseisValidDateInterval("invalid", "2024-12-31") // falseisValidDateInterval("5785-01-01[u-ca=hebrew]", "2024-12-31") // true (mixed calendars — ordering is calendar-independent)