UNPKG

@burglekitt/gmt

Version:

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

26 lines (25 loc) 1.2 kB
/** * Collapse a list of UTC intervals into the minimum set of non-overlapping intervals. * * - List-form generalization of `intervalUnionUtc`, which is pairwise only. * - Intervals are merged when they overlap or share an instant exactly (adjacent intervals * ARE merged). * - Order of the input list does not matter; the result is sorted by start. * - Returns `[]` for an empty list. * - Returns `[]` when `intervals` is not an array, when any element is not a * `{ start, end }` record of valid ISO UTC datetime strings, or when any element has * `start > end` or a leap-second string. * * @param intervals array of `{ start, end }` records * @returns the minimum set of non-overlapping `{ start, end }` records, sorted by start, or `[]` on invalid input * * @example mergeIntervalsUtc([{ start: "2024-01-01T00:00:00Z", end: "2024-01-10T00:00:00Z" }, { start: "2024-01-05T00:00:00Z", end: "2024-01-15T00:00:00Z" }]) // [{ start: "2024-01-01T00:00:00Z", end: "2024-01-15T00:00:00Z" }] * @example mergeIntervalsUtc([]) // [] */ export declare function mergeIntervalsUtc(intervals: Array<{ start: string; end: string; }>): Array<{ start: string; end: string; }>;