Skip to content

FreePeriodRule

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”.

import type { FreePeriodRule } from "@northguild/gmt";
MemberTypeDescription
labelstringThe caller’s name for the rule. The report is keyed by it; labels must be unique.
severity?"violation" | "advisory" (DutySeverity)Whether a failure is a violation or an advisory.
kind"freePeriod"Selects this rule kind.
restStatusesS[]The statuses that are free time.
minimumstringThe shortest free period, a positive ISO 8601 duration of exact time.
withinPeriodThe window the free periods are counted in.
containing?object (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.windowLocalWindowThe local window, as operating hours take it.
containing.countnumberHow many whole windows each free period must contain, an integer from 1 to 10,000.
atLeast?numberHow many free periods the window must hold, a non-negative integer.
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;
};

types/duty.ts