IF Commons GitHub

governance/time

Written to: 1 requirement: 0 proved, 0 partly, 0 failing, 1 with no test recorded. 0002-planning-core FR-003

The time of an event and the day a deferral ends, as branded text made only by a parser: an instant is YYYY-MM-DDTHH:MM:SSZ in UTC to the second (0037-planning FR-003) and a day is YYYY-MM-DD; each is a real date, and each sorts as text in the order of time. Nothing here reads a clock: a time is a value the caller passes in (FR-022).

import { parseInstant } from "./time.ts";
parseInstant("2026-11-21T10:00:00Z"); // { kind: "ok", value: "2026-11-21T10:00:00Z" }
parseInstant("2026-02-30T10:00:00Z"); // { kind: "err", error: ... }

Source: commons/planning/src/governance/time.ts

0 of 14 exports are imported by a test of the run. A test that imports an export may not call it or check what it returns.

governance.Instanttypeno test imports it
type Instant = Brand<string, "plan instant">;

A time in UTC to the second, YYYY-MM-DDTHH:MM:SSZ. Made only by parseInstant or instantOfMs.

governance.Daytypeno test imports it
type Day = Brand<string, "plan day">;

A calendar day, YYYY-MM-DD. Made only by parseDay.

governance.TimeProblemtypeno test imports it
type TimeProblem = { readonly kind: "bad-time"; readonly text: string; readonly expected: string };

A text that is not an instant or a day.

governance.parseInstantfunctionno test imports it
function parseInstant(text: string): Result<Instant, TimeProblem>

An instant from text, or why it is not one: the form, and a date that exists.

governance.instantOfMsfunctionno test imports it
function instantOfMs(ms: number): Result<Instant, TimeProblem>

The instant of a time in milliseconds since 1970, cut to the second.

governance.msOfInstantfunctionno test imports it
function msOfInstant(instant: Instant): number

The milliseconds since 1970 of an instant.

governance.parseDayfunctionno test imports it
function parseDay(text: string): Result<Day, TimeProblem>

A day from text, or why it is not one.

Instanttypeno test imports it
type Instant = Brand<string, "plan instant">;

A time in UTC to the second, YYYY-MM-DDTHH:MM:SSZ. Made only by parseInstant or instantOfMs.

Daytypeno test imports it
type Day = Brand<string, "plan day">;

A calendar day, YYYY-MM-DD. Made only by parseDay.

TimeProblemtypeno test imports it
type TimeProblem = { readonly kind: "bad-time"; readonly text: string; readonly expected: string };

A text that is not an instant or a day.

parseInstantfunctionno test imports it
function parseInstant(text: string): Result<Instant, TimeProblem>

An instant from text, or why it is not one: the form, and a date that exists.

instantOfMsfunctionno test imports it
function instantOfMs(ms: number): Result<Instant, TimeProblem>

The instant of a time in milliseconds since 1970, cut to the second.

msOfInstantfunctionno test imports it
function msOfInstant(instant: Instant): number

The milliseconds since 1970 of an instant.

parseDayfunctionno test imports it
function parseDay(text: string): Result<Day, TimeProblem>

A day from text, or why it is not one.

Titles, headings, exports, tables, columns and requirements. Esc closes.