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.

26 lines • 1.72 kB
/** * Return true when the half-open time intervals `[aStart, aEnd)` and `[bStart, bEnd)` share at * least one clock time. * * - Half-open: an interval holds every `t` with `start <= t < end`, so `end` itself is not in it * (the rule CORE-6's `intervalsOverlap` uses). The test is `aStart < bEnd && bStart < aEnd`. * - Touching intervals (`aEnd` equal to `bStart`) share no time and do not overlap. * - An empty interval (`start === end`) overlaps only an interval it lies strictly inside. * - PlainTime has no day rollover: an interval never wraps past midnight. * - Uses `Temporal.PlainTime.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 time string for the first interval start * @param aEnd ISO 8601 time string for the first interval end (excluded) * @param bStart ISO 8601 time string for the second interval start * @param bEnd ISO 8601 time string for the second interval end (excluded) * @returns true if intervals overlap, or false on invalid input * * @example intervalsOverlapTime("09:00:00", "17:00:00", "12:00:00", "18:00:00") // true * @example intervalsOverlapTime("09:00:00", "17:00:00", "17:00:00", "18:00:00") // false (touching) * @example intervalsOverlapTime("09:00:00", "17:00:00", "18:00:00", "20:00:00") // false (disjoint) * @example intervalsOverlapTime("09:00:00", "17:00:00", "10:00:00", "11:00:00") // true (contained) * @example intervalsOverlapTime("invalid", "17:00:00", "12:00:00", "18:00:00") // false */ export declare function intervalsOverlapTime(aStart: string, aEnd: string, bStart: string, bEnd: string): boolean;