UNPKG

@burglekitt/gmt

Version:

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

26 lines (25 loc) 1.49 kB
/** * Return the combined span of two Unix epoch intervals, or null when they are disjoint. * * - Compares numeric Unix epoch values directly. * - 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 (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 `{ start, end }` with the merged span, or null on invalid input / disjoint intervals * * @example intervalUnionUnix(0, 1700000000, 1000000, 2000000) // { start: 0, end: 1700000000 } * @example intervalUnionUnix(0, 1000000, 1000000, 2000000) // { start: 0, end: 2000000 } * @example intervalUnionUnix(0, 1000000, 1000001, 2000000) // null * @example intervalUnionUnix(NaN, 1700000000, 1000000, 2000000) // null * @example intervalUnionUnix("0", "1700000000", "1000000", "2000000") // { start: 0, end: 1700000000 } */ export declare function intervalUnionUnix(aStart: number | string, aEnd: number | string, bStart: number | string, bEnd: number | string): { start: number; end: number; } | null;