# FreePeriodRule

Industry: Workforce

A free period of at least `minimum` consecutive rest inside every window: "30 consecutive hours off in every 168", "36 hours off containing two local nights", "one day in seven free, averaged over four weeks".

```ts
import type { FreePeriodRule } from "@northguild/gmt";
```

## Members

| Member | Type | Description |
| --- | --- | --- |
| `label` | `string` | The caller's name for the rule. The report is keyed by it; labels must be unique. |
| `severity?` | `"violation"` \| `"advisory"` ([`DutySeverity`](/gmt/reference/types/DutySeverity/)) | Whether a failure is a violation or an advisory. |
| `kind` | `"freePeriod"` | Selects this rule kind. |
| `restStatuses` | `S[]` | The statuses that are free time. |
| `minimum` | `string` | The shortest free period, a positive ISO 8601 duration of exact time. |
| `within` | [`Period`](/gmt/reference/types/Period/) | The window the free periods are counted in. |
| `containing?` | `object` ([`LocalWindow`](/gmt/reference/types/LocalWindow/)) | Local windows each free period must contain, such as nights from 22:00 to 08:00, read in the reference zone. Their edges resolve under the call's `disambiguation`. |
| `containing.window` | [`LocalWindow`](/gmt/reference/types/LocalWindow/) | The local window, as operating hours take it. |
| `containing.count` | `number` | How many whole windows each free period must contain, an integer from 1 to 10,000. |
| `atLeast?` | `number` | How many free periods the window must hold, a non-negative integer. |

## Definition

```ts
type FreePeriodRule<S extends string = string> = {
  /** The caller's name for the rule. The report is keyed by it; labels must be unique. */
  label: string;
  /**
   * Whether a failure is a violation or an advisory.
   *
   * @defaultValue `"violation"`.
   */
  severity?: DutySeverity;
  /** Selects this rule kind. */
  kind: "freePeriod";
  /** The statuses that are free time. */
  restStatuses: S[];
  /** The shortest free period, a positive ISO 8601 duration of exact time. */
  minimum: string;
  /** The window the free periods are counted in. */
  within: Period;
  /**
   * Local windows each free period must contain, such as nights from 22:00 to 08:00, read in the
   * reference zone. Their edges resolve under the call's `disambiguation`.
   *
   * @defaultValue None. Any run of `minimum` is a free period.
   */
  containing?: {
    /** The local window, as operating hours take it. */
    window: LocalWindow;
    /** How many whole windows each free period must contain, an integer from 1 to 10,000. */
    count: number;
  };
  /**
   * How many free periods the window must hold, a non-negative integer.
   *
   * @defaultValue `1`.
   */
  atLeast?: number;
};
```

## Used by

- [`dutyViolations`](/gmt/reference/workforce/calculate/dutyViolations/)
- [`evaluateDutyLog`](/gmt/reference/workforce/calculate/evaluateDutyLog/)

## Source

[types/duty.ts](https://github.com/northguild/gmt/blob/main/packages/gmt/src/types/duty.ts)
