@burglekitt/gmt
Version:
Temporal-based date and time utilities with timezone support and polyfill integration
26 lines (25 loc) • 1.47 kB
TypeScript
/**
* Return the portion(s) of interval A not covered by interval B.
*
* - Uses `Temporal.PlainTime.compare` for comparison.
* - Returns `[]` when B fully covers A.
* - Returns `[{ start, end }]` when B overlaps one edge of A (or equals A).
* - Returns `[{ start, end }, { start, end }]` when B is fully inside A with gaps on both sides.
* - Returns `[]` if either interval is invalid (`start > end`).
* - Returns `[]` 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 array of `{ start, end }` records representing A minus B, or `[]` on invalid input
*
* @example intervalDifferenceTime("09:00:00", "17:00:00", "12:00:00", "13:00:00") // [{ start: "09:00:00", end: "11:59:59" }, { start: "13:00:01", end: "17:00:00" }]
* @example intervalDifferenceTime("09:00:00", "17:00:00", "09:00:00", "17:00:00") // []
* @example intervalDifferenceTime("09:00:00", "17:00:00", "12:00:00", "17:00:00") // [{ start: "09:00:00", end: "11:59:59" }]
* @example intervalDifferenceTime("invalid", "17:00:00", "12:00:00", "13:00:00") // []
*/
export declare function intervalDifferenceTime(aStart: string, aEnd: string, bStart: string, bEnd: string): Array<{
start: string;
end: string;
}>;