UNPKG

@burglekitt/gmt

Version:

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

26 lines (25 loc) 1.58 kB
/** * Return the symmetric difference of two Unix intervals — time covered by exactly one interval. * * - Compares numeric Unix epoch values directly. * - Returns `[]` when intervals are identical or both invalid. * - Returns `[{ start, end }]` when one interval fully contains the other. * - Returns `[{ start, end }, { start, end }]` when intervals partially overlap. * - Returns `[]` if either interval is invalid (`start > end`). * - Returns `[]` on invalid input (non-numeric types, non-finite values). * * @param aStart Unix epoch value (seconds or milliseconds) — first interval start * @param aEnd Unix epoch value (seconds or milliseconds) — first interval end * @param bStart Unix epoch value (seconds or milliseconds) — second interval start * @param bEnd Unix epoch value (seconds or milliseconds) — second interval end * @returns array of `{ start, end }` records representing the symmetric difference, or `[]` on invalid input * * @example intervalXorUnix(0, 1500000000, 1400000000, 1700000000) // [{ start: 0, end: 1399999999 }, { start: 1500000001, end: 1700000000 }] * @example intervalXorUnix(0, 1700000000, 1400000000, 1500000000) // [{ start: 0, end: 1399999999 }, { start: 1500000001, end: 1700000000 }] * @example intervalXorUnix(0, 1700000000, 0, 1700000000) // [] * @example intervalXorUnix(NaN, 1500000000, 1400000000, 1700000000) // [] */ export declare function intervalXorUnix(aStart: number | string, aEnd: number | string, bStart: number | string, bEnd: number | string): Array<{ start: number; end: number; }>;