UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

27 lines • 1.25 kB
/** A `DutyEntry` parsed once: its status and its bounds as epoch nanoseconds. */ export type DutyLogEntry = { status: string; start: bigint; end: bigint; }; /** A maximal stretch of touching entries in a set of statuses, `[start, end)`. */ export type DutyRun = { start: bigint; end: bigint; }; /** * Parse a candidate duty log, all-or-nothing. * * - An entry is any object whose `status` is a string and whose `start` and `end` are ISO 8601 * instant strings with `start` before `end`; extra keys are ignored (GMT rule: the type is * structural). Each field is read once. * - Entries must be ordered by `start` and must not overlap: one may start where the previous * ends (half-open), or later. * * @param value candidate array of `{ status, start, end }` records * @returns the parsed entries in order, or null when `value` is not a valid duty log * * @example parseDutyLog([{ status: "off", start: "1970-01-01T00:00:00Z", end: "1970-01-01T00:00:00.000000002Z" }]) // [{ status: "off", start: 0n, end: 2n }] * @example parseDutyLog([{ status: "off", start: "1970-01-01T00:00:00Z", end: "1970-01-01T00:00:00Z" }]) // null — zero length */ export declare function parseDutyLog(value: unknown): DutyLogEntry[] | null;