# intervalXorUnix

Industry: Core

## Signature

```ts
intervalXorUnix(aStart: string | number, aEnd: string | number, bStart: string | number, bEnd: string | number): { start: number; end: number; }[]
```

Return the symmetric difference of two half-open Unix intervals `[start, end)` — the values covered by exactly one interval.

- Compares numeric Unix epoch values directly.
- The result is every maximal run covered by exactly one interval, sorted by start — the same as `mergeIntervals` of `subtractIntervals(a, [b])` and `subtractIntervals(b, [a])`, and the same as `intervalXorAllUnix([a, b])`.
- Every boundary is an input's own `start` or `end`; no boundary is stepped by an epoch unit.
- Touching intervals share no value, so they join into one run (`[0, 5)` xor `[5, 10)` is `[0, 10)`). An empty interval (`start === end`) holds no value and changes nothing.
- Returns `[]` when the intervals are identical.
- Returns `[{ start, end }]` when the intervals share a start or an end, or touch.
- Returns `[{ start, end }, { start, end }]` when they partially overlap, when one strictly contains the other, or when they are disjoint with a gap.
- Returns `[]` if either interval is invalid (`start > end`).
- Returns `[]` 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

array of `{ start, end }` records representing the symmetric difference, or `[]` on invalid input

**Members of each item**

| 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 { intervalXorUnix } from "@northguild/gmt/unix/interval";

intervalXorUnix(0, 1500000000, 1400000000, 1700000000) // [{ start: 0, end: 1400000000 }, { start: 1500000000, end: 1700000000 }]
```

## Source

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