# qualifyingRests

Industry: Workforce

## Signature

```ts
qualifyingRests(log: DutyEntry[], spec: { statuses: string[]; minimum: string; }): Interval[]
```

Return every rest of at least `minimum` in a duty log: the runs of touching entries in any of `spec.statuses` that last that long.

- A run is ended by another status or an unlogged gap, never by a change between two of `statuses`: an off period running straight into a sleeper-berth period is one rest.
- The whole log is read. Intervals are UTC instants ending in "Z", in log order.
- For two shorter rests that count together, use `qualifyingRestPairs`.
- `[]` is both a legitimate result and the sentinel: returned when the log fails `isValidDutyLog`, when `spec` is not an object, when `statuses` is not an array of strings, and when `minimum` is not a positive ISO 8601 duration of exact time.

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| `log` | `DutyEntry[]` | the duty log, ordered and non-overlapping |

## Options

**spec**

the statuses a rest is made of and the shortest that counts

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `statuses` | `string[]` | Required | The statuses a rest is made of. Touching entries in any of them are one rest. |
| `minimum` | `string` | Required | The shortest rest returned, a positive ISO 8601 duration of exact time (`"PT10H"`). |

## Returns

the rests' `{ start, end }` records, or [] on invalid input

## Related types

- [`DutyEntry`](/gmt/reference/types/DutyEntry/)
- [`Interval`](/gmt/reference/types/Interval/)

## Examples

```ts
import { qualifyingRests } from "@northguild/gmt/workforce/calculate";

qualifyingRests([{ status: "off", start: "2024-01-01T00:00:00Z", end: "2024-01-01T10:00:00Z" }, { status: "work", start: "2024-01-01T10:00:00Z", end: "2024-01-01T16:00:00Z" }, { status: "off", start: "2024-01-01T16:00:00Z", end: "2024-01-01T23:00:00Z" }], { statuses: ["off"], minimum: "PT10H" }) // [{ start: "2024-01-01T00:00:00Z", end: "2024-01-01T10:00:00Z" }]
```

## Source

[workforce/calculate/qualifyingRests.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/workforce/calculate/qualifyingRests.ts)
