intervalContainsUtc
Signature
Section titled “Signature”intervalContainsUtc(intervalStart: string, intervalEnd: string, pointOrStart: string, pointEnd?: string): booleanReturn true when pointOrStart lies in the half-open interval [intervalStart, intervalEnd) (3-arg), or when the inner interval [innerStart, innerEnd) lies within it (4-arg).
- Half-open: an interval holds every instant
twithstart <= t < end, sointervalEnditself is outside (the rule CORE-6’sintervalContainsuses). An empty interval (start === end) contains no point. - 4-arg: the inner interval must start at or after
intervalStart, end at or beforeintervalEnd, and overlap the outer interval. An empty inner interval therefore counts only strictly inside, never at an edge (CORE-6’sclampIntervalclamps it away there). - The 3-argument form delegates to CORE-6’s
intervalContainsonce the arguments pass the UTC-string gate. - Uses
Temporal.Instant.comparefor comparison. - Returns
falseifintervalStart > intervalEnd(invalid outer interval). - Returns
falseifinnerStart > innerEndin 4-arg mode (invalid inner interval). - Returns
falseon invalid input (wrong type, non-Zstrings, malformed strings, leap seconds).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
intervalStart | string | ISO 8601 UTC datetime string for the outer interval start |
intervalEnd | string | ISO 8601 UTC datetime string for the outer interval end (excluded) |
pointOrStart | string | ISO 8601 UTC datetime string for the point (3-arg) or inner start (4-arg) |
pointEnd | string | optional ISO 8601 UTC datetime string for the inner interval end (4-arg mode) |
Returns
Section titled “Returns”true if the point or inner interval is contained, or false on invalid input
Examples
Section titled “Examples”import { intervalContainsUtc } from "@northguild/gmt/utc/interval";
intervalContainsUtc("2024-01-01T09:00:00Z", "2024-01-01T17:00:00Z", "2024-01-01T12:00:00Z") // true