# intervalOverlappingDaysDate

Industry: Core

## Signature

```ts
intervalOverlappingDaysDate(aStart: string, aEnd: string, bStart: string, bEnd: string): number | null
```

Return how many distinct calendar dates two date intervals share.

- Half-open: an interval holds every date `d` with `start <= d < end`. The count is the number of days in the intersection `[max(aStart, bStart), min(aEnd, bEnd))`, that is `min(aEnd, bEnd) - max(aStart, bStart)` in days.
- Touching intervals (`aEnd === bStart`) share no day and count `0`; so does an empty interval.
- Returns `0` when the intervals share no day (a well-defined answer, not invalid input).
- Returns `null` if either interval is invalid (`start > end`).
- Returns `null` on invalid input (wrong type, malformed strings).
- Accepts RFC 9557 calendar-annotated PlainDate strings — E5 (issue #78). All four arguments must name the same calendar (a bare ISO string names `iso8601`); different calendars return `null`, as Temporal's `until` throws when `CalendarEquals` is false.
- Compatibility: before 1.16.0 arguments could name different calendars. Since 1.16.0 calendar strings are RFC 9557 (ISO digits, `[u-ca=<id>]`, canonical calendar ids); see `isValidCalendarDate`.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `aStart` | `string` | ISO 8601 date string for the first interval start, optionally calendar-annotated |
| `aEnd` | `string` | ISO 8601 date string for the first interval end, optionally calendar-annotated |
| `bStart` | `string` | ISO 8601 date string for the second interval start, optionally calendar-annotated |
| `bEnd` | `string` | ISO 8601 date string for the second interval end, optionally calendar-annotated |

## Returns

number of shared calendar dates, `0` when disjoint, or null on invalid input

## Examples

```ts
import { intervalOverlappingDaysDate } from "@northguild/gmt/plain/interval";

intervalOverlappingDaysDate("2024-01-01", "2024-06-30", "2024-04-01", "2024-12-31") // 90 (04-01 up to, not including, 06-30)
```

## Source

[plain/interval/intervalOverlappingDaysDate.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/plain/interval/intervalOverlappingDaysDate.ts)
