intervalOverlappingDaysUtc
Signature
Section titled “Signature”intervalOverlappingDaysUtc(aStart: string, aEnd: string, bStart: string, bEnd: string): number | nullReturn how many distinct UTC calendar dates two UTC intervals share.
- Half-open: an interval holds every
twithstart <= t < end. The count is the number of calendar days holding at least one instant of the intersection[max(aStart, bStart), min(aEnd, bEnd)). An intersection ending exactly at midnight does not reach that day. - Touching intervals (
aEnd === bStart) share no instant and count0; so does an empty interval. - Returns
0when the intervals share nothing (a well-defined answer, not invalid input). - Returns
nullif either interval is invalid (start > end). - Returns
nullon invalid input (wrong type, malformed strings, leap seconds).
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
aStart | string | ISO 8601 UTC datetime string for the first interval start |
aEnd | string | ISO 8601 UTC datetime string for the first interval end |
bStart | string | ISO 8601 UTC datetime string for the second interval start |
bEnd | string | ISO 8601 UTC datetime string for the second interval end |
Returns
Section titled “Returns”number of shared calendar dates, 0 when disjoint, or null on invalid input
Examples
Section titled “Examples”import { intervalOverlappingDaysUtc } from "@northguild/gmt/utc/interval";
intervalOverlappingDaysUtc("2024-01-01T23:59:00Z", "2024-01-02T00:01:00Z", "2024-01-01T23:59:00Z", "2024-01-02T00:01:00Z") // 2