intervalContainsZoned
Signature
Section titled “Signature”intervalContainsZoned(intervalStart: string, intervalEnd: string, pointOrStart: string, pointEnd?: string): booleanReturn true when pointOrStart falls within the half-open interval [intervalStart, intervalEnd) (3-arg), or when the inner interval [innerStart, innerEnd) lies within the outer interval [intervalStart, intervalEnd) (4-arg).
- Uses
Temporal.Instant.comparefor comparison (same instant semantics). - Point mode:
start <= point < end, the same rule asintervalContains. Theendis excluded, so a point atend’s instant returnsfalse, and an empty interval (startandendthe same instant) contains no point. - Interval mode: the intervals overlap and
start <= innerStartandinnerEnd <= end. An inner interval may share the outerend. An empty inner interval counts only strictly inside the outer interval, the same edge rule asclampInterval, and an empty outer interval contains nothing. - Returns
falseifintervalStart > intervalEnd(invalid outer interval). - Returns
falseifinnerStart > innerEndin 4-arg mode (invalid inner interval). - Returns
falseon invalid input (wrong type, malformed strings, leap seconds). - Accepts mixed calendar systems (E7’s D4-zoned, issue #152): both bare ISO zoned strings and RFC 9557 calendar-annotated ones (
"2024-02-24T14:30:00-05:00[America/New_York][u-ca=hebrew]"), and the endpoints need not agree on a calendar. Ordering is calendar-independent — verified thatTemporal.Instantcarries no calendar field at all and thatInstant.compare/ZonedDateTime.compareboth return0for the same instant expressed in hebrew, islamic-civil, japanese and iso8601. - Rejects a calendar annotation before the time zone annotation, which is not RFC 9557.
- Compatibility: since 1.16.0 calendar strings are RFC 9557 (ISO digits, the
[u-ca=<id>]annotation after the zone, canonical calendar ids); seeisValidCalendarZonedDateTime.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
intervalStart | string | ISO 8601 zoned datetime string for the outer interval start |
intervalEnd | string | ISO 8601 zoned datetime string for the outer interval end |
pointOrStart | string | ISO 8601 zoned datetime string for the point (3-arg) or inner start (4-arg) |
pointEnd | string | optional ISO 8601 zoned 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 { intervalContainsZoned } from "@northguild/gmt/zoned/interval";
intervalContainsZoned("2024-01-01T00:00:00+00:00[UTC]", "2024-12-31T23:59:59+00:00[UTC]", "2024-06-15T12:00:00+00:00[UTC]") // true