UNPKG

@burglekitt/gmt

Version:

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

25 lines (24 loc) 1.35 kB
/** * Return the combined span of two time intervals, or null when they are disjoint. * * - Uses `Temporal.PlainTime.compare` for comparison. * - Overlapping intervals return their merged span. * - Adjacent intervals (e.g. `aEnd === bStart`) share one instant and ARE merged. * - Returns `null` if either interval is invalid (`start > end`). * - Returns `null` 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 * @param bStart ISO 8601 time string for the second interval start * @param bEnd ISO 8601 time string for the second interval end * @returns `{ start, end }` with the merged span, or null on invalid input / disjoint intervals * * @example intervalUnionTime("09:00:00", "17:00:00", "12:00:00", "18:00:00") // { start: "09:00:00", end: "18:00:00" } * @example intervalUnionTime("09:00:00", "17:00:00", "17:00:00", "18:00:00") // { start: "09:00:00", end: "18:00:00" } * @example intervalUnionTime("09:00:00", "17:00:00", "18:00:00", "20:00:00") // null * @example intervalUnionTime("invalid", "17:00:00", "12:00:00", "18:00:00") // null */ export declare function intervalUnionTime(aStart: string, aEnd: string, bStart: string, bEnd: string): { start: string; end: string; } | null;