intervalEngulfsDate
Signature
Section titled “Signature”intervalEngulfsDate(aStart: string, aEnd: string, bStart: string, bEnd: string): booleanReturn true when the half-open interval B [bStart, bEnd) lies within the half-open interval A [aStart, aEnd) — every day of B is also in A.
- Half-open: an interval holds every
twithstart <= t < end. B may start at A’s start and end at A’s end, because neither end is part of either interval. - B must also overlap A, so an empty B (
bStart === bEnd) counts only strictly inside A, never at an edge (CORE-6’sclampIntervalclamps it away there). - Equivalent to 4-argument
intervalContainsDate(aStart, aEnd, bStart, bEnd). - 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 outer interval start, optionally calendar-annotated |
aEnd | string | ISO 8601 date string for the outer interval end (excluded), optionally calendar-annotated |
bStart | string | ISO 8601 date string for the inner interval start, optionally calendar-annotated |
bEnd | string | ISO 8601 date string for the inner interval end (excluded), optionally calendar-annotated |
Returns
Section titled “Returns”true if B lies within A, or false on invalid input
Examples
Section titled “Examples”import { intervalEngulfsDate } from "@northguild/gmt/plain/interval";
intervalEngulfsDate("2024-01-01", "2024-12-31", "2024-06-01", "2024-07-01") // true