intervalAbutsZoned
Signature
Section titled “Signature”intervalAbutsZoned(aStart: string, aEnd: string, bStart: string, bEnd: string): booleanReturn true when two half-open zoned intervals [start, end) are exactly adjacent — one ends at the instant the other starts, so they share no instant and leave no gap (Allen’s “meets”, either order).
- Uses
Temporal.Instant.comparefor comparison (via.toInstant()), so the shared instant may be spelled in different zones. - Returns
truewhenaEndis the same instant asbStart, orbEndthe same instant asaStart, and neither interval is empty. No instant is stepped by a nanosecond, so an interval ending at the last representable instant is handled like any other. - Returns
falsewhen intervals overlap, are disjoint with a gap (even one nanosecond), are invalid, or when either is empty (startandendthe same instant): an empty interval abuts nothing. - 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 two 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 |
|---|---|---|
aStart | string | ISO 8601 zoned datetime string for the first interval start |
aEnd | string | ISO 8601 zoned datetime string for the first interval end |
bStart | string | ISO 8601 zoned datetime string for the second interval start |
bEnd | string | ISO 8601 zoned datetime string for the second interval end |
Returns
Section titled “Returns”true if intervals are exactly adjacent, or false on invalid input
Examples
Section titled “Examples”import { intervalAbutsZoned } from "@northguild/gmt/zoned/interval";
intervalAbutsZoned("2024-01-01T09:00:00+00:00[UTC]", "2024-06-30T12:00:00+00:00[UTC]", "2024-06-30T12:00:00+00:00[UTC]", "2024-12-31T17:00:00+00:00[UTC]") // true