intervalAbutsDate
Signature
Section titled “Signature”intervalAbutsDate(aStart: string, aEnd: string, bStart: string, bEnd: string): booleanimport { intervalAbutsDate } from "@northguild/gmt/plain/interval";Return true when two date intervals are exactly adjacent — one’s end equals the other’s start
- with zero gap and zero overlap.
- Uses
Temporal.PlainDate.comparefor comparison. - Returns
truewhenaEnd + 1 day === bStartorbEnd + 1 day === aStart. - Returns
falsewhen intervals overlap, are disjoint with a gap, or are invalid. - Returns
falseon invalid input (wrong type, malformed strings). - Accepts GMT calendar-annotated PlainDate strings (as produced by
convertDateToCalendar) — E5 (issue #78). Comparison is by calendar-independent ordering (Temporal.PlainDate.compareignores calendar), so the four endpoints may carry different or no calendar tags — E5 decision of record D4 (ordering-only functions accept mixed calendars).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
aStart |
string |
ISO 8601 date string for the first interval start, optionally calendar-annotated |
aEnd |
string |
ISO 8601 date string for the first interval end, optionally calendar-annotated |
bStart |
string |
ISO 8601 date string for the second interval start, optionally calendar-annotated |
bEnd |
string |
ISO 8601 date string for the second interval end, optionally calendar-annotated |
Returns
Section titled “Returns”true if intervals are exactly adjacent, or false on invalid input
Examples
Section titled “Examples”intervalAbutsDate("2024-01-01", "2024-06-30", "2024-07-01", "2024-12-31") // trueintervalAbutsDate("2024-07-01", "2024-12-31", "2024-01-01", "2024-06-30") // trueintervalAbutsDate("2024-01-01", "2024-06-30", "2024-07-02", "2024-12-31") // false (gap)intervalAbutsDate("2024-01-01", "2024-07-01", "2024-06-30", "2024-12-31") // false (overlap)intervalAbutsDate("invalid", "2024-06-30", "2024-07-01", "2024-12-31") // false