# intervalIntersectionTime

Industry: Core

## Signature

```ts
intervalIntersectionTime(aStart: string, aEnd: string, bStart: string, bEnd: string): { start: string; end: string; } | null
```

Return the overlapping span of two time intervals, or null when they do not overlap.

- Uses `Temporal.PlainTime.compare` for comparison.
- Half-open: an interval holds every `t` with `start <= t < end`. The intersection is `[max(aStart, bStart), min(aEnd, bEnd))` when `aStart < bEnd && bStart < aEnd` (CORE-6's `intersectIntervals`), otherwise `null`.
- Touching intervals (`aEnd === bStart`) share no clock time and return `null`.
- An empty interval (`start === end`) intersects only an interval it lies strictly inside, and then returns itself.
- Returns `null` if either interval is invalid (`start > end`).
- Returns `null` on invalid input (wrong type, malformed strings).

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `aStart` | `string` | ISO 8601 time string for the first interval start |
| `aEnd` | `string` | ISO 8601 time string for the first interval end |
| `bStart` | `string` | ISO 8601 time string for the second interval start |
| `bEnd` | `string` | ISO 8601 time string for the second interval end |

## Returns

`{ start, end }` with the overlapping span, or null on invalid input / no overlap

**Members**

| Member | Type | Description |
| --- | --- | --- |
| `start` | `string` | The clock time the interval begins at, as an ISO 8601 time string with no date, offset or time zone. |
| `end` | `string` | The first clock time after the interval, in the same format as `start`. It is exclusive: the interval holds everything from `start` up to but not including this value. It can equal `start`, which makes the interval empty. |

## Examples

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

intervalIntersectionTime("09:00:00", "17:00:00", "12:00:00", "18:00:00") // { start: "12:00:00", end: "17:00:00" }
```

## Source

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