UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

27 lines • 2.17 kB
/** * Return true when the half-open interval B `[bStart, bEnd)` lies within the half-open interval * A `[aStart, aEnd)` — every moment of B is also in A. * * - Half-open: an interval holds every `t` with `start <= 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's `clampInterval` clamps it away there). * - Equivalent to 4-argument `intervalContainsDateTime(aStart, aEnd, bStart, bEnd)`. * - Uses `Temporal.PlainDateTime.compare` for comparison. * - Returns `false` if either interval is invalid (`start > end`). * - Returns `false` on invalid input (wrong type, malformed strings). * * @param aStart ISO 8601 datetime string for the outer interval start * @param aEnd ISO 8601 datetime string for the outer interval end (excluded) * @param bStart ISO 8601 datetime string for the inner interval start * @param bEnd ISO 8601 datetime string for the inner interval end (excluded) * @returns true if B lies within A, or false on invalid input * * @example intervalEngulfsDateTime("2024-01-01T09:00:00", "2024-01-01T17:00:00", "2024-01-01T12:00:00", "2024-01-01T13:00:00") // true * @example intervalEngulfsDateTime("2024-01-01T09:00:00", "2024-01-01T17:00:00", "2024-01-01T09:00:00", "2024-01-01T17:00:00") // true (equal intervals) * @example intervalEngulfsDateTime("2024-01-01T09:00:00", "2024-01-01T17:00:00", "2024-01-01T12:00:00", "2024-01-01T17:00:00") // true (same end) * @example intervalEngulfsDateTime("2024-01-01T09:00:00", "2024-01-01T17:00:00", "2024-01-01T12:00:00", "2024-01-01T12:00:00") // true (empty interval strictly inside) * @example intervalEngulfsDateTime("2024-01-01T09:00:00", "2024-01-01T17:00:00", "2024-01-01T17:00:00", "2024-01-01T17:00:00") // false (empty interval at the edge) * @example intervalEngulfsDateTime("2024-01-01T12:00:00", "2024-01-01T13:00:00", "2024-01-01T09:00:00", "2024-01-01T17:00:00") // false */ export declare function intervalEngulfsDateTime(aStart: string, aEnd: string, bStart: string, bEnd: string): boolean;