@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
21 lines (20 loc) • 1.46 kB
TypeScript
/**
* Return true when intervals `[aStart, aEnd]` and `[bStart, bEnd]` share at least one instant.
*
* - Uses `Temporal.Instant.compare` for comparison (same instant semantics).
* - Adjacent intervals (e.g. `aEnd === bStart`) do NOT overlap — returns `false`.
* - Returns `false` if either interval is invalid (`start > end`).
* - Returns `false` on invalid input (wrong type, malformed strings, leap seconds).
*
* @param aStart ISO 8601 UTC datetime string for the first interval start
* @param aEnd ISO 8601 UTC datetime string for the first interval end
* @param bStart ISO 8601 UTC datetime string for the second interval start
* @param bEnd ISO 8601 UTC datetime string for the second interval end
* @returns true if intervals overlap, or false on invalid input
*
* @example intervalsOverlapUtc("2024-01-01T00:00:00Z", "2024-06-30T23:59:59Z", "2024-04-01T00:00:00Z", "2024-12-31T23:59:59Z") // true
* @example intervalsOverlapUtc("2024-01-01T00:00:00Z", "2024-06-30T23:59:59Z", "2024-07-01T00:00:00Z", "2024-12-31T23:59:59Z") // false (adjacent)
* @example intervalsOverlapUtc("2024-01-01T00:00:00Z", "2024-06-30T23:59:59Z", "2024-07-02T00:00:00Z", "2024-12-31T23:59:59Z") // false (disjoint)
* @example intervalsOverlapUtc("invalid", "2024-06-30T23:59:59Z", "2024-04-01T00:00:00Z", "2024-12-31T23:59:59Z") // false
*/
export declare function intervalsOverlapUtc(aStart: string, aEnd: string, bStart: string, bEnd: string): boolean;