# intervalUnionUnix

Industry: Core

## Signature

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

Return the combined span of two half-open Unix epoch intervals `[start, end)`, or null when their union is not one non-empty span.

- Compares numeric Unix epoch values directly.
- The result is the single run `mergeIntervalsUnix([a, b])` produces, the same rule as `mergeIntervals`. Overlapping intervals return their merged span.
- Touching intervals (e.g. `aEnd === bStart`) leave no gap between them and ARE merged.
- An empty interval (`start === end`) holds no instant, so it never changes the result: with a non-empty interval the answer is that interval, and two empty intervals give `null`.
- Returns `null` if either interval is invalid (`start > end`).
- Returns `null` on invalid input: non-numeric types, empty strings, and values that are not safe integers (fractions, `NaN`, `±Infinity`, beyond ±(2^53 − 1)).

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `aStart` | `string` \| `number` | Unix epoch value, in the one unit all epoch arguments share — first interval start |
| `aEnd` | `string` \| `number` | Unix epoch value, in the one unit all epoch arguments share — first interval end |
| `bStart` | `string` \| `number` | Unix epoch value, in the one unit all epoch arguments share — second interval start |
| `bEnd` | `string` \| `number` | Unix epoch value, in the one unit all epoch arguments share — second interval end |

## Returns

`{ start, end }` with the merged span, or null on invalid input / disjoint intervals

**Members**

| Member | Type | Description |
| --- | --- | --- |
| `start` | `number` | The instant the interval begins at, as a Unix epoch number in the unit the arguments share. |
| `end` | `number` | The first instant after the interval, in the same unit as `start`. It is exclusive: the interval holds everything from `start` up to but not including this value. It is always later than `start`. |

## Examples

```ts
import { intervalUnionUnix } from "@northguild/gmt/unix/interval";

intervalUnionUnix(0, 1700000000, 1000000, 2000000) // { start: 0, end: 1700000000 }
```

## Source

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