intervalsOverlapDate
Signature
Section titled “Signature”intervalsOverlapDate(aStart: string, aEnd: string, bStart: string, bEnd: string): booleanReturn true when the half-open date intervals [aStart, aEnd) and [bStart, bEnd) share at least one day.
- Half-open: an interval holds every date
dwithstart <= d < end, soenditself is not in it (the rule CORE-6’sintervalsOverlapuses). The test isaStart < bEnd && bStart < aEnd. - Touching intervals (
aEndequal tobStart) share no day and do not overlap. - An empty interval (
start === end) overlaps only an interval it lies strictly inside. - Uses
Temporal.PlainDate.comparefor comparison. - Returns
falseif either interval is invalid (start > end). - Returns
falseon invalid input (wrong type, malformed strings). - Accepts RFC 9557 calendar-annotated PlainDate strings — E5 (issue #78). Ordering is calendar-independent, so arguments may carry different or no calendar tags (D4).
- Compatibility: since 1.16.0 calendar strings are RFC 9557 (ISO digits,
[u-ca=<id>], canonical calendar ids); seeisValidCalendarDate.
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 (excluded), 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 (excluded), optionally calendar-annotated |
Returns
Section titled “Returns”true if intervals overlap, or false on invalid input
Examples
Section titled “Examples”import { intervalsOverlapDate } from "@northguild/gmt/plain/interval";
intervalsOverlapDate("2024-01-01", "2024-06-30", "2024-04-01", "2024-12-31") // true