UNPKG

@burglekitt/gmt

Version:

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

23 lines (22 loc) 1.64 kB
/** * Return true when two datetime intervals are exactly adjacent — one's end equals the other's * start with zero gap and zero overlap. * * - Uses `Temporal.PlainDateTime.compare` for comparison. * - Returns `true` when `aEnd + 1 nanosecond === bStart` or `bEnd + 1 nanosecond === aStart`. * - Returns `false` when intervals overlap, are disjoint with a gap, or are invalid. * - Returns `false` on invalid input (wrong type, malformed strings). * * @param aStart ISO 8601 datetime string for the first interval start * @param aEnd ISO 8601 datetime string for the first interval end * @param bStart ISO 8601 datetime string for the second interval start * @param bEnd ISO 8601 datetime string for the second interval end * @returns true if intervals are exactly adjacent, or false on invalid input * * @example intervalAbutsDateTime("2024-01-01T09:00:00", "2024-06-30T12:00:00", "2024-06-30T12:00:00.000000001", "2024-12-31T17:00:00") // true * @example intervalAbutsDateTime("2024-06-30T12:00:00", "2024-12-31T17:00:00", "2024-01-01T09:00:00", "2024-06-30T12:00:00.000000001") // true * @example intervalAbutsDateTime("2024-01-01T09:00:00", "2024-06-30T12:00:00", "2024-06-30T12:00:01", "2024-12-31T17:00:00") // false (gap) * @example intervalAbutsDateTime("2024-01-01T09:00:00", "2024-06-30T13:00:00", "2024-06-30T12:00:00", "2024-12-31T17:00:00") // false (overlap) * @example intervalAbutsDateTime("invalid", "2024-06-30T12:00:00", "2024-06-30T12:00:00", "2024-12-31T17:00:00") // false */ export declare function intervalAbutsDateTime(aStart: string, aEnd: string, bStart: string, bEnd: string): boolean;