UNPKG

@burglekitt/gmt

Version:

Temporal-based date and time utilities with timezone support and polyfill integration

32 lines (31 loc) 2.53 kB
/** * Return true when `pointOrStart` falls within the interval `[intervalStart, intervalEnd]` * (3-arg), or when the inner interval `[innerStart, innerEnd]` is fully contained within * the outer interval `[intervalStart, intervalEnd]` (4-arg). * * - Uses `Temporal.Instant.compare` for comparison (same instant semantics). * - Always-inclusive boundaries: `start <= point <= end`. * - Returns `false` if `intervalStart > intervalEnd` (invalid outer interval). * - Returns `false` if `innerStart > innerEnd` in 4-arg mode (invalid inner interval). * - Returns `false` on invalid input (wrong type, malformed strings, leap seconds). * - **Accepts mixed calendar systems** (E7's D4-zoned, issue #152): both bare ISO zoned strings * and GMT calendar-annotated ones (`"5784-06-15T14:30:00-05:00[u-ca=hebrew][America/New_York]"`), * and the endpoints need not agree on a calendar. Ordering is calendar-independent — verified * that `Temporal.Instant` carries no calendar field at all and that * `Instant.compare`/`ZonedDateTime.compare` both return `0` for the same instant expressed in * hebrew, islamic-civil, japanese and iso8601. * - Still rejects Temporal's own `[timeZone][u-ca=...]` RFC 9557 ordering, which reads GMT's * calendar-native digits as ISO digits — see `regex/calendar-zoned-date-time.ts`. * * @param intervalStart ISO 8601 zoned datetime string for the outer interval start * @param intervalEnd ISO 8601 zoned datetime string for the outer interval end * @param pointOrStart ISO 8601 zoned datetime string for the point (3-arg) or inner start (4-arg) * @param pointEnd optional ISO 8601 zoned datetime string for the inner interval end (4-arg mode) * @returns true if the point or inner interval is contained, or false on invalid input * * @example 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 * @example 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]", "2024-07-15T12:00:00+00:00[UTC]") // true * @example intervalContainsZoned("2024-12-31T23:59:59+00:00[UTC]", "2024-01-01T00:00:00+00:00[UTC]", "2024-06-15T12:00:00+00:00[UTC]") // false * @example intervalContainsZoned("invalid", "2024-12-31T23:59:59+00:00[UTC]", "2024-06-15T12:00:00+00:00[UTC]") // false */ export declare function intervalContainsZoned(intervalStart: string, intervalEnd: string, pointOrStart: string, pointEnd?: string): boolean;