diff --git a/.changeset/aviation-ssim-dates.md b/.changeset/aviation-ssim-dates.md
new file mode 100644
index 000000000..bf2af66c8
--- /dev/null
+++ b/.changeset/aviation-ssim-dates.md
@@ -0,0 +1,27 @@
+---
+"@northguild/gmt": minor
+---
+
+A new `aviation` area reads and writes the date in IATA SSIM airline schedule files. An SSIM date has seven characters, `DDMMMYY`, such as `01JAN26`. It is not ISO 8601, so `Temporal` cannot read it. The functions are in `@northguild/gmt/aviation`, and in `@northguild/gmt/aviation/parse`, `@northguild/gmt/aviation/format` and `@northguild/gmt/aviation/validate`.
+
+- `parseSsimDate(value, options)` reads an SSIM date and returns an ISO date.
+- `formatSsimDate(value, options)` writes an ISO date as an SSIM date.
+- `isValidSsimDate(value, options)` is `true` exactly when `parseSsimDate` would return a date.
+
+```typescript
+import {
+ formatSsimDate,
+ isValidSsimDate,
+ parseSsimDate,
+} from "@northguild/gmt/aviation";
+
+parseSsimDate("01JAN26", { yearWindow: 2000 }); // "2026-01-01"
+formatSsimDate("2026-10-25", { yearWindow: 2000 }); // "25OCT26"
+isValidSsimDate("31FEB26", { yearWindow: 2000 }); // false
+```
+
+Three rules apply to all three functions:
+
+- **The month is a fixed English code.** It is one of `JAN` to `DEC`, in upper case, and it is never read through the platform's language. The result is the same on every machine. `01jan26`, `01ENE26` and `01JANV26` are not read.
+- **You state the century.** A two-digit year has no century of its own, so `options.yearWindow` is required: a first year such as `2000`, or `"rolling"`. There is no default. Without it, the parser and the formatter return `""` and the validator returns `false`.
+- **A date that does not exist is refused.** `29FEB25` and `31APR26` return `""`. `formatSsimDate` also returns `""` for a year outside the window, because written as two digits it would be read back as another century.
diff --git a/README.md b/README.md
index f0e10e6fd..01f719170 100644
--- a/README.md
+++ b/README.md
@@ -53,7 +53,7 @@ addZoned("2024-03-30T12:00:00+01:00[Europe/Berlin]", { hours: 24 }); // "2024-03
resolveLocal("2024-03-31T02:30:00", "Europe/Berlin", { disambiguation: "reject" }); // ""
```
-- **748 functions, to the nanosecond**, tested in 17 locales.
+- **751 functions, to the nanosecond**, tested in 17 locales.
- **Never throws.** ISO 8601 strings in. Invalid input returns `""`, `null`, `false` or `[]`.
The latest test counts, CI volume and the comparison with Luxon, date-fns, Moment.js, Day.js, Spacetime and `@internationalized/date` are on the [Why GMT](https://northguild.dev/gmt/why-gmt/) page. The full comparison and the method are on the [compare](https://northguild.dev/gmt/compare/) page.
@@ -79,9 +79,9 @@ convertUtcToZoned("2024-06-15T12:00:00Z", "Asia/Tokyo"); // "2024-06-15T21:00:00
```
Every function has a reference page with a live playground:
-[plain](https://northguild.dev/gmt/reference/plain/) · [zoned](https://northguild.dev/gmt/reference/zoned/) · [utc](https://northguild.dev/gmt/reference/utc/) · [unix](https://northguild.dev/gmt/reference/unix/) · [instant](https://northguild.dev/gmt/reference/instant/) · [calendar](https://northguild.dev/gmt/reference/calendar/) · [duration](https://northguild.dev/gmt/reference/duration/) · [interval](https://northguild.dev/gmt/reference/interval/) · [workforce](https://northguild.dev/gmt/reference/workforce/) · [span](https://northguild.dev/gmt/reference/span/) · [precision](https://northguild.dev/gmt/reference/precision/) · [recurrence](https://northguild.dev/gmt/reference/recurrence/) · [timescale](https://northguild.dev/gmt/reference/timescale/) · [gnss](https://northguild.dev/gmt/reference/gnss/) · [transport](https://northguild.dev/gmt/reference/transport/) · [intermodal](https://northguild.dev/gmt/reference/intermodal/) · [finance](https://northguild.dev/gmt/reference/finance/) · [healthcare](https://northguild.dev/gmt/reference/healthcare/)
+[plain](https://northguild.dev/gmt/reference/plain/) · [zoned](https://northguild.dev/gmt/reference/zoned/) · [utc](https://northguild.dev/gmt/reference/utc/) · [unix](https://northguild.dev/gmt/reference/unix/) · [instant](https://northguild.dev/gmt/reference/instant/) · [calendar](https://northguild.dev/gmt/reference/calendar/) · [duration](https://northguild.dev/gmt/reference/duration/) · [interval](https://northguild.dev/gmt/reference/interval/) · [workforce](https://northguild.dev/gmt/reference/workforce/) · [span](https://northguild.dev/gmt/reference/span/) · [precision](https://northguild.dev/gmt/reference/precision/) · [recurrence](https://northguild.dev/gmt/reference/recurrence/) · [timescale](https://northguild.dev/gmt/reference/timescale/) · [gnss](https://northguild.dev/gmt/reference/gnss/) · [transport](https://northguild.dev/gmt/reference/transport/) · [intermodal](https://northguild.dev/gmt/reference/intermodal/) · [finance](https://northguild.dev/gmt/reference/finance/) · [healthcare](https://northguild.dev/gmt/reference/healthcare/) · [aviation](https://northguild.dev/gmt/reference/aviation/)
-By industry: [Workforce](https://northguild.dev/gmt/industries/workforce/) · [Transport](https://northguild.dev/gmt/industries/transport/) · [Intermodal](https://northguild.dev/gmt/industries/intermodal/) · [GNSS](https://northguild.dev/gmt/industries/gnss/) · [Maritime](https://northguild.dev/gmt/industries/maritime/) · [Finance](https://northguild.dev/gmt/industries/finance/) · [Healthcare](https://northguild.dev/gmt/industries/healthcare/)
+By industry: [Workforce](https://northguild.dev/gmt/industries/workforce/) · [Transport](https://northguild.dev/gmt/industries/transport/) · [Intermodal](https://northguild.dev/gmt/industries/intermodal/) · [GNSS](https://northguild.dev/gmt/industries/gnss/) · [Maritime](https://northguild.dev/gmt/industries/maritime/) · [Finance](https://northguild.dev/gmt/industries/finance/) · [Healthcare](https://northguild.dev/gmt/industries/healthcare/) · [Aviation](https://northguild.dev/gmt/industries/aviation/)
Then the [guides](https://northguild.dev/gmt/guides/) show how to do each job, and the [tools](https://northguild.dev/gmt/tools/) let you try it on your own values.
diff --git a/apps/dox/scripts/contrast-measure.mjs b/apps/dox/scripts/contrast-measure.mjs
index eb53be2a4..dbef5a087 100644
--- a/apps/dox/scripts/contrast-measure.mjs
+++ b/apps/dox/scripts/contrast-measure.mjs
@@ -127,6 +127,7 @@ const ALL_PAGES = [
{ id: "dox-chat", path: "/dox/" },
{ id: "dox-chat+timetable", path: "/dox/", open: "showTimetableReader" },
{ id: "dox-chat+x12", path: "/dox/", open: "showX12TimeReader" },
+ { id: "dox-chat+ssim", path: "/dox/", open: "showSsimDateReader" },
{
id: "check:canada-2026-clock-change",
path: "/check/canada-2026-clock-change/",
diff --git a/apps/dox/scripts/grow-measure.mjs b/apps/dox/scripts/grow-measure.mjs
index eb06d58f8..b46fa877a 100644
--- a/apps/dox/scripts/grow-measure.mjs
+++ b/apps/dox/scripts/grow-measure.mjs
@@ -278,6 +278,11 @@ const PAGES = [
preset: PRESET,
drag: null,
},
+ {
+ slug: "ssim-date-reader",
+ preset: PRESET,
+ drag: null,
+ },
{
slug: "holiday-rule-builder",
preset: PRESET,
diff --git a/apps/dox/scripts/html-diff.mjs b/apps/dox/scripts/html-diff.mjs
index c9f6af140..df2fdbabf 100644
--- a/apps/dox/scripts/html-diff.mjs
+++ b/apps/dox/scripts/html-diff.mjs
@@ -182,6 +182,10 @@ const PAGES = [
path: "tools/fix-timestamp-reader",
widget: "fix-timestamp-reader",
},
+ {
+ path: "tools/ssim-date-reader",
+ widget: "ssim-date-reader",
+ },
{
path: "tools/holiday-rule-builder",
widget: "holiday-rule-builder",
diff --git a/apps/dox/scripts/readout-still.mjs b/apps/dox/scripts/readout-still.mjs
index 4e9091958..e8c63356c 100644
--- a/apps/dox/scripts/readout-still.mjs
+++ b/apps/dox/scripts/readout-still.mjs
@@ -3,9 +3,9 @@
* Readouts-hold-still gate (context/dox/reference/visual-design.md, "Layout stability",
* and the Timetable Reader's rules in context/dox/built.md).
*
- * Dragging a handle must move nothing except the values themselves. For each of
- * the seven tool pages (Departure Board, Punctuality Board, ETA Drift Chart,
- * Timetable Reader, Free Time Ledger, Dwell Ledger, B/L Date Stamp), every
+ * Dragging a handle must move nothing except the values themselves. For each
+ * tool page in `TOOLS` (the table below lists the handles of the first seven; a later
+ * entry names its own controls), every
* preset, and each of these widths, the script takes every control the reader
* drags:
*
diff --git a/apps/dox/scripts/visual-snapshot.mjs b/apps/dox/scripts/visual-snapshot.mjs
index de5189105..e32b97526 100644
--- a/apps/dox/scripts/visual-snapshot.mjs
+++ b/apps/dox/scripts/visual-snapshot.mjs
@@ -157,6 +157,7 @@ const PAGES = [
{ slug: "tool-stored-time-audit", path: "/tools/stored-time-audit/" },
{ slug: "tool-tai64n-log-reader", path: "/tools/tai64n-log-reader/" },
{ slug: "tool-fix-timestamp-reader", path: "/tools/fix-timestamp-reader/" },
+ { slug: "tool-ssim-date-reader", path: "/tools/ssim-date-reader/" },
{ slug: "tool-holiday-rule-builder", path: "/tools/holiday-rule-builder/" },
{
slug: "tool-observance-comparator",
diff --git a/apps/dox/src/components/SsimDateReader.astro b/apps/dox/src/components/SsimDateReader.astro
new file mode 100644
index 000000000..0370d8454
--- /dev/null
+++ b/apps/dox/src/components/SsimDateReader.astro
@@ -0,0 +1,45 @@
+---
+/**
+ * SSIM Date Reader widget (AV-97).
+ *
+ * An IATA SSIM date (`01JAN26`) read in a window the reader states, beside the locale pattern
+ * parser it is not, and an ISO date written back.
+ *
+ * **The markup and the wiring both live in `lib/ssim-date-reader-mount.ts`**, so the chat rail
+ * mounts the same widget this page server-renders.
+ */
+import { renderSsimDateReaderTemplate } from "../lib/ssim-date-reader-mount";
+
+/** `fullbleed` lets the page use the whole main pane (see ObservanceComparator). */
+interface Props {
+ fullbleed?: boolean;
+}
+
+const { fullbleed = false } = Astro.props;
+const html = renderSsimDateReaderTemplate("ssim-date-reader", {}).value;
+---
+
+{
+ fullbleed ? (
+
+ ) : (
+
+ )
+}
+
+
diff --git a/apps/dox/src/components/ask/widget-graph.test.ts b/apps/dox/src/components/ask/widget-graph.test.ts
index 8803bcbda..a9bc43956 100644
--- a/apps/dox/src/components/ask/widget-graph.test.ts
+++ b/apps/dox/src/components/ask/widget-graph.test.ts
@@ -179,6 +179,8 @@ describe("the chat island's static import graph", () => {
"lib/finance-lib.ts",
"lib/fix-picture.ts",
"lib/fix-timestamp-reader.ts",
+ "lib/aviation-lib.ts",
+ "lib/ssim-date-reader.ts",
"lib/tai64n-presets.ts",
"lib/tai64n-lib.ts",
"lib/holiday-widgets.ts",
diff --git a/apps/dox/src/components/ask/widget-registry.ts b/apps/dox/src/components/ask/widget-registry.ts
index 2179d0225..efceaa1ba 100644
--- a/apps/dox/src/components/ask/widget-registry.ts
+++ b/apps/dox/src/components/ask/widget-registry.ts
@@ -86,6 +86,7 @@ import type { LeapDayArgs } from "~/lib/leap-day-birthday-mount";
import type { StoredTimeAuditArgs } from "~/lib/stored-time-audit-mount";
import type { Tai64nLogReaderArgs } from "~/lib/tai64n-log-reader-mount";
import type { FixTimestampReaderArgs } from "~/lib/fix-timestamp-reader-mount";
+import type { SsimDateReaderArgs } from "~/lib/ssim-date-reader-mount";
import type { HolidayRuleBuilderArgs } from "~/lib/holiday-rule-builder-mount";
import type { ObservanceComparatorArgs } from "~/lib/observance-comparator-mount";
import type { MovingFeastsArgs } from "~/lib/moving-feasts-mount";
@@ -128,6 +129,7 @@ import {
showDatabaseTimestampReaderInput,
showTai64nLogReaderInput,
showFixTimestampReaderInput,
+ showSsimDateReaderInput,
showTerrestrialTimeStackInput,
showDwellLedgerInput,
showEtaDriftInput,
@@ -969,6 +971,37 @@ const fixTimestampEntry = defineWidget({
})),
});
+const ssimEntry = defineWidget({
+ title: "SSIM Date Reader",
+ kind: "ssim",
+ parse: (input) => {
+ const result = showSsimDateReaderInput.safeParse(input);
+ if (!result.success) {
+ return {
+ ok: false,
+ reason: "The widget was asked for with arguments that don't fit.",
+ };
+ }
+ const { value, yearWindow, locale, date } = result.data;
+ return {
+ ok: true,
+ args: {
+ ...(value === undefined ? {} : { value }),
+ ...(yearWindow === undefined ? {} : { window: String(yearWindow) }),
+ ...(locale === undefined ? {} : { locale }),
+ ...(date === undefined ? {} : { date }),
+ },
+ };
+ },
+ /* No `validate`: a date the library does not read is this widget's own NO SIGNAL state, and a call with no window opens with the window blank. */
+ load: () =>
+ import("~/lib/ssim-date-reader-mount").then((m) => ({
+ renderTemplate: (idPrefix, args) =>
+ m.renderSsimDateReaderTemplate(idPrefix, args),
+ mount: m.mountSsimDateReader,
+ })),
+});
+
const ttStackEntry = defineWidget({
title: "Terrestrial Time Stack",
kind: "ttstack",
@@ -1385,6 +1418,7 @@ export const WIDGET_REGISTRY: Record = {
showDatabaseTimestampReader: databaseReaderEntry,
showTai64nLogReader: tai64nEntry,
showFixTimestampReader: fixTimestampEntry,
+ showSsimDateReader: ssimEntry,
showTerrestrialTimeStack: ttStackEntry,
};
diff --git a/apps/dox/src/content/docs/guides/index.mdx b/apps/dox/src/content/docs/guides/index.mdx
index 5b3cc2c6f..239266150 100644
--- a/apps/dox/src/content/docs/guides/index.mdx
+++ b/apps/dox/src/content/docs/guides/index.mdx
@@ -20,7 +20,7 @@ same patterns to coding agents.
| [Conversion](./conversion/) | Between plain/zoned/unix/UTC and calendar systems, foreign epochs (NTP, FILETIME, Excel, PostgreSQL), time-ordered IDs, [database timestamps](./conversion/databases/) (PostgreSQL, MySQL, SQL Server, Oracle, SQLite, MongoDB, DynamoDB, Redis, Couchbase, Cassandra, ScyllaDB, Neo4j), Parquet, Arrow, protobuf |
| [Intervals](./intervals/interval-basics/) | Range math — containment, overlap, set operations, splitting, [hours of work](./industries/workforce-hours-of-work/) |
| [Integration](./integration/) | Cache keys, routers, tables, lint config |
-| [Industries](./industries/) | The industry layers on top of the core — transport legs and dwell, cut-offs, multi-leg scheduling, punctuality and timestamp classes, free time and demurrage, billing deadlines, bill of lading dates and multimodal ETAs, EDI timestamps, HL7 clinical timestamps — with real-world scenarios |
+| [Industries](./industries/) | The industry layers on top of the core — transport legs and dwell, cut-offs, multi-leg scheduling, punctuality and timestamp classes, free time and demurrage, billing deadlines, bill of lading dates and multimodal ETAs, EDI timestamps, HL7 clinical timestamps, SSIM schedule dates — with real-world scenarios |
| [How-to](./how-to/) | Short answers to common tasks — add business days, convert between time zones, check whether a local time exists on a DST day |
## Reading order
diff --git a/apps/dox/src/content/docs/guides/industries/aviation-message-times.mdx b/apps/dox/src/content/docs/guides/industries/aviation-message-times.mdx
new file mode 100644
index 000000000..c85094ba2
--- /dev/null
+++ b/apps/dox/src/content/docs/guides/industries/aviation-message-times.mdx
@@ -0,0 +1,215 @@
+---
+title: "Aviation: Message Times"
+description: parseSsimDate, formatSsimDate and isValidSsimDate — read, write and check the SSIM schedule date, with English month letters that ignore the platform's language and a century the caller states.
+sidebar:
+ order: 12
+industries: [aviation]
+---
+
+Airlines and airports exchange schedules in the files and messages of IATA's Standard Schedules
+Information Manual, SSIM. Their dates are not ISO 8601. An SSIM date is written `01JAN26`: two
+digits of day, three letters of month and two digits of year. Nothing in it says which century
+the year is in, and the month is a code, not a word in any language.
+
+The functions here read and write that date and check it. They never read the platform's
+language, and they never choose a century for you.
+
+```typescript
+import { parseSsimDate } from "@northguild/gmt/aviation/parse";
+import { formatSsimDate } from "@northguild/gmt/aviation/format";
+import { isValidSsimDate } from "@northguild/gmt/aviation/validate";
+```
+
+The functions live in `@northguild/gmt/aviation/parse`, `@northguild/gmt/aviation/format` and
+`@northguild/gmt/aviation/validate`. They use only Core: a date check from
+[`plain/`](/reference/plain/) and the library's two-digit-year window.
+
+## The SSIM date form
+
+The form is day, month letters, year: `01JAN26`. EUROCONTROL's CSST guide shows it in a schedule
+file, in the carrier record, the second record of the file. Its period of schedule validity
+runs from `05APR10` to `11APR10`, and a third date, `16DEC09`, follows (the figure does not
+label it). The three are written together as `05APR1011APR1016DEC09`. The month letters are the
+first three letters of the English month name in upper case: `JAN`, `FEB`, `MAR`, `APR`, `MAY`,
+`JUN`, `JUL`, `AUG`, `SEP`, `OCT`, `NOV`, `DEC`.
+
+[`parseSsimDate(value, options)`](/reference/aviation/parse/parseSsimDate/) returns an ISO date.
+It returns `""` for anything that is not a valid SSIM date.
+
+```typescript
+import { parseSsimDate } from "@northguild/gmt/aviation/parse";
+
+parseSsimDate("01JAN26", { yearWindow: 2000 });
+// "2026-01-01"
+parseSsimDate("05APR10", { yearWindow: 2000 });
+// "2010-04-05"
+parseSsimDate("16DEC09", { yearWindow: 1950 });
+// "2009-12-16"
+parseSsimDate("29FEB25", { yearWindow: 2000 });
+// "" (no 29 February in 2025)
+parseSsimDate("31APR26", { yearWindow: 2000 });
+// "" (no 31 April)
+parseSsimDate("00XXX00", { yearWindow: 2000 });
+// "" (XXX is not a month)
+```
+
+Slot messages write the day and month with no year (`01APR`), as ACL's introductory guide shows.
+This layer does not read that form, because a date with no year needs a season to anchor it.
+
+## Why the month letters bypass the locale
+
+The letters are a code. `JAN` is the code for January in every file, whatever language the
+machine reading it uses. A pattern parser that is given the platform's language breaks on this
+in both directions. On a machine set to Spanish it rejects `JAN` and accepts `ENE`, which the
+format never writes. Other languages want their own words, such as `JANV.` with its full stop.
+And it accepts lower case, `jan`, which the format never writes either.
+
+`parseSsimDate` reads the letters from a constant table. The platform's language is never read,
+so the answer is the same on every machine.
+
+```typescript
+import { parseSsimDate } from "@northguild/gmt/aviation/parse";
+
+parseSsimDate("01JAN26", { yearWindow: 2000 });
+// "2026-01-01" (on every machine)
+parseSsimDate("01ENE26", { yearWindow: 2000 });
+// "" (Spanish for January; not an SSIM month)
+parseSsimDate("01JANV26", { yearWindow: 2000 });
+// "" (letters from another language)
+parseSsimDate("01jan26", { yearWindow: 2000 });
+// "" (lower case)
+parseSsimDate("01Jan26", { yearWindow: 2000 });
+// "" (mixed case)
+```
+
+Upper case only is deliberate. A reader that accepts `jan` invites a writer that emits it, and
+folding case can change a letter: `"ſEP".toUpperCase() === "SEP"` maps another letter onto a
+month code, and `"i".toLocaleUpperCase("tr") === "İ"` depends on the locale.
+
+## The window
+
+A two-digit year does not say which century it is in. `parseSsimDate` takes the hundred-year
+window you state in `yearWindow`, and returns `""` without one. There are two ways to state it.
+
+A fixed first year suits an archive, because the same file then reads the same way in any year.
+`yearWindow: 2000` places `YY` in 2000 to 2099, and `yearWindow: 1950` places it in 1950 to
+2049.
+
+```typescript
+import { parseSsimDate } from "@northguild/gmt/aviation/parse";
+
+parseSsimDate("01JAN26", { yearWindow: 2000 });
+// "2026-01-01"
+parseSsimDate("01JAN26", { yearWindow: 1900 });
+// "1926-01-01"
+parseSsimDate("01JAN70", { yearWindow: 1970 });
+// "1970-01-01"
+parseSsimDate("01JAN70", { yearWindow: 1971 });
+// "2070-01-01"
+```
+
+`"rolling"` suits a live feed. The window moves with the current UTC year, so a date near today
+is read as near today.
+
+```typescript
+import { parseSsimDate } from "@northguild/gmt/aviation/parse";
+
+parseSsimDate("01JAN26", { yearWindow: "rolling" });
+// "2026-01-01" (while the current UTC year is 1977 to 2076)
+parseSsimDate("01JAN26", {});
+// "" (no window stated)
+```
+
+The window also settles whether a day exists. `29FEB00` is a date from 2000, which was a leap
+year, and nothing from 1900, which was not:
+
+```typescript
+import { parseSsimDate } from "@northguild/gmt/aviation/parse";
+
+parseSsimDate("29FEB00", { yearWindow: 2000 });
+// "2000-02-29"
+parseSsimDate("29FEB00", { yearWindow: 1900 });
+// ""
+```
+
+The library holds no cut-off year of its own. Any fixed pivot is right for the files of one
+period and wrong for the others, and it would change its answer on the day it was passed. The
+century is a fact about your files, so you state it.
+
+## Writing a date back
+
+[`formatSsimDate(value, options)`](/reference/aviation/format/formatSsimDate/) writes an ISO date
+as an SSIM date, with upper-case letters. It takes the same window, and it returns `""` for a
+year outside it, because the two digits it would write would read back as another year.
+
+```typescript
+import { formatSsimDate } from "@northguild/gmt/aviation/format";
+
+formatSsimDate("2026-01-01", { yearWindow: 2000 });
+// "01JAN26"
+formatSsimDate("2000-02-29", { yearWindow: 2000 });
+// "29FEB00"
+formatSsimDate("2026-01-01", { yearWindow: 1900 });
+// "" (2026 is outside 1900 to 1999)
+formatSsimDate("2100-01-01", { yearWindow: 2000 });
+// "" (2100 is outside 2000 to 2099)
+formatSsimDate("2026-01-01", {});
+// "" (no window stated)
+```
+
+A round trip never changes a century. Whatever the formatter writes, the parser reads back to the
+same date in the same window:
+
+```typescript
+import { formatSsimDate } from "@northguild/gmt/aviation/format";
+import { parseSsimDate } from "@northguild/gmt/aviation/parse";
+
+formatSsimDate("1999-12-31", { yearWindow: 1950 });
+// "31DEC99"
+parseSsimDate("31DEC99", { yearWindow: 1950 });
+// "1999-12-31"
+```
+
+## Checking a value
+
+[`isValidSsimDate(value, options)`](/reference/aviation/validate/isValidSsimDate/) takes the same
+window and answers with a boolean. It is `true` exactly when `parseSsimDate` returns a date.
+
+```typescript
+import { isValidSsimDate } from "@northguild/gmt/aviation/validate";
+
+isValidSsimDate("01JAN26", { yearWindow: 2000 });
+// true
+isValidSsimDate("29FEB00", { yearWindow: 2000 });
+// true
+isValidSsimDate("29FEB00", { yearWindow: 1900 });
+// false
+isValidSsimDate("01jan26", { yearWindow: 2000 });
+// false
+isValidSsimDate("01JAN26", {});
+// false
+```
+
+The window is part of the question. `29FEB00` is neither valid nor invalid until you say which
+century it is in.
+
+## See it break, then work
+
+- [An SSIM Month Read in the Wrong Language](/scenarios/an-ssim-month-read-in-the-wrong-language/)
+- [Aviation mistakes](/mistakes/aviation/)
+- [SSIM Date Reader](/tools/ssim-date-reader/), a tool that reads, compares and writes a date
+
+## Sources
+
+- EUROCONTROL, [_CSST Users Guide_](https://www.eurocontrol.int/archive_download/all/node/9248),
+ Edition 8.0 (28-04-2021), section 3.2, Figure 1: an SSIM schedule file with the seven-character
+ form `DDMMMYY`.
+- ACL (Airport Coordination Limited, UK),
+ [_An Introductory Guide to SSIM_](https://www.acl-uk.org/wp-content/uploads/2021/04/SSIM-Review-Final2.pdf),
+ a condensed extract of Chapter 6: the day and the month letters, as `01APR`.
+- AECFA (Spain), _Quick Guide to Using the IATA SSIM format_, Chapter 6: the day as two digits and
+ the month as the first three letters of its English name. It is no longer online.
+- Avinor (Norway), SSIM wiki, [Period of Schedule Validity](https://xwiki.avinor.no/x/rYC5Ag):
+ shown as `ddmmyy`, a two-digit year.
+- IATA's _Standard Schedules Information Manual_ is not openly published, and its own text was
+ not reached.
diff --git a/apps/dox/src/content/docs/guides/industries/index.mdx b/apps/dox/src/content/docs/guides/industries/index.mdx
index ddf4bab9a..3634946b6 100644
--- a/apps/dox/src/content/docs/guides/industries/index.mdx
+++ b/apps/dox/src/content/docs/guides/industries/index.mdx
@@ -71,6 +71,9 @@ Three things hold across every industry layer:
- [Healthcare: clinical timestamps](./healthcare-clinical-timestamps/) — read and write HL7
version 2 dates and times, keep a time with no offset local until you name the sender's zone,
and keep a partial date a span.
+- [Aviation: message times](./aviation-message-times/) — read, write and check an SSIM schedule
+ date such as `01JAN26`, with month letters that ignore the platform's language and a century
+ you state. Draws on Core only.
## Scenarios
@@ -100,7 +103,9 @@ GMT approach working, on the same live widget:
- [Second Sixty on an Ordinary Day](/scenarios/second-sixty-on-an-ordinary-day/)
- [An HL7 Time Read as UTC](/scenarios/an-hl7-time-read-as-utc/)
- [A TS Date Read as a Time](/scenarios/a-ts-date-read-as-a-time/)
+- [An SSIM Month Read in the Wrong Language](/scenarios/an-ssim-month-read-in-the-wrong-language/)
The mistakes that have hurt people in these layers are collected under
[Transport mistakes](/mistakes/transport/), [Intermodal mistakes](/mistakes/intermodal/),
-[Finance mistakes](/mistakes/finance/) and [Healthcare mistakes](/mistakes/healthcare/).
+[Finance mistakes](/mistakes/finance/), [Healthcare mistakes](/mistakes/healthcare/) and
+[Aviation mistakes](/mistakes/aviation/).
diff --git a/apps/dox/src/content/docs/guides/integration/skills.mdx b/apps/dox/src/content/docs/guides/integration/skills.mdx
index 2138e6737..fd03d0918 100644
--- a/apps/dox/src/content/docs/guides/integration/skills.mdx
+++ b/apps/dox/src/content/docs/guides/integration/skills.mdx
@@ -47,6 +47,7 @@ Sample output:
- gmt-integration
- gmt-gnss
- gmt-finance
+ - gmt-aviation
- gmt-transport
- gmt-intermodal
- gmt-workforce
@@ -80,7 +81,7 @@ For projects that want explicit routing, pass `--map` to bind a task keyword to
skill so `intent list` highlights the right match automatically:
```bash
-npx @tanstack/intent@latest install --map "basics=gmt-basics" --map "arithmetic=gmt-arithmetic" --map "timezone=gmt-timezone" --map "gnss=gmt-gnss" --map "finance=gmt-finance" --map "transport=gmt-transport" --map "intermodal=gmt-intermodal" --map "workforce=gmt-workforce" --map "healthcare=gmt-healthcare" --map "lint=first-time-setup"
+npx @tanstack/intent@latest install --map "basics=gmt-basics" --map "arithmetic=gmt-arithmetic" --map "timezone=gmt-timezone" --map "gnss=gmt-gnss" --map "finance=gmt-finance" --map "transport=gmt-transport" --map "intermodal=gmt-intermodal" --map "workforce=gmt-workforce" --map "healthcare=gmt-healthcare" --map "aviation=gmt-aviation" --map "lint=first-time-setup"
```
## Allowlist skills
@@ -133,6 +134,7 @@ its tasks use `gmt-gnss`.
| Intermodal | `gmt-intermodal` | Free time, demurrage, billing deadlines, bill of lading dates, EDI and EPCIS timestamps | `src/intermodal/` |
| GNSS | `gmt-gnss` | GNSS time scales, broadcast and RINEX week numbers, rollover eras | `src/gnss/` |
| Finance | `gmt-finance` | FIX `UTCTimestamp` values: precision from the digit count, picoseconds, leap seconds | `src/finance/` |
+| Aviation | `gmt-aviation` | IATA SSIM schedule dates (`DDMMMYY`): fixed English month letters, a stated century | `src/aviation/` |
> **Skills are routing pointers, not API documentation.** The skill files carry the
> core rules and common pitfalls. For a signature, a locale matrix or an example,
diff --git a/apps/dox/src/content/docs/mistakes/aviation.mdx b/apps/dox/src/content/docs/mistakes/aviation.mdx
new file mode 100644
index 000000000..69c21dbc4
--- /dev/null
+++ b/apps/dox/src/content/docs/mistakes/aviation.mdx
@@ -0,0 +1,114 @@
+---
+title: Aviation mistakes
+description: Common mistakes with SSIM schedule dates, the month letters, upper case, the century and the window, in GMT's Aviation layer.
+industries: [aviation]
+sidebar:
+ label: Aviation
+---
+
+The Aviation layer reads and writes the dates in airline schedule files. The mistakes around them
+are the ones a quick parser makes: reading the month letters as a word in the machine's language,
+accepting lower case, fixing a century in code, writing a year the reader will place in another
+century, and judging a leap day without knowing the century. Every output shown here is what the
+function returns.
+
+import Mistake from "../../../components/Mistake.astro";
+
+## Month letters
+
+
+
+
+
+## The century
+
+
+
+
+
+
+
+See [An SSIM Month Read in the Wrong
+Language](/scenarios/an-ssim-month-read-in-the-wrong-language/), and the reasoning in [Aviation:
+Message Times](/guides/industries/aviation-message-times/). To try a date yourself, use the
+[SSIM Date Reader](/tools/ssim-date-reader/).
diff --git a/apps/dox/src/content/docs/mistakes/index.mdx b/apps/dox/src/content/docs/mistakes/index.mdx
index 5cbd66f6c..f504a64db 100644
--- a/apps/dox/src/content/docs/mistakes/index.mdx
+++ b/apps/dox/src/content/docs/mistakes/index.mdx
@@ -80,3 +80,9 @@ and (where applicable) a live playground you can tinker with.
- [Precision Mistakes](/mistakes/finance/#precision)
- [Leap Second Mistakes in FIX Timestamps](/mistakes/finance/#leap-seconds)
- [Local Time Mistakes](/mistakes/finance/#local-time)
+
+## Aviation
+
+- [Aviation Mistakes](/mistakes/aviation/)
+- [Month Letter Mistakes](/mistakes/aviation/#month-letters)
+- [Century Mistakes](/mistakes/aviation/#the-century)
diff --git a/apps/dox/src/content/docs/scenarios/an-ssim-month-read-in-the-wrong-language.mdx b/apps/dox/src/content/docs/scenarios/an-ssim-month-read-in-the-wrong-language.mdx
new file mode 100644
index 000000000..0251abb73
--- /dev/null
+++ b/apps/dox/src/content/docs/scenarios/an-ssim-month-read-in-the-wrong-language.mdx
@@ -0,0 +1,35 @@
+---
+title: "An SSIM Month Read in the Wrong Language"
+description: A schedule import runs on a server set to Spanish, and a parser that reads month names through the locale rejects 01JAN26 and accepts 01ENE26.
+industries: [aviation]
+---
+
+import Scenario from "~/components/Scenario.astro";
+
+
+
+The fix is to treat the letters as a code, not a word. See [Aviation: Message
+Times](/guides/industries/aviation-message-times/#why-the-month-letters-bypass-the-locale) for the
+reasoning, and [Aviation mistakes](/mistakes/aviation/) for the others that come with it. The
+[SSIM Date Reader](/tools/ssim-date-reader/) shows the same text read both ways.
diff --git a/apps/dox/src/content/docs/tools/ssim-date-reader.mdx b/apps/dox/src/content/docs/tools/ssim-date-reader.mdx
new file mode 100644
index 000000000..6c71eaee5
--- /dev/null
+++ b/apps/dox/src/content/docs/tools/ssim-date-reader.mdx
@@ -0,0 +1,56 @@
+---
+title: SSIM Date Reader
+description: Read an IATA SSIM date such as 01JAN26 in a window you state, see why a locale pattern parser reads the same text differently, and write an ISO date back.
+industries: [aviation]
+---
+
+import SsimDateReader from "../../../components/SsimDateReader.astro";
+import ToolLayout from "../../../components/ToolLayout.astro";
+
+
+
+
+
+An SSIM date is a code, not a sentence in a language: the month letters are fixed, and the century is yours to state.
+
+
+
+
+
+Airline schedules write a date as `DDMMMYY`, such as `01JAN26`. Two things in it are easy to get wrong. The month letters are the same in every country, and the two-digit year does not say which century it means. [`parseSsimDate`](/reference/aviation/parse/parseSsimDate/) reads the code with the window you give it and takes no locale.
+
+Type a date, state a window and pick a locale, or press one of the presets. Section 1 reads the date. Section 2 puts the same text through [`parseDateWithPattern`](/reference/plain/parse/parseDateWithPattern/), which reads the month as the locale's own short name: a different function, used wrongly, and the table beside it shows why. Section 3 writes an ISO date back. Every date and every month letter on the page is a library result, and each section prints the calls it made.
+
+
+
+
+
+
+
+**SSIM reads.** [`parseSsimDate`](/reference/aviation/parse/parseSsimDate/) takes upper-case letters only, and the window you pass says which hundred years the two-digit year falls in: a first year, or a rolling window that moves with today. With no window there is no date, and the page says so.
+
+**Valid.** [`isValidSsimDate`](/reference/aviation/validate/isValidSsimDate/) is true exactly when the read returns a date.
+
+**The locale pattern.** [`parseDateWithPattern`](/reference/plain/parse/parseDateWithPattern/) reads `MMM` as the short month names of the locale it is given, and ignores case. For an SSIM date that is the wrong function: the month letters are part of the format, and a translated month is not the code. [`getLocaleMonthNames`](/reference/plain/locale/getLocaleMonthNames/) lists the names the table sets beside the SSIM letters.
+
+**SSIM writes.** [`formatSsimDate`](/reference/aviation/format/formatSsimDate/) writes an ISO date as `DDMMMYY`, and refuses a year outside the window, because it would read back as another century.
+
+See [Aviation message times](/guides/industries/aviation-message-times/), [an SSIM month read in the wrong language](/scenarios/an-ssim-month-read-in-the-wrong-language/) and [Aviation mistakes](/mistakes/aviation/).
+
+**Worth trying:**
+
+- [01JAN26 with an fr-FR pattern](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22french-locale%22%7D) — the SSIM reader gives 2026-01-01 and the pattern parser has no date, because that locale writes the month `janv.`.
+- [The same text with an English pattern](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22english-locale%22%7D) — the two agree only because English short names happen to match the code.
+- [25OCT26 with a tr-TR pattern](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22turkish-locale%22%7D) — the locale you pass the pattern parser changes nothing for the SSIM reader.
+- [Lower case](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22lower-case%22%7D) — the SSIM reader refuses `01jan26`, and the pattern parser reads it.
+- [A translated month](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22spanish-locale%22%7D) — `01ENE26` reads under `es-ES` and is refused by the SSIM reader.
+- [An archive window](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22archive%22%7D) — a window from 1950 puts `09` in 2009.
+- [29FEB00 from 2000](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22leap-2000%22%7D) — valid, because 2000 is a leap year.
+- [29FEB00 from 1900](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22leap-1900%22%7D) — not valid, because 1900 has no 29 February.
+- [A rolling window](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22rolling%22%7D) — the window moves with today.
+- [No window](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22no-window%22%7D) — no century stated, no date.
+- [Write a year outside the window](/tools/ssim-date-reader/?w=ssim&wa=%7B%22preset%22%3A%22write-outside%22%7D) — the writer refuses 1999-12-31 in a window from 2000.
+
+
+
+
diff --git a/apps/dox/src/data/gmt-stats.json b/apps/dox/src/data/gmt-stats.json
index 3270c623b..fc654933e 100644
--- a/apps/dox/src/data/gmt-stats.json
+++ b/apps/dox/src/data/gmt-stats.json
@@ -1,8 +1,8 @@
{
"suite": "packages/gmt",
- "tests": 72935,
- "files": 961,
- "executions": 2188050,
+ "tests": 73261,
+ "files": 965,
+ "executions": 2197830,
"nodes": ["22", "24", "26"],
"timezones": 10,
"timezoneList": [
@@ -37,7 +37,7 @@
"ru-RU",
"tr-TR"
],
- "functions": 748,
+ "functions": 751,
"patterns": 30,
"byNamespace": [
{
@@ -104,6 +104,10 @@
"namespace": "recurrence",
"count": 4
},
+ {
+ "namespace": "aviation",
+ "count": 3
+ },
{
"namespace": "finance",
"count": 3
@@ -118,6 +122,7 @@
"transport",
"workforce",
"gnss",
+ "aviation",
"finance",
"healthcare"
],
@@ -192,7 +197,13 @@
"label": "Healthcare",
"own": 3,
"drawsOn": []
+ },
+ {
+ "id": "aviation",
+ "label": "Aviation",
+ "own": 3,
+ "drawsOn": []
}
],
- "industryFunctions": 90
+ "industryFunctions": 93
}
diff --git a/apps/dox/src/data/industries.json b/apps/dox/src/data/industries.json
index 008b9a6f1..50da72c09 100644
--- a/apps/dox/src/data/industries.json
+++ b/apps/dox/src/data/industries.json
@@ -60,5 +60,14 @@
"guide": "/guides/industries/healthcare-clinical-timestamps/",
"namespace": "healthcare",
"drawsOn": []
+ },
+ {
+ "id": "aviation",
+ "label": "Aviation",
+ "definition": "Airline schedule dates in IATA SSIM files, with English month letters and a century the caller states.",
+ "icon": "industry-aviation",
+ "guide": "/guides/industries/aviation-message-times/",
+ "namespace": "aviation",
+ "drawsOn": []
}
]
diff --git a/apps/dox/src/generated/reference/gmt-corpus.json b/apps/dox/src/generated/reference/gmt-corpus.json
index 6dcf45b91..66ca00378 100644
--- a/apps/dox/src/generated/reference/gmt-corpus.json
+++ b/apps/dox/src/generated/reference/gmt-corpus.json
@@ -1,4 +1,127 @@
[
+ {
+ "url": "/reference/aviation/format/formatSsimDate",
+ "page": "/reference/aviation/format/formatSsimDate",
+ "name": "formatSsimDate",
+ "namespace": "aviation",
+ "module": "format",
+ "kind": "function",
+ "signature": "formatSsimDate(value: string, options: TwoDigitYearOptions): string",
+ "description": "Write an ISO 8601 date as an SSIM schedule date. The inverse of `parseSsimDate`.",
+ "sourcePath": "packages/gmt/src/aviation/format/formatSsimDate.ts",
+ "examples": [
+ {
+ "call": "formatSsimDate(\"2026-10-25\", { yearWindow: 2000 })",
+ "result": "\"25OCT26\""
+ },
+ {
+ "call": "formatSsimDate(\"2000-02-29\", { yearWindow: 2000 })",
+ "result": "\"29FEB00\""
+ },
+ {
+ "call": "formatSsimDate(\"2049-12-31\", { yearWindow: 1950 })",
+ "result": "\"31DEC49\""
+ },
+ {
+ "call": "formatSsimDate(\"1999-12-31\", { yearWindow: 2000 })",
+ "result": "\"\""
+ },
+ {
+ "call": "formatSsimDate(\"2026-10-25\", { yearWindow: \"rolling\" })",
+ "result": "\"25OCT26\" (while the current UTC year is 1977–2076)"
+ },
+ {
+ "call": "formatSsimDate(\"2026-10-25\", {})",
+ "result": "\"\""
+ },
+ {
+ "call": "formatSsimDate(\"2026-10-25T10:00\", { yearWindow: 2000 })",
+ "result": "\"\""
+ }
+ ]
+ },
+ {
+ "url": "/reference/aviation/parse/parseSsimDate",
+ "page": "/reference/aviation/parse/parseSsimDate",
+ "name": "parseSsimDate",
+ "namespace": "aviation",
+ "module": "parse",
+ "kind": "function",
+ "signature": "parseSsimDate(value: string, options: TwoDigitYearOptions): string",
+ "description": "Parse an SSIM schedule date as an ISO 8601 date.",
+ "sourcePath": "packages/gmt/src/aviation/parse/parseSsimDate.ts",
+ "examples": [
+ {
+ "call": "parseSsimDate(\"01JAN26\", { yearWindow: 2000 })",
+ "result": "\"2026-01-01\""
+ },
+ {
+ "call": "parseSsimDate(\"29FEB00\", { yearWindow: 2000 })",
+ "result": "\"2000-02-29\""
+ },
+ {
+ "call": "parseSsimDate(\"29FEB00\", { yearWindow: 1900 })",
+ "result": "\"\""
+ },
+ {
+ "call": "parseSsimDate(\"16DEC09\", { yearWindow: 1950 })",
+ "result": "\"2009-12-16\""
+ },
+ {
+ "call": "parseSsimDate(\"01JAN26\", { yearWindow: \"rolling\" })",
+ "result": "\"2026-01-01\" (while the current UTC year is 1977–2076)"
+ },
+ {
+ "call": "parseSsimDate(\"01jan26\", { yearWindow: 2000 })",
+ "result": "\"\""
+ },
+ {
+ "call": "parseSsimDate(\"01ENE26\", { yearWindow: 2000 })",
+ "result": "\"\""
+ },
+ {
+ "call": "parseSsimDate(\"01JAN26\", {})",
+ "result": "\"\""
+ }
+ ]
+ },
+ {
+ "url": "/reference/aviation/validate/isValidSsimDate",
+ "page": "/reference/aviation/validate/isValidSsimDate",
+ "name": "isValidSsimDate",
+ "namespace": "aviation",
+ "module": "validate",
+ "kind": "function",
+ "signature": "isValidSsimDate(value: string, options: TwoDigitYearOptions): boolean",
+ "description": "Return true when `value` is a real SSIM date (`DDMMMYY`) in the stated hundred-year window.",
+ "sourcePath": "packages/gmt/src/aviation/validate/isValidSsimDate.ts",
+ "examples": [
+ {
+ "call": "isValidSsimDate(\"01JAN26\", { yearWindow: 2000 })",
+ "result": "true"
+ },
+ {
+ "call": "isValidSsimDate(\"29FEB00\", { yearWindow: 2000 })",
+ "result": "true"
+ },
+ {
+ "call": "isValidSsimDate(\"29FEB00\", { yearWindow: 1900 })",
+ "result": "false"
+ },
+ {
+ "call": "isValidSsimDate(\"01jan26\", { yearWindow: 2000 })",
+ "result": "false"
+ },
+ {
+ "call": "isValidSsimDate(\"31APR26\", { yearWindow: 2000 })",
+ "result": "false"
+ },
+ {
+ "call": "isValidSsimDate(\"01JAN26\", {})",
+ "result": "false"
+ }
+ ]
+ },
{
"url": "/reference/calendar/business/businessDaysBetween",
"page": "/reference/calendar/business/businessDaysBetween",
diff --git a/apps/dox/src/generated/reference/route-manifest.ts b/apps/dox/src/generated/reference/route-manifest.ts
index 572c5a56b..1ea83d3ff 100644
--- a/apps/dox/src/generated/reference/route-manifest.ts
+++ b/apps/dox/src/generated/reference/route-manifest.ts
@@ -4,6 +4,13 @@ import type { RouteManifest } from "~/reference-types";
export const referenceRoutes: RouteManifest = new Set([
"/reference",
+ "/reference/aviation",
+ "/reference/aviation/format",
+ "/reference/aviation/format/formatSsimDate",
+ "/reference/aviation/parse",
+ "/reference/aviation/parse/parseSsimDate",
+ "/reference/aviation/validate",
+ "/reference/aviation/validate/isValidSsimDate",
"/reference/calendar",
"/reference/calendar/business",
"/reference/calendar/business/businessDaysBetween",
diff --git a/apps/dox/src/lib/aviation-lib.test.ts b/apps/dox/src/lib/aviation-lib.test.ts
new file mode 100644
index 000000000..fa8fa5c77
--- /dev/null
+++ b/apps/dox/src/lib/aviation-lib.test.ts
@@ -0,0 +1,54 @@
+/**
+ * `loadAviationLib` against the real gmt modules.
+ */
+import { loadAviationLib } from "./aviation-lib";
+import { GMT_MODULES } from "./gmt-modules";
+import { WidgetLoadError } from "./widget-mount";
+
+const NAMES = [
+ "parseSsimDate",
+ "formatSsimDate",
+ "isValidSsimDate",
+ "parseDateWithPattern",
+ "getLocaleMonthNames",
+ "isValidDate",
+];
+
+describe("loadAviationLib", () => {
+ it("hands back every function the tools call, and nothing else", async () => {
+ const lib = await loadAviationLib();
+ expect(Object.keys(lib).sort()).toEqual([...NAMES].sort());
+ for (const name of NAMES) {
+ expect(typeof (lib as unknown as Record)[name]).toBe(
+ "function",
+ );
+ }
+ });
+
+ it("answers a real call", async () => {
+ const lib = await loadAviationLib();
+ expect(lib.parseSsimDate("01JAN26", { yearWindow: 2000 })).toBe(
+ "2026-01-01",
+ );
+ });
+
+ it("turns a rejected import into a WidgetLoadError", async () => {
+ const original = GMT_MODULES["aviation/parse"];
+ GMT_MODULES["aviation/parse"] = () => Promise.reject(new Error("offline"));
+ try {
+ await expect(loadAviationLib()).rejects.toBeInstanceOf(WidgetLoadError);
+ } finally {
+ GMT_MODULES["aviation/parse"] = original;
+ }
+ });
+
+ it("turns a module that lacks a name into a WidgetLoadError", async () => {
+ const original = GMT_MODULES["plain/locale"];
+ GMT_MODULES["plain/locale"] = () => Promise.resolve({});
+ try {
+ await expect(loadAviationLib()).rejects.toBeInstanceOf(WidgetLoadError);
+ } finally {
+ GMT_MODULES["plain/locale"] = original;
+ }
+ });
+});
diff --git a/apps/dox/src/lib/aviation-lib.ts b/apps/dox/src/lib/aviation-lib.ts
new file mode 100644
index 000000000..66bce1fcd
--- /dev/null
+++ b/apps/dox/src/lib/aviation-lib.ts
@@ -0,0 +1,74 @@
+/**
+ * Loads the real gmt functions the aviation tools call, at module granularity, and hands
+ * them back as an `AviationLib`.
+ *
+ * The SSIM readers live in `aviation/parse`, `aviation/format` and `aviation/validate`; the
+ * locale pattern parser in `plain/parse`; the locale month names in `plain/locale`; and
+ * `isValidDate` in `plain/validate`. Each name is picked from its module and nothing else is
+ * read.
+ *
+ * A heavy module: only a tool's mount imports it. A module that fails to load, or a name it
+ * no longer exports, becomes a `WidgetLoadError` rather than a dead control.
+ */
+import { GMT_MODULES } from "./gmt-modules";
+import { pickFunctions } from "./gmt-pick";
+import { WidgetLoadError } from "./widget-mount";
+
+/** The hundred-year window a two-digit year is read in, as the library takes it. */
+export interface YearWindowOptions {
+ yearWindow?: number | "rolling";
+}
+
+/** The functions the aviation tools call, as the library declares them. */
+export interface AviationLib {
+ // aviation/parse
+ parseSsimDate(value: string, options: YearWindowOptions): string;
+ // aviation/format
+ formatSsimDate(value: string, options: YearWindowOptions): string;
+ // aviation/validate
+ isValidSsimDate(value: string, options: YearWindowOptions): boolean;
+ // plain/parse
+ parseDateWithPattern(
+ value: string,
+ pattern: string,
+ locale?: string | string[],
+ options?: YearWindowOptions,
+ ): string;
+ // plain/locale
+ getLocaleMonthNames(
+ locale: string | string[],
+ style?: "long" | "short" | "narrow",
+ ): string[];
+ // plain/validate
+ isValidDate(value: string): boolean;
+}
+
+export async function loadAviationLib(): Promise {
+ try {
+ const [
+ aviationParse,
+ aviationFormat,
+ aviationValidate,
+ parse,
+ locale,
+ validate,
+ ] = await Promise.all([
+ GMT_MODULES["aviation/parse"](),
+ GMT_MODULES["aviation/format"](),
+ GMT_MODULES["aviation/validate"](),
+ GMT_MODULES["plain/parse"](),
+ GMT_MODULES["plain/locale"](),
+ GMT_MODULES["plain/validate"](),
+ ]);
+ return {
+ ...pickFunctions(aviationParse, ["parseSsimDate"]),
+ ...pickFunctions(aviationFormat, ["formatSsimDate"]),
+ ...pickFunctions(aviationValidate, ["isValidSsimDate"]),
+ ...pickFunctions(parse, ["parseDateWithPattern"]),
+ ...pickFunctions(locale, ["getLocaleMonthNames"]),
+ ...pickFunctions(validate, ["isValidDate"]),
+ } as unknown as AviationLib;
+ } catch (cause) {
+ throw new WidgetLoadError(cause);
+ }
+}
diff --git a/apps/dox/src/lib/chat-constants.ts b/apps/dox/src/lib/chat-constants.ts
index b78a8d682..8e2ff3374 100644
--- a/apps/dox/src/lib/chat-constants.ts
+++ b/apps/dox/src/lib/chat-constants.ts
@@ -337,6 +337,7 @@ export const EXAMPLE_AREAS = [
{ id: "gnss", label: "GNSS" },
{ id: "finance", label: "Finance" },
{ id: "healthcare", label: "Healthcare" },
+ { id: "aviation", label: "Aviation" },
] as const;
type ExampleArea = (typeof EXAMPLE_AREAS)[number]["id"];
@@ -906,6 +907,12 @@ export const CHAT_STARTERS: readonly {
area: "core",
args: { value: "2026-01-01T00:00:00Z" },
},
+ {
+ text: "Does the SSIM date 01JAN26 read the same as the locale pattern parser's reading, with a window from 2000?",
+ widget: "showSsimDateReader",
+ area: "aviation",
+ args: { value: "01JAN26", yearWindow: 2000, locale: "fr-FR" },
+ },
];
/** The rail call a starter card makes on click: a stable id per starter, so a
diff --git a/apps/dox/src/lib/dox-tools.ts b/apps/dox/src/lib/dox-tools.ts
index 70af2c00f..a8c7ceff0 100644
--- a/apps/dox/src/lib/dox-tools.ts
+++ b/apps/dox/src/lib/dox-tools.ts
@@ -644,6 +644,26 @@ export const showHl7TimestampReaderInput = z.object({
zone4: zoneSchema.optional(),
});
+/**
+ * SSIM Date Reader: the SSIM text to read (`value`), the window its two-digit year is read in
+ * (`yearWindow`: a first year or "rolling"), the locale the comparison passes the pattern
+ * parser (`locale`) and an ISO date to write back (`date`). Nothing is trimmed, upper-cased or
+ * defaulted: a call with no `yearWindow` opens with the window blank, and the chat never picks
+ * a century. The widget's permalink calls `yearWindow` `window`.
+ */
+export const showSsimDateReaderInput = z
+ .object({
+ value: z.string().max(16).optional(),
+ yearWindow: z
+ .union([z.literal("rolling"), z.number().int().min(0).max(9900)])
+ .optional(),
+ locale: z.string().min(2).max(35).optional(),
+ date: z.string().max(32).optional(),
+ })
+ .refine((a) => a.value !== undefined || a.date !== undefined, {
+ message: "Give a value to read or a date to write.",
+ });
+
/** Typed as the library's `IsoWeekday`, so a parsed shift is a `HolidayRule` shift. */
const isoWeekdaySchema = z
.number()
@@ -1274,7 +1294,8 @@ export type DoxToolName =
| "showTai64nLogReader"
| "showTerrestrialTimeStack"
| "showFixTimestampReader"
- | "showHl7TimestampReader";
+ | "showHl7TimestampReader"
+ | "showSsimDateReader";
/** Prompt copy, kept beside the schemas so the two cannot drift. */
export const DOX_TOOL_DOCS: {
@@ -1605,6 +1626,13 @@ export const DOX_TOOL_DOCS: {
when: "the reader asks what an HL7 v2 DTM or TS value means, what instant an HL7 time with no offset names, what a TS degree of precision such as ^L or ^D does, or how to write an instant as an HL7 DTM",
args: "value (the HL7 date-time exactly as the reader gave it, such as 20240615103000 or 199904011200^L; at most 64 characters; never corrected, and never given an offset the reader did not send), zone1 to zone4 (optional IANA ids to read a value with no offset in; only zones the reader named: never choose one from a facility, a place, a vendor or an abbreviation, because the value states none).",
},
+ {
+ name: "showSsimDateReader",
+ purpose:
+ "Read an IATA SSIM DDMMMYY date with a window you state, beside the locale pattern parser, and write a date back.",
+ when: "Call when the reader asks about SSIM or airline schedule dates such as 01JAN26, a month code read in the wrong language, or which century a two-digit year means in a schedule. Pass only what the reader gave: never a yearWindow they did not state, never a locale inferred from a place, never an upper-cased value.",
+ args: 'value: the SSIM text exactly as the reader gave it, at most 16 characters, never trimmed or upper-cased; yearWindow: only when the reader stated one, a first year from 0 to 9900 or "rolling"; locale: a BCP 47 tag, only when the reader named one, passed to the pattern comparison alone; date: an ISO date to write back. Give value or date.',
+ },
];
/**
@@ -1797,6 +1825,10 @@ export const DOX_TOOLS = {
description: DOX_TOOL_DOCS[45].purpose,
inputSchema: showHl7TimestampReaderInput,
}),
+ showSsimDateReader: tool({
+ description: DOX_TOOL_DOCS[46].purpose,
+ inputSchema: showSsimDateReaderInput,
+ }),
} as const;
export const DOX_TOOL_NAMES = Object.keys(DOX_TOOLS) as DoxToolName[];
@@ -1866,6 +1898,7 @@ export const ENABLED_TOOL_NAMES = [
"showTerrestrialTimeStack",
"showFixTimestampReader",
"showHl7TimestampReader",
+ "showSsimDateReader",
] as const satisfies readonly DoxToolName[];
/** Prompt copy for the offered tools only. */
diff --git a/apps/dox/src/lib/gmt-modules.ts b/apps/dox/src/lib/gmt-modules.ts
index 53cc55088..ae87884ad 100644
--- a/apps/dox/src/lib/gmt-modules.ts
+++ b/apps/dox/src/lib/gmt-modules.ts
@@ -54,6 +54,11 @@ export const GMT_MODULES: Record<
"instant/parse": () => import("@northguild/gmt/instant/parse"),
"instant/validate": () => import("@northguild/gmt/instant/validate"),
+ // --- aviation ---
+ "aviation/format": () => import("@northguild/gmt/aviation/format"),
+ "aviation/parse": () => import("@northguild/gmt/aviation/parse"),
+ "aviation/validate": () => import("@northguild/gmt/aviation/validate"),
+
// --- calendar ---
"calendar/business": () => import("@northguild/gmt/calendar/business"),
"calendar/calculate": () => import("@northguild/gmt/calendar/calculate"),
diff --git a/apps/dox/src/lib/industry-overview.ts b/apps/dox/src/lib/industry-overview.ts
index 898d7ddf2..59911d01e 100644
--- a/apps/dox/src/lib/industry-overview.ts
+++ b/apps/dox/src/lib/industry-overview.ts
@@ -524,6 +524,54 @@ export const INDUSTRY_OVERVIEWS: Readonly> = {
},
],
},
+ aviation: {
+ about:
+ "Airlines exchange schedules in IATA's SSIM files, and their dates are not ISO. A date there is a day, three English month letters and a two-digit year. This layer reads and writes that date without the platform's language settings and without picking a century for you.",
+ guideTitle: "Aviation: Message Times",
+ solves: [
+ {
+ problem:
+ "A schedule date reads differently on a machine set to another language.",
+ answer:
+ "The month letters are a fixed English code. {{parseSsimDate}} reads them from a constant table and never asks the platform's language, so the same file gives the same date everywhere.",
+ see: [
+ {
+ label: "guide",
+ href: "/guides/industries/aviation-message-times/",
+ },
+ {
+ label: "scenario",
+ href: "/scenarios/an-ssim-month-read-in-the-wrong-language/",
+ },
+ { label: "mistakes", href: "/mistakes/aviation/" },
+ ],
+ },
+ {
+ problem: "A two-digit year lands in the wrong century.",
+ answer:
+ "The format does not say which century it means. {{parseSsimDate}} and {{isValidSsimDate}} take the hundred-year window you state, a fixed start for an archive or a rolling one for a live feed, and give nothing without it.",
+ see: [
+ {
+ label: "guide",
+ href: "/guides/industries/aviation-message-times/",
+ },
+ { label: "mistakes", href: "/mistakes/aviation/" },
+ ],
+ },
+ {
+ problem: "A date written back reads as another year.",
+ answer:
+ "{{formatSsimDate}} writes upper-case letters and refuses a year outside your window, so reading its output back with the same window gives the same date.",
+ see: [
+ {
+ label: "guide",
+ href: "/guides/industries/aviation-message-times/",
+ },
+ { label: "mistakes", href: "/mistakes/aviation/" },
+ ],
+ },
+ ],
+ },
};
/** The `{{name}}` tokens in a pain point's text, in order. */
diff --git a/apps/dox/src/lib/industry-tags.ts b/apps/dox/src/lib/industry-tags.ts
index 48ec3f440..83440f8e8 100644
--- a/apps/dox/src/lib/industry-tags.ts
+++ b/apps/dox/src/lib/industry-tags.ts
@@ -168,8 +168,8 @@ const STROKE =
* `DETAILS`, in the transport icons' format (transport-icons.ts): a 24x24
* viewBox, stroke-based, legible at 14px. A clock for core, a person beside a
* clock face for workforce, a route between two points for transport, a
- * container for intermodal. None reuses a transport mode's glyph, which
- * already means that mode inside the widgets. */
+ * container for intermodal, a control tower for aviation. None reuses a transport
+ * mode's glyph, which already means that mode inside the widgets. */
export const INDUSTRY_ICON_PATHS: Readonly> = {
"industry-core": ``,
"industry-workforce": ``,
@@ -179,6 +179,7 @@ export const INDUSTRY_ICON_PATHS: Readonly> = {
"industry-maritime": ``,
"industry-finance": ``,
"industry-healthcare": ``,
+ "industry-aviation": ``,
};
/**
diff --git a/apps/dox/src/lib/mdx-jsx.ts b/apps/dox/src/lib/mdx-jsx.ts
index 0ed7631e2..09151bda1 100644
--- a/apps/dox/src/lib/mdx-jsx.ts
+++ b/apps/dox/src/lib/mdx-jsx.ts
@@ -616,6 +616,7 @@ export function renderMdxComponents(body: string): string {
"StoredTimeAudit",
"Tai64nLogReader",
"FixTimestampReader",
+ "SsimDateReader",
"HolidayRuleBuilder",
"ObservanceComparator",
"MovingFeasts",
diff --git a/apps/dox/src/lib/namespace-summary.ts b/apps/dox/src/lib/namespace-summary.ts
index 9a3798d2b..4ea3497e8 100644
--- a/apps/dox/src/lib/namespace-summary.ts
+++ b/apps/dox/src/lib/namespace-summary.ts
@@ -49,6 +49,8 @@ export const NAMESPACE_SUMMARIES: Readonly> = {
"Functions that read, write and check the timestamps of financial messages, starting with the FIX UTCTimestamp.",
healthcare:
"Functions that read, write and check HL7 version 2 date-times, keeping the precision sent and a missing offset as local time.",
+ aviation:
+ "Functions that read, write and check the dates of aviation messages, starting with the SSIM date DDMMMYY.",
};
/**
diff --git a/apps/dox/src/lib/ssim-date-reader-mount.test.tsx b/apps/dox/src/lib/ssim-date-reader-mount.test.tsx
new file mode 100644
index 000000000..c46932277
--- /dev/null
+++ b/apps/dox/src/lib/ssim-date-reader-mount.test.tsx
@@ -0,0 +1,490 @@
+/**
+ * @vitest-environment jsdom
+ *
+ * The SSIM Date Reader end to end, through roles and accessible names the way a reader meets
+ * the page. The loader hands the widget the real library wrapped in a recorder, so the printed
+ * calls can be checked against the calls that ran. A hold draws every text it may show, hidden,
+ * so a text a reader sees is looked up with the hidden twins ignored.
+ */
+import { screen, within } from "@testing-library/dom";
+import { convertUtcToUnix } from "@northguild/gmt/utc/convert";
+import {
+ WIDGET_REGISTRY,
+ type AnyWidgetEntry,
+} from "~/components/ask/widget-registry";
+import { installJsdomShims } from "~/test/jsdom-shims";
+import {
+ expectNoAxeViolations,
+ renderWidget,
+ type RenderedWidget,
+} from "~/test/render-widget";
+import { aviationLib } from "~/test/aviation-lib";
+import type { AviationLib } from "./aviation-lib";
+
+const recorded: { name: string; args: unknown[] }[] = [];
+
+vi.mock("./aviation-lib", () => ({
+ loadAviationLib: async () => {
+ const { aviationLib: real } = await import("~/test/aviation-lib");
+ const wrapped = {} as Record;
+ for (const [name, fn] of Object.entries(real)) {
+ wrapped[name] = (...args: unknown[]) => {
+ recorded.push({ name, args });
+ return (fn as (...a: unknown[]) => unknown)(...args);
+ };
+ }
+ return wrapped as unknown as AviationLib;
+ },
+}));
+
+const { READ_REASONS, SSIM_PRESETS, WRITE_REASONS, monthTable } =
+ await import("./ssim-date-reader");
+const { DIFFERS_TEXT, NOT_WRITTEN } = await import("./ssim-date-reader-mount");
+
+installJsdomShims();
+
+const entry = WIDGET_REGISTRY["showSsimDateReader"] as AnyWidgetEntry;
+
+let live: RenderedWidget | null = null;
+
+const open = async (args: unknown = {}): Promise => {
+ live?.destroy();
+ recorded.length = 0;
+ live = await renderWidget(entry, { args });
+ return live;
+};
+
+afterEach(() => {
+ live?.destroy();
+ live = null;
+ vi.useRealTimers();
+});
+
+const SIGNAL = "⟨ NO SIGNAL ⟩";
+
+/**
+ * The elements that show `text` to a reader. A hold keeps a hidden twin of every text it may
+ * show, inside an `aria-hidden` wrapper, so those are left out.
+ */
+const shown = (text: string, container: HTMLElement = document.body) =>
+ within(container)
+ .queryAllByText(text)
+ // oxlint-disable-next-line testing-library/no-node-access -- a hold keeps hidden twins beside the live text, and no query drops a hidden subtree from a text match
+ .filter((el) => el.closest("[aria-hidden='true']") === null);
+
+const preset = () => screen.getByRole("combobox", { name: "Preset" });
+const valueBox = () => screen.getByRole("textbox", { name: "SSIM date" });
+const firstBox = () => screen.getByRole("textbox", { name: "First year" });
+const localeSelect = () => screen.getByRole("combobox", { name: "Locale" });
+const dateBox = () => screen.getByRole("textbox", { name: "ISO date" });
+const calls = (which: string) =>
+ screen.getByRole("group", { name: `Calls made for ${which}`, hidden: true });
+
+/** The row of a plate: its caption's group, whose shown text is the value a reader sees. */
+const plate = (caption: string) => {
+ const [term] = shown(caption);
+ if (term === undefined) throw new Error(`no plate captioned ${caption}`);
+ // oxlint-disable-next-line testing-library/no-node-access -- a plate has no role; its caption's row is the only handle on the value beside it
+ return term.closest("div")!;
+};
+const reads = (caption: string, text: string) =>
+ expect(shown(text, plate(caption))).toHaveLength(1);
+
+const reason = (label: string) => screen.getByRole("note", { name: label });
+
+async function paste(w: RenderedWidget, box: HTMLElement, value: string) {
+ await w.user.clear(box);
+ if (value !== "") {
+ await w.user.click(box);
+ await w.user.paste(value);
+ }
+}
+
+describe("opening", () => {
+ it("opens on the french-locale preset with the comparison already differing", async () => {
+ const w = await open();
+ expect(preset()).toHaveValue("french-locale");
+ expect(valueBox()).toHaveValue("01JAN26");
+ expect(firstBox()).toHaveValue("2000");
+ expect(localeSelect()).toHaveValue("fr-FR");
+ reads("SSIM reads", "2026-01-01");
+ reads("Valid", "valid");
+ reads("Pattern reads (ddMMMyy, fr-FR)", "no date");
+ expect(shown(DIFFERS_TEXT)).toHaveLength(1);
+ expect(reason("Reason for the read")).toHaveTextContent(READ_REASONS.read);
+ await expectNoAxeViolations(w.root);
+ });
+
+ it("opens on what a chat call carries, with no window when none was given", async () => {
+ const w = await open({ value: "01JAN26", window: "", locale: "en" });
+ expect(valueBox()).toHaveValue("01JAN26");
+ expect(firstBox()).toHaveValue("");
+ reads("SSIM reads", SIGNAL);
+ reads("Valid", "not valid");
+ expect(reason("Reason for the read")).toHaveTextContent(
+ READ_REASONS.noWindow,
+ );
+ await expectNoAxeViolations(w.root);
+ });
+});
+
+describe("every preset", () => {
+ const EXPECT: Record<
+ string,
+ { ssim: string; valid: string; pattern: string; differs: boolean }
+ > = {
+ "french-locale": {
+ ssim: "2026-01-01",
+ valid: "valid",
+ pattern: "no date",
+ differs: true,
+ },
+ "english-locale": {
+ ssim: "2026-01-01",
+ valid: "valid",
+ pattern: "2026-01-01",
+ differs: false,
+ },
+ "turkish-locale": {
+ ssim: "2026-10-25",
+ valid: "valid",
+ pattern: "no date",
+ differs: true,
+ },
+ "lower-case": {
+ ssim: SIGNAL,
+ valid: "not valid",
+ pattern: "2026-01-01",
+ differs: true,
+ },
+ "spanish-locale": {
+ ssim: SIGNAL,
+ valid: "not valid",
+ pattern: "2026-01-01",
+ differs: true,
+ },
+ archive: {
+ ssim: "2009-12-16",
+ valid: "valid",
+ pattern: "2009-12-16",
+ differs: false,
+ },
+ "leap-2000": {
+ ssim: "2000-02-29",
+ valid: "valid",
+ pattern: "2000-02-29",
+ differs: false,
+ },
+ "leap-1900": {
+ ssim: SIGNAL,
+ valid: "not valid",
+ pattern: "no date",
+ differs: false,
+ },
+ "no-window": {
+ ssim: SIGNAL,
+ valid: "not valid",
+ pattern: "no date",
+ differs: false,
+ },
+ "write-outside": {
+ ssim: "2026-01-01",
+ valid: "valid",
+ pattern: "2026-01-01",
+ differs: false,
+ },
+ };
+
+ it("has an expectation for each preset but the rolling one", () => {
+ expect(
+ SSIM_PRESETS.map((p) => p.id)
+ .filter((id) => id !== "rolling")
+ .sort(),
+ ).toEqual(Object.keys(EXPECT).sort());
+ });
+
+ it.each(Object.entries(EXPECT))(
+ "%s reads as the library says, and is accessible",
+ async (id, want) => {
+ const w = await open();
+ await w.user.selectOptions(preset(), id);
+ expect(preset()).toHaveValue(id);
+ const locale = (localeSelect() as HTMLSelectElement).value;
+ reads("SSIM reads", want.ssim);
+ reads("Valid", want.valid);
+ reads(`Pattern reads (ddMMMyy, ${locale})`, want.pattern);
+ if (want.differs) {
+ expect(shown(DIFFERS_TEXT)).toHaveLength(1);
+ } else {
+ expect(shown(DIFFERS_TEXT)).toHaveLength(0);
+ }
+ await expectNoAxeViolations(w.root);
+ },
+ );
+
+ it("the rolling preset reads with a rolling window and keeps the first year out of the way", async () => {
+ vi.useFakeTimers({ toFake: ["Date"] });
+ vi.setSystemTime(convertUtcToUnix("2026-11-10T12:00:00Z")!);
+ const w = await open();
+ await w.user.selectOptions(preset(), "rolling");
+ expect(screen.getByRole("radio", { name: "Rolling" })).toBeChecked();
+ expect(
+ screen.queryByRole("textbox", { name: "First year" }),
+ ).not.toBeInTheDocument();
+ reads(
+ "SSIM reads",
+ aviationLib.parseSsimDate("25OCT26", { yearWindow: "rolling" }),
+ );
+ expect(calls("the SSIM read")).toHaveTextContent(
+ '{ yearWindow: "rolling" }',
+ );
+ await expectNoAxeViolations(w.root);
+ });
+
+ it("a rolling window moves with the clock", async () => {
+ vi.useFakeTimers({ toFake: ["Date"] });
+ vi.setSystemTime(convertUtcToUnix("2026-11-10T12:00:00Z")!);
+ const w = await open({ value: "25OCT26", window: "rolling" });
+ const now = aviationLib.parseSsimDate("25OCT26", { yearWindow: "rolling" });
+ reads("SSIM reads", now);
+ vi.setSystemTime(convertUtcToUnix("2090-01-01T12:00:00Z")!);
+ await w.user.clear(valueBox());
+ await w.user.click(valueBox());
+ await w.user.paste("25OCT26");
+ const later = aviationLib.parseSsimDate("25OCT26", {
+ yearWindow: "rolling",
+ });
+ expect(later).not.toBe(now);
+ reads("SSIM reads", later);
+ });
+});
+
+describe("typing", () => {
+ it("lower case is refused with its own reason, and the call shows the text as typed", async () => {
+ const w = await open();
+ await paste(w, valueBox(), "01jan26");
+ reads("SSIM reads", SIGNAL);
+ expect(reason("Reason for the read")).toHaveTextContent(
+ READ_REASONS.lowerCase,
+ );
+ expect(calls("the SSIM read")).toHaveTextContent('parseSsimDate("01jan26"');
+ expect(preset()).toHaveValue("custom");
+ await expectNoAxeViolations(w.root);
+ });
+
+ it("a day the month lacks has its own reason, and the day probe prints", async () => {
+ const w = await open();
+ await paste(w, valueBox(), "31APR26");
+ reads("SSIM reads", SIGNAL);
+ expect(reason("Reason for the read")).toHaveTextContent(
+ READ_REASONS.noSuchDay,
+ );
+ expect(calls("the SSIM read")).toHaveTextContent('parseSsimDate("01APR26"');
+ });
+
+ it("a first year the library refuses has its own reason, not the shape's", async () => {
+ const w = await open();
+ await paste(w, firstBox(), "10000");
+ reads("SSIM reads", SIGNAL);
+ expect(reason("Reason for the read")).toHaveTextContent(
+ READ_REASONS.badWindow,
+ );
+ expect(calls("the SSIM read")).toHaveTextContent(
+ 'parseSsimDate("01JAN00", { yearWindow: 10000 })',
+ );
+ });
+
+ it("a cleared window is the no-date reason, never a default", async () => {
+ const w = await open();
+ await w.user.clear(firstBox());
+ reads("SSIM reads", SIGNAL);
+ expect(reason("Reason for the read")).toHaveTextContent(
+ READ_REASONS.noWindow,
+ );
+ expect(calls("the SSIM read")).toHaveTextContent(
+ 'parseSsimDate("01JAN26", {})',
+ );
+ });
+
+ it("the window chips switch the window and show or hide the first year", async () => {
+ const w = await open();
+ await w.user.click(screen.getByRole("radio", { name: "Rolling" }));
+ expect(
+ screen.queryByRole("textbox", { name: "First year" }),
+ ).not.toBeInTheDocument();
+ await w.user.click(screen.getByRole("radio", { name: "Fixed from" }));
+ expect(firstBox()).toBeVisible();
+ reads("SSIM reads", "2026-01-01");
+ });
+
+ it("an empty field says nothing typed and makes no call", async () => {
+ const w = await open();
+ recorded.length = 0;
+ await w.user.clear(valueBox());
+ recorded.length = 0;
+ await w.user.clear(valueBox());
+ reads("SSIM reads", "nothing typed");
+ reads("Valid", "nothing typed");
+ reads("Pattern reads (ddMMMyy, fr-FR)", "nothing typed");
+ expect(reason("Reason for the read")).toHaveTextContent(READ_REASONS.empty);
+ expect(recorded.map((c) => c.name)).not.toContain("parseSsimDate");
+ expect(recorded.map((c) => c.name)).not.toContain("isValidSsimDate");
+ expect(recorded.map((c) => c.name)).not.toContain("parseDateWithPattern");
+ await expectNoAxeViolations(w.root);
+ });
+
+ it("a section left blank makes no call of its own", async () => {
+ await open({ value: "", date: "", window: "2000", locale: "en" });
+ const names = recorded.map((c) => c.name);
+ expect(names).not.toContain("parseSsimDate");
+ expect(names).not.toContain("isValidSsimDate");
+ expect(names).not.toContain("parseDateWithPattern");
+ expect(names).not.toContain("isValidDate");
+ // The month table's twelve probes are the only writes.
+ expect(names.filter((n) => n === "formatSsimDate")).toHaveLength(12);
+ reads("SSIM writes", "nothing typed");
+ reads("Reads back as", "nothing typed");
+ });
+});
+
+describe("the locale", () => {
+ it("feeds the comparison alone: a switch redraws section 2 and never calls the SSIM reader", async () => {
+ const w = await open({ value: "01ENE26", window: "2000", locale: "en" });
+ reads("SSIM reads", SIGNAL);
+ recorded.length = 0;
+ await w.user.selectOptions(localeSelect(), "es-ES");
+ const names = recorded.map((c) => c.name);
+ expect(names).not.toContain("parseSsimDate");
+ expect(names).not.toContain("isValidSsimDate");
+ expect(names).not.toContain("isValidDate");
+ expect(names).toContain("parseDateWithPattern");
+ expect(names).toContain("getLocaleMonthNames");
+ reads("SSIM reads", SIGNAL);
+ reads("Pattern reads (ddMMMyy, es-ES)", "2026-01-01");
+ expect(shown(DIFFERS_TEXT)).toHaveLength(1);
+ // The header and caption name no locale, so the stacked layout wraps them the same for
+ // `en` and `fr-FR` and the table holds one height.
+ expect(
+ screen.getByRole("columnheader", { name: "Short name" }),
+ ).toBeVisible();
+ expect(screen.queryByText(/es-ES short name/)).not.toBeInTheDocument();
+ await expectNoAxeViolations(w.root);
+ });
+
+ it("redraws the month table only when the locale changed", async () => {
+ const w = await open({ value: "01JAN26", window: "2000", locale: "en" });
+ recorded.length = 0;
+ await paste(w, valueBox(), "02JAN26");
+ expect(recorded.map((c) => c.name)).not.toContain("getLocaleMonthNames");
+ });
+
+ it("the call to the SSIM reader carries no locale", async () => {
+ await open();
+ const text = calls("the SSIM read").textContent ?? "";
+ expect(text).not.toContain("fr-FR");
+ expect(calls("the pattern and the table")).toHaveTextContent('"fr-FR"');
+ });
+});
+
+describe("the month table", () => {
+ it("shows the letters the library writes, month by month", async () => {
+ await open({ value: "01JAN26", window: "2000", locale: "en" });
+ const table = screen.getByRole("region", { name: /The twelve months/ });
+ const rows = within(table).getAllByRole("row").slice(1);
+ const want = monthTable(aviationLib, "en").rows;
+ expect(rows).toHaveLength(12);
+ rows.forEach((row, i) => {
+ expect(shown(want[i]!.letters!, row)).toHaveLength(1);
+ expect(shown(want[i]!.name!, row)).toHaveLength(1);
+ });
+ });
+
+ it("shows the locale's own names beside the same letters", async () => {
+ await open({ value: "01JAN26", window: "2000", locale: "es-ES" });
+ const table = screen.getByRole("region", { name: /The twelve months/ });
+ const first = within(table).getAllByRole("row")[1]!;
+ expect(shown("JAN", first)).toHaveLength(1);
+ expect(
+ shown(monthTable(aviationLib, "es-ES").rows[0]!.name!, first),
+ ).toHaveLength(1);
+ });
+});
+
+describe("the write", () => {
+ it("writes upper case and reads it back with the same window", async () => {
+ const w = await open();
+ reads("SSIM writes", "01JAN26");
+ reads("Reads back as", "2026-01-01");
+ expect(reason("Reason for the write")).toHaveTextContent(
+ WRITE_REASONS.written,
+ );
+ expect(calls("the write")).toHaveTextContent('formatSsimDate("2026-01-01"');
+ await expectNoAxeViolations(w.root);
+ });
+
+ it("refuses a year outside the window and says nothing was written", async () => {
+ const w = await open();
+ await w.user.selectOptions(preset(), "write-outside");
+ reads("SSIM writes", SIGNAL);
+ reads("Reads back as", NOT_WRITTEN);
+ expect(reason("Reason for the write")).toHaveTextContent(
+ WRITE_REASONS.outside,
+ );
+ await expectNoAxeViolations(w.root);
+ });
+
+ it("with no window the writer is refused, not outside", async () => {
+ const w = await open();
+ await w.user.selectOptions(preset(), "no-window");
+ await paste(w, dateBox(), "2026-01-01");
+ reads("SSIM writes", SIGNAL);
+ expect(reason("Reason for the write")).toHaveTextContent(
+ WRITE_REASONS.refused,
+ );
+ });
+
+ it("a date typed in section 3 does not redraw the read", async () => {
+ const w = await open();
+ recorded.length = 0;
+ await paste(w, dateBox(), "2026-12-31");
+ const names = recorded.map((c) => c.name);
+ expect(names).not.toContain("parseDateWithPattern");
+ expect(names).not.toContain("isValidSsimDate");
+ reads("SSIM writes", "31DEC26");
+ });
+});
+
+describe("holds", () => {
+ it("each reason hold draws every text it can show", async () => {
+ const w = await open();
+ for (const text of [
+ ...Object.values(READ_REASONS),
+ ...Object.values(WRITE_REASONS),
+ ]) {
+ expect(screen.getAllByText(text).length).toBeGreaterThan(0);
+ }
+ await expectNoAxeViolations(w.root);
+ });
+
+ it("the plates hold a ghost of every value they can show", async () => {
+ await open();
+ for (const text of ["nothing typed", SIGNAL, "valid", "not valid"]) {
+ expect(screen.getAllByText(text).length).toBeGreaterThan(0);
+ }
+ expect(screen.getAllByText(NOT_WRITTEN).length).toBeGreaterThan(0);
+ });
+});
+
+describe("the permalink", () => {
+ it("a preset links as that preset, and a typed value as its four strings", async () => {
+ const w = await open();
+ expect(decodeURIComponent(w.permalink())).toContain(
+ '"preset":"french-locale"',
+ );
+ await paste(w, valueBox(), "05MAR41");
+ const link = decodeURIComponent(w.permalink());
+ expect(link).toContain('"value":"05MAR41"');
+ expect(link).toContain('"window":"2000"');
+ expect(link).toContain('"locale":"fr-FR"');
+ });
+});
diff --git a/apps/dox/src/lib/ssim-date-reader-mount.ts b/apps/dox/src/lib/ssim-date-reader-mount.ts
new file mode 100644
index 000000000..b9ec1e8b7
--- /dev/null
+++ b/apps/dox/src/lib/ssim-date-reader-mount.ts
@@ -0,0 +1,673 @@
+/**
+ * The SSIM Date Reader widget (AV-97), mountable on its tool page and in the chat rail.
+ *
+ * Section 1 reads an IATA SSIM date (`DDMMMYY`) with `parseSsimDate` and `isValidSsimDate`,
+ * in the window the reader states. Section 2 puts the same text through the locale pattern
+ * parser beside a table of the SSIM month letters and the locale's own short names: a different
+ * function, used wrongly. Section 3 writes an ISO date back with `formatSsimDate`, in the same
+ * window. Everything on screen is a library call; the widget computes no date and holds no
+ * month-letter table (`ssim-date-reader.ts` builds the readings).
+ *
+ * Built on the component kit: `renderSsimDateReaderTemplate` writes the markup from builders
+ * only, with ids from `idScope(idPrefix)`, and `mount` finds its parts by those ids and
+ * delegates every listener on the widget with the mount's `signal`. Every region is laid out in
+ * every state and holds the widest of its texts, so typing never moves a plate, the badge, the
+ * reason line, the table or a calls frame.
+ *
+ * A refusal from the library reads NO SIGNAL (amber). The pattern parser's "no date" is the
+ * right answer from that function and stays neutral. A box nobody typed in makes no call and
+ * reads "nothing typed".
+ */
+import { defineElements } from "~/widgets/define";
+import {
+ badge,
+ codeFrame,
+ field,
+ findWidget,
+ hint,
+ html,
+ idScope,
+ plates,
+ section,
+ select,
+ setHtml,
+ table,
+ textInput,
+ widget,
+ type Plate,
+ type SafeHtml,
+} from "~/widgets/builders";
+import { heldText, type HeldState } from "~/widgets/families/holiday/held-text";
+import { holidayFrame } from "~/widgets/families/holiday/holiday-frame";
+import { reservedText } from "~/widgets/families/holiday/reserved-text";
+import {
+ SIGNAL_TEXT,
+ signalPlates,
+ type SignalPlate,
+} from "~/widgets/families/holiday/signal-plates";
+import { chips, type GmtChips } from "~/widgets/primitives/chips/chips";
+import { grow } from "~/widgets/primitives/grow/grow";
+import { preset, type GmtPreset } from "~/widgets/primitives/preset/preset";
+import styles from "~/widgets/tools/ssim-date-reader.module.css";
+import { loadAviationLib, type AviationLib } from "./aviation-lib";
+import { CONVERTER_LOCALES } from "./curated-timezones";
+import {
+ CUSTOM_PRESET_ID,
+ ISO_SAMPLE,
+ NOTHING_TYPED,
+ NO_DATE,
+ NO_NAME,
+ PATTERN,
+ PATTERN_LEAD,
+ READ_REASONS,
+ SSIM_PRESETS,
+ WRITE_NOTE,
+ WRITE_REASONS,
+ callsSizerText,
+ isSeeded,
+ matchPreset,
+ monthTable,
+ permalinkOf,
+ presetState,
+ readArgs,
+ readPattern,
+ readSsim,
+ writeSsim,
+ type CallsSection,
+ type MonthTable,
+ type PatternResult,
+ type ReadReasonKey,
+ type ReadResult,
+ type SsimArgs,
+ type SsimState,
+ type WriteReasonKey,
+ type WriteResult,
+} from "./ssim-date-reader";
+import { onceDestroy, WidgetLoadError, type MountFn } from "./widget-mount";
+
+export type { SsimArgs as SsimDateReaderArgs } from "./ssim-date-reader";
+
+const WIDGET_NAME = "ssim-date-reader";
+
+/** What the written-back plate reads while nothing has been written. */
+export const NOT_WRITTEN = "nothing written";
+
+/** The badge on the pattern plate when it disagrees with section 1. */
+export const DIFFERS_TEXT = "differs from SSIM";
+
+/** The words of the validity plate. */
+const VALID_WORD = "valid";
+const NOT_VALID_WORD = "not valid";
+
+/** The widest a written SSIM date reads (`26SEP26`'s length, seven characters). */
+const WIDEST_SSIM = "26SEP26";
+
+/** The widest month name any CLDR short name takes, for the table before a locale is read. */
+const FALLBACK_NAME = "sept.";
+
+const WINDOW_ITEMS = [
+ { value: "fixed", label: "Fixed from" },
+ { value: "rolling", label: "Rolling" },
+] as const;
+
+// ---------------------------------------------------------------------------
+// Held texts
+// ---------------------------------------------------------------------------
+
+const READ_REASON_TEXTS = Object.values(READ_REASONS);
+const WRITE_REASON_TEXTS = Object.values(WRITE_REASONS);
+
+const SECTION_LABELS: Record = {
+ read: "the SSIM read",
+ pattern: "the pattern and the table",
+ write: "the write",
+};
+
+function readReasonState(key: ReadReasonKey): HeldState {
+ return key === "read" || key === "empty" ? "note" : "sentinel";
+}
+
+function writeReasonState(key: WriteReasonKey): HeldState {
+ return key === "outside" || key === "refused" ? "sentinel" : "note";
+}
+
+function readReasonOf(key: ReadReasonKey): SafeHtml {
+ return heldText({
+ label: "Reason for the read",
+ text: READ_REASONS[key],
+ state: readReasonState(key),
+ sizers: READ_REASON_TEXTS,
+ gate: "hold",
+ });
+}
+
+function writeReasonOf(key: WriteReasonKey): SafeHtml {
+ return heldText({
+ label: "Reason for the write",
+ text: WRITE_REASONS[key],
+ state: writeReasonState(key),
+ sizers: WRITE_REASON_TEXTS,
+ gate: "hold",
+ });
+}
+
+// ---------------------------------------------------------------------------
+// Plates
+// ---------------------------------------------------------------------------
+
+/** A library result as a plate value: its date, NO SIGNAL for a refusal, or nothing typed. */
+function dateOrSignal(blank: boolean, value: string | null): string | null {
+ return blank ? NOTHING_TYPED : value;
+}
+
+function readPlates(r: ReadResult): SafeHtml {
+ const list: SignalPlate[] = [
+ {
+ caption: "SSIM reads",
+ value: dateOrSignal(r.blank, r.ssim),
+ line: "parseSsimDate",
+ lineSamples: ["parseSsimDate"],
+ series: 1,
+ samples: [ISO_SAMPLE, NOTHING_TYPED],
+ },
+ {
+ caption: "Valid",
+ value: r.blank ? NOTHING_TYPED : r.valid ? VALID_WORD : NOT_VALID_WORD,
+ line: "isValidSsimDate",
+ lineSamples: ["isValidSsimDate"],
+ series: 2,
+ samples: [VALID_WORD, NOT_VALID_WORD, NOTHING_TYPED],
+ },
+ ];
+ return signalPlates(list, { gate: "hero" });
+}
+
+function writePlates(w: WriteResult): SafeHtml {
+ const written = w.written !== null;
+ const list: SignalPlate[] = [
+ {
+ caption: "SSIM writes",
+ value: dateOrSignal(w.blank, w.written),
+ line: "formatSsimDate",
+ lineSamples: ["formatSsimDate"],
+ series: 1,
+ samples: [WIDEST_SSIM, NOTHING_TYPED],
+ },
+ {
+ caption: "Reads back as",
+ value: w.blank ? NOTHING_TYPED : written ? w.back : NOT_WRITTEN,
+ line: "parseSsimDate",
+ lineSamples: ["parseSsimDate"],
+ series: 2,
+ samples: [ISO_SAMPLE, NOTHING_TYPED, NOT_WRITTEN],
+ },
+ ];
+ return signalPlates(list, { gate: "write-plates" });
+}
+
+/** Every locale the caption can name, so the pattern plate holds the widest caption. */
+function captionOf(locale: string): string {
+ return `Pattern reads (${PATTERN}, ${locale})`;
+}
+
+function localeList(locale: string): string[] {
+ const list: string[] = [...CONVERTER_LOCALES];
+ return list.includes(locale) ? list : [...list, locale];
+}
+
+function patternPlate(p: PatternResult, locale: string): SafeHtml {
+ const list: Plate[] = [
+ {
+ caption: captionOf(locale),
+ captions: localeList(locale).map(captionOf),
+ value: p.date === undefined ? NOTHING_TYPED : (p.date ?? NO_DATE),
+ lines: ["parseDateWithPattern"],
+ lineSamples: [["parseDateWithPattern"]],
+ series: 3,
+ samples: [ISO_SAMPLE, NO_DATE, NOTHING_TYPED],
+ },
+ ];
+ return plates(list, { gate: "pattern-plate" });
+}
+
+/**
+ * The badge slot: the badge always takes its room (a hidden twin), and shows only when the
+ * pattern parser disagrees with section 1. Its accent is a bottom edge, never a left one.
+ */
+function differsOf(on: boolean): SafeHtml {
+ const mark = badge({ text: DIFFERS_TEXT, tone: "neutral" });
+ return html`${on ? html`${mark}` : ""}${mark}
`;
+}
+
+// ---------------------------------------------------------------------------
+// The month table
+// ---------------------------------------------------------------------------
+
+type ColumnKey = "month" | "letters" | "name";
+
+// The header and the caption name no locale: in the stacked layout the header becomes each
+// cell's label and the caption is a block, so a longer locale code (`fr-FR`) wrapped onto a
+// second line and `en` did not, moving everything below by 12 rows. The Locale select names it.
+function columnsOf() {
+ return [
+ { key: "month", header: "Month", align: "start", numeric: true },
+ { key: "letters", header: "SSIM letters", align: "start", numeric: false },
+ {
+ key: "name",
+ header: "Short name",
+ align: "start",
+ numeric: false,
+ },
+ ] as const;
+}
+
+function monthCell(
+ text: string | null,
+ samples: readonly string[],
+ absent: string,
+ signal: boolean,
+): SafeHtml {
+ return html`${reservedText({
+ text: text ?? (signal ? SIGNAL_TEXT : absent),
+ state: text === null && signal ? "signal" : "live",
+ samples: [...samples, SIGNAL_TEXT, absent],
+ })}`;
+}
+
+function monthsOf(t: MonthTable | null): SafeHtml {
+ const widest = t === null || t.widest === "" ? FALLBACK_NAME : t.widest;
+ const rows = (
+ t?.rows ??
+ Array.from({ length: 12 }, (_, i) => ({
+ month: String(i + 1).padStart(2, "0"),
+ letters: null,
+ name: null,
+ }))
+ ).map((row) => ({
+ month: row.month,
+ letters: monthCell(row.letters, ["SEP"], NO_NAME, t !== null),
+ name: monthCell(row.name, [widest], NO_NAME, false),
+ }));
+ return html`${table({
+ caption: `The twelve months: SSIM letters from formatSsimDate in the window 2000, and the short names of the chosen locale`,
+ columns: columnsOf(),
+ rows,
+ rowHeader: "month",
+ layout: "fixed",
+ widths: ["16%", "28%"],
+ labelCells: true,
+ gate: "grid",
+ })}
`;
+}
+
+// ---------------------------------------------------------------------------
+// Calls frames
+// ---------------------------------------------------------------------------
+
+const SIZER_LINES: Record = {
+ read: callsSizerText("read").split("\n").length,
+ pattern: callsSizerText("pattern").split("\n").length,
+ write: callsSizerText("write").split("\n").length,
+};
+
+function callsOf(which: CallsSection, text: string): SafeHtml {
+ return codeFrame({
+ label: `Calls made for ${SECTION_LABELS[which]}`,
+ copyLabel: `Copy the calls for ${SECTION_LABELS[which]}`,
+ copyText: text,
+ code: html`${text}`,
+ gate: "codeframe",
+ // The widest reading prints every call; the frame holds that many lines.
+ minLines: SIZER_LINES[which],
+ });
+}
+
+function callsSlot(id: string, which: CallsSection): SafeHtml {
+ return grow(
+ html`${callsOf(which, "")}
`,
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Template
+// ---------------------------------------------------------------------------
+
+function localeOptions(locale: string): { value: string; label: string }[] {
+ return localeList(locale).map((l) => ({ value: l, label: l }));
+}
+
+const blankRead: ReadResult = {
+ blank: true,
+ ssim: null,
+ valid: null,
+ reason: "empty",
+ calls: [],
+};
+
+const blankWrite: WriteResult = {
+ blank: true,
+ written: null,
+ back: null,
+ reason: "empty",
+ calls: [],
+};
+
+const blankPattern: PatternResult = {
+ date: undefined,
+ differs: false,
+ calls: [],
+};
+
+/**
+ * The widget's chrome, seeded with `args` so the first paint shows them. With no args it shows
+ * the first preset. The readings are drawn blank here, without the library; `mount` draws every
+ * result.
+ */
+export function renderSsimDateReaderTemplate(
+ idPrefix: string,
+ args: SsimArgs = {},
+): SafeHtml {
+ const id = idScope(idPrefix);
+ const state = isSeeded(args) ? readArgs(args) : presetState(SSIM_PRESETS[0]!);
+ const rolling = state.mode === "rolling";
+
+ const readSection = section(
+ { id: id("read"), heading: "1. Read an SSIM date", level: 3 },
+ html`${preset({
+ id: id("preset"),
+ label: "Preset",
+ value: matchPreset(state),
+ options: [
+ { value: CUSTOM_PRESET_ID, label: "Custom", description: "" },
+ ...SSIM_PRESETS.map((p) => ({
+ value: p.id,
+ label: p.label,
+ description: p.description,
+ })),
+ ],
+ })}
${field({
+ id: id("value"),
+ label: "SSIM date",
+ control: ({ id: cid, describedBy }) =>
+ textInput({
+ id: cid,
+ value: state.value,
+ autocomplete: "off",
+ spellcheck: false,
+ maxLength: 16,
+ describedBy,
+ }),
+ })}
${chips({
+ legend: "Window",
+ kind: "radio",
+ name: id("window"),
+ items: WINDOW_ITEMS.map((i) => ({
+ ...i,
+ checked: i.value === (rolling ? "rolling" : "fixed"),
+ })),
+ })}
${field(
+ {
+ id: id("first"),
+ label: "First year",
+ hint: hint(
+ id("first-hint"),
+ "The first of the hundred years a two-digit year can mean.",
+ ),
+ control: ({ id: cid, describedBy }) =>
+ textInput({
+ id: cid,
+ value: state.first,
+ inputMode: "numeric",
+ autocomplete: "off",
+ spellcheck: false,
+ maxLength: 6,
+ describedBy,
+ }),
+ },
+ )}
${field({
+ id: id("locale"),
+ label: "Locale",
+ hint: hint(
+ id("locale-hint"),
+ "Feeds only the comparison below. parseSsimDate takes no locale.",
+ ),
+ control: ({ id: cid, describedBy }) =>
+ select({
+ id: cid,
+ value: state.locale,
+ options: localeOptions(state.locale),
+ describedBy,
+ }),
+ })}
${holidayFrame(
+ html`${readPlates(blankRead)}
${readReasonOf("empty")}
`,
+ { gate: "frame" },
+ )}${callsSlot(id("read-calls"), "read")}`,
+ );
+
+ const patternSection = section(
+ {
+ id: id("pattern"),
+ heading: "2. The same text through a locale pattern",
+ level: 3,
+ },
+ html`${PATTERN_LEAD}
${holidayFrame(
+ html`${patternPlate(blankPattern, state.locale)}
${differsOf(false)}
${monthsOf(null)}
`,
+ { gate: "frame" },
+ )}${callsSlot(id("pattern-calls"), "pattern")}`,
+ );
+
+ const writeSection = section(
+ { id: id("write"), heading: "3. Write a date back", level: 3 },
+ html`${field({
+ id: id("date"),
+ label: "ISO date",
+ hint: hint(id("date-hint"), WRITE_NOTE),
+ control: ({ id: cid, describedBy }) =>
+ textInput({
+ id: cid,
+ value: state.date,
+ autocomplete: "off",
+ spellcheck: false,
+ maxLength: 32,
+ describedBy,
+ }),
+ })}
${holidayFrame(
+ html`${writePlates(blankWrite)}
${writeReasonOf("empty")}
`,
+ { gate: "frame" },
+ )}${callsSlot(id("write-calls"), "write")}`,
+ );
+
+ return widget(
+ { name: WIDGET_NAME, label: "SSIM Date Reader", scope: idPrefix },
+ html`${readSection}${patternSection}${writeSection}`,
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Wiring
+// ---------------------------------------------------------------------------
+
+interface Controller {
+ readState(): SsimState;
+ apply(state: SsimState): void;
+}
+
+/** Which sections a change redraws. A locale change redraws section 2 alone. */
+type Scope = "all" | "locale" | "date";
+
+function setupWidget(
+ root: HTMLElement,
+ lib: AviationLib,
+ signal: AbortSignal,
+ initial: SsimState,
+): Controller {
+ const { el: widgetEl, part: el } = findWidget(root, WIDGET_NAME);
+ const valueEl = el("value");
+ const firstEl = el("first");
+ const localeEl = el("locale");
+ const dateEl = el("date");
+ const presetEl = el("preset").closest("gmt-preset")!;
+ const windowEl = el("window-slot").querySelector("gmt-chips")!;
+
+ let state: SsimState = initial;
+ let lastRead: ReadResult = blankRead;
+ /** The locale the month table was last drawn for. */
+ let drawnLocale = "";
+ let months: MonthTable | null = null;
+
+ function syncControls(): void {
+ valueEl.value = state.value;
+ firstEl.value = state.first;
+ dateEl.value = state.date;
+ windowEl.value = state.mode;
+ el("first-field").hidden = state.mode === "rolling";
+ if (![...localeEl.options].some((o) => o.value === state.locale)) {
+ const opt = localeEl.ownerDocument.createElement("option");
+ opt.value = state.locale;
+ opt.textContent = state.locale;
+ localeEl.append(opt);
+ }
+ localeEl.value = state.locale;
+ }
+
+ function drawRead(): void {
+ lastRead = readSsim(lib, state);
+ setHtml(el("read-plates"), readPlates(lastRead));
+ setHtml(el("read-reason"), readReasonOf(lastRead.reason));
+ setHtml(el("read-calls"), callsOf("read", lastRead.calls.join("\n")));
+ }
+
+ function drawPattern(): void {
+ const pattern = readPattern(lib, state, lastRead);
+ if (drawnLocale !== state.locale) {
+ drawnLocale = state.locale;
+ months = monthTable(lib, state.locale);
+ setHtml(el("months"), monthsOf(months));
+ }
+ setHtml(el("pattern-plate"), patternPlate(pattern, state.locale));
+ setHtml(el("differs"), differsOf(pattern.differs));
+ setHtml(
+ el("pattern-calls"),
+ callsOf(
+ "pattern",
+ [...pattern.calls, ...(months?.calls ?? [])].join("\n"),
+ ),
+ );
+ }
+
+ function drawWrite(): void {
+ const write = writeSsim(lib, state);
+ setHtml(el("write-plates"), writePlates(write));
+ setHtml(el("write-reason"), writeReasonOf(write.reason));
+ setHtml(el("write-calls"), callsOf("write", write.calls.join("\n")));
+ }
+
+ function draw(scope: Scope): void {
+ presetEl.value = matchPreset(state);
+ if (scope === "all") {
+ drawRead();
+ drawPattern();
+ drawWrite();
+ } else if (scope === "locale") {
+ drawPattern();
+ } else {
+ drawWrite();
+ }
+ }
+
+ widgetEl.addEventListener(
+ "input",
+ (e) => {
+ const target = e.target;
+ if (target === valueEl) {
+ state.value = valueEl.value;
+ draw("all");
+ } else if (target === firstEl) {
+ state.first = firstEl.value;
+ draw("all");
+ } else if (target === dateEl) {
+ state.date = dateEl.value;
+ draw("date");
+ }
+ },
+ { signal },
+ );
+
+ widgetEl.addEventListener(
+ "change",
+ (e) => {
+ const target = e.target;
+ if (target === localeEl) {
+ state.locale = localeEl.value;
+ draw("locale");
+ } else if (target === presetEl) {
+ const chosen = SSIM_PRESETS.find((p) => p.id === presetEl.value);
+ // Custom keeps what is typed.
+ if (chosen) apply(presetState(chosen));
+ } else if (
+ target instanceof Element &&
+ target.closest("gmt-chips") === windowEl
+ ) {
+ const mode = windowEl.value === "rolling" ? "rolling" : "fixed";
+ if (mode === state.mode) return;
+ state.mode = mode;
+ el("first-field").hidden = mode === "rolling";
+ draw("all");
+ }
+ },
+ { signal },
+ );
+
+ function apply(next: SsimState): void {
+ state = next;
+ syncControls();
+ draw("all");
+ }
+
+ apply(state);
+
+ return { readState: () => state, apply };
+}
+
+export const mountSsimDateReader: MountFn = async (
+ root,
+ args,
+ signal,
+) => {
+ defineElements();
+ let lib: AviationLib;
+ try {
+ lib = await loadAviationLib();
+ } catch (cause) {
+ // Loud, not inert: the host decides what to show (see `WidgetLoadError`).
+ throw cause instanceof WidgetLoadError ? cause : new WidgetLoadError(cause);
+ }
+ if (signal.aborted) return onceDestroy(() => {});
+
+ // One draw, of what the reader asked for: no stray call for a preset that is never shown.
+ const controller = setupWidget(
+ root,
+ lib,
+ signal,
+ isSeeded(args) ? readArgs(args) : presetState(SSIM_PRESETS[0]!),
+ );
+
+ return onceDestroy(
+ () => {},
+ () => permalinkOf(controller.readState()),
+ );
+};
diff --git a/apps/dox/src/lib/ssim-date-reader.test.ts b/apps/dox/src/lib/ssim-date-reader.test.ts
new file mode 100644
index 000000000..0d0940b14
--- /dev/null
+++ b/apps/dox/src/lib/ssim-date-reader.test.ts
@@ -0,0 +1,404 @@
+/**
+ * The SSIM Date Reader's pure half, against the real library in `dist`: every preset's
+ * outputs, a reason for each row of the reason table, the permalink and the chat seed.
+ */
+import { aviationLib } from "~/test/aviation-lib";
+import {
+ CUSTOM_PRESET_ID,
+ MONTH_COUNT,
+ READ_REASONS,
+ SSIM_PRESETS,
+ WRITE_REASONS,
+ blankState,
+ buildModel,
+ callsSizerText,
+ isSeeded,
+ matchPreset,
+ monthTable,
+ optionsOf,
+ permalinkOf,
+ presetState,
+ readArgs,
+ readSsim,
+ writeSsim,
+ type SsimState,
+} from "./ssim-date-reader";
+
+const state = (over: Partial): SsimState => ({
+ ...blankState(),
+ ...over,
+});
+
+const preset = (id: string) => {
+ const found = SSIM_PRESETS.find((p) => p.id === id);
+ if (found === undefined) throw new Error(`no preset ${id}`);
+ return found;
+};
+
+/** What the library and the browser-checked locale data give for each preset. */
+const EXPECTED = {
+ "french-locale": ["2026-01-01", "read", null, true, "01JAN26", "2026-01-01"],
+ "english-locale": ["2026-01-01", "read", "2026-01-01", false, null, null],
+ "turkish-locale": ["2026-10-25", "read", null, true, null, null],
+ "lower-case": [null, "lowerCase", "2026-01-01", true, null, null],
+ "spanish-locale": [null, "shape", "2026-01-01", true, null, null],
+ archive: ["2009-12-16", "read", "2009-12-16", false, null, null],
+ "leap-2000": ["2000-02-29", "read", "2000-02-29", false, null, null],
+ "leap-1900": [null, "noSuchDay", null, false, null, null],
+ "no-window": [null, "noWindow", null, false, null, null],
+ "write-outside": ["2026-01-01", "read", "2026-01-01", false, null, null],
+} as const;
+
+describe("the presets, against the library", () => {
+ it.each(Object.entries(EXPECTED))(
+ "%s gives its outputs",
+ (id, [ssim, reason, pattern, differs, written, back]) => {
+ const model = buildModel(aviationLib, presetState(preset(id)));
+ expect(model.read.ssim).toBe(ssim);
+ expect(model.read.reason).toBe(reason);
+ expect(model.read.valid).toBe(ssim !== null);
+ expect(model.pattern.date).toBe(pattern);
+ expect(model.pattern.differs).toBe(differs);
+ expect(model.write.written).toBe(written);
+ expect(model.write.back).toBe(back);
+ },
+ );
+
+ it("the opening preset shows a difference before anything is touched", () => {
+ expect(SSIM_PRESETS[0]!.id).toBe("french-locale");
+ const model = buildModel(aviationLib, presetState(SSIM_PRESETS[0]!));
+ expect(model.read.ssim).toBe("2026-01-01");
+ expect(model.pattern.differs).toBe(true);
+ });
+
+ it("the write-outside preset is refused for the window, not the calendar", () => {
+ const model = buildModel(aviationLib, presetState(preset("write-outside")));
+ expect(model.write.written).toBeNull();
+ expect(model.write.reason).toBe("outside");
+ });
+
+ it("the rolling preset reads the text with a rolling window", () => {
+ const options = optionsOf(presetState(preset("rolling")));
+ expect(options).toEqual({ yearWindow: "rolling" });
+ expect(
+ readSsim(aviationLib, presetState(preset("rolling"))).calls[0],
+ ).toContain('"rolling"');
+ });
+
+ it("no preset uses an out-of-scope form", () => {
+ for (const p of SSIM_PRESETS) {
+ expect(p.value).not.toMatch(/X/);
+ expect(p.value).toMatch(/^\d{2}[A-Za-z]{3}\d{2}$/);
+ }
+ });
+
+ it("each preset matches itself", () => {
+ for (const p of SSIM_PRESETS) {
+ expect(matchPreset(presetState(p))).toBe(p.id);
+ }
+ expect(matchPreset(state({ value: "x" }))).toBe(CUSTOM_PRESET_ID);
+ });
+});
+
+describe("the read", () => {
+ it("makes no call for an empty field", () => {
+ const read = readSsim(aviationLib, blankState());
+ expect(read.blank).toBe(true);
+ expect(read.calls).toEqual([]);
+ expect(read.valid).toBeNull();
+ });
+
+ it("never upper-cases the typed text before a call", () => {
+ const read = readSsim(
+ aviationLib,
+ state({ value: "01jan26", first: "2000" }),
+ );
+ expect(read.calls[0]).toContain('parseSsimDate("01jan26"');
+ expect(read.reason).toBe("lowerCase");
+ });
+
+ it("a blank window is the library's refusal with its own reason, never a default", () => {
+ const read = readSsim(aviationLib, state({ value: "01JAN26" }));
+ expect(read.ssim).toBeNull();
+ expect(read.reason).toBe("noWindow");
+ expect(read.calls[0]).toBe('parseSsimDate("01JAN26", {}); // ""');
+ });
+
+ it("a non-integer first year sends no window", () => {
+ expect(optionsOf(state({ first: "20x0" }))).toEqual({});
+ expect(optionsOf(state({ first: " 2000 " }))).toEqual({ yearWindow: 2000 });
+ });
+
+ it("gives a reason for each row of the reason table", () => {
+ const seen = new Set();
+ const cases: [SsimState, string][] = [
+ [blankState(), "empty"],
+ [state({ value: "01JAN26" }), "noWindow"],
+ [state({ value: "01JAN26", first: "10000" }), "badWindow"],
+ [state({ value: "01jan26", first: "2000" }), "lowerCase"],
+ [state({ value: "31APR26", first: "2000" }), "noSuchDay"],
+ [state({ value: "1JAN26", first: "2000" }), "shape"],
+ [state({ value: "01JAN26", first: "2000" }), "read"],
+ ];
+ for (const [s, key] of cases) {
+ const r = readSsim(aviationLib, s);
+ expect(r.reason).toBe(key);
+ seen.add(r.reason);
+ }
+ expect([...seen].sort()).toEqual(Object.keys(READ_REASONS).sort());
+ });
+
+ // Each reason is decided by hand from the grammar and the window rule (a first year is an
+ // integer from 0 to 9900), never read from the probes under test.
+ it.each`
+ value | first | reason | why
+ ${"31APR26"} | ${"2000"} | ${"noSuchDay"} | ${"April has 30 days"}
+ ${"30FEB26"} | ${"2000"} | ${"noSuchDay"} | ${"February never has 30 days"}
+ ${"29FEB25"} | ${"2000"} | ${"noSuchDay"} | ${"2025 is not a leap year"}
+ ${"29FEB00"} | ${"1900"} | ${"noSuchDay"} | ${"1900 is not a leap year"}
+ ${"29FEB00"} | ${"1800"} | ${"noSuchDay"} | ${"00 reads as 1900 in a window from 1800"}
+ ${"30FEB00"} | ${"1900"} | ${"noSuchDay"} | ${"February never has 30 days"}
+ ${"00JAN26"} | ${"2000"} | ${"noSuchDay"} | ${"there is no day 0"}
+ ${"32JAN26"} | ${"2000"} | ${"noSuchDay"} | ${"January has 31 days"}
+ ${"01JAN26"} | ${"10000"} | ${"badWindow"} | ${"a first year above 9900"}
+ ${"01JAN26"} | ${"9901"} | ${"badWindow"} | ${"a first year above 9900"}
+ ${"01JAN26"} | ${"-1"} | ${"badWindow"} | ${"a first year below 0"}
+ ${"01JAN00"} | ${"-1"} | ${"badWindow"} | ${"the window probe's own text"}
+ ${"31APR26"} | ${"-1"} | ${"badWindow"} | ${"the window is named before the day"}
+ ${"01jan26"} | ${"10000"} | ${"badWindow"} | ${"the window is named before the case"}
+ ${"01jan26"} | ${"2000"} | ${"lowerCase"} | ${"lower case"}
+ ${"31apr26"} | ${"2000"} | ${"shape"} | ${"lower case, and upper-cased it names no day"}
+ ${"abJAN26"} | ${"2000"} | ${"shape"} | ${"no digits of day to swap"}
+ ${"01ENE26"} | ${"2000"} | ${"shape"} | ${"ENE is not a month code"}
+ ${"1JAN26"} | ${"2000"} | ${"shape"} | ${"one digit of day"}
+ `(
+ "names $reason for '$value' from $first: $why",
+ ({ value, first, reason }) => {
+ expect(readSsim(aviationLib, state({ value, first })).reason).toBe(
+ reason,
+ );
+ },
+ );
+
+ it("prints each probe it runs, and none whose text is the typed text", () => {
+ expect(
+ readSsim(aviationLib, state({ value: "31APR26", first: "2000" })).calls,
+ ).toEqual([
+ 'parseSsimDate("31APR26", { yearWindow: 2000 }); // ""',
+ 'isValidSsimDate("31APR26", { yearWindow: 2000 }); // false',
+ 'parseSsimDate("01JAN00", { yearWindow: 2000 }); // "2000-01-01"',
+ 'parseSsimDate("01APR26", { yearWindow: 2000 }); // "2026-04-01"',
+ ]);
+ expect(
+ readSsim(aviationLib, state({ value: "01JAN00", first: "-1" })).calls,
+ ).toHaveLength(2);
+ });
+
+ it("the widest printed read is a path the library can take", () => {
+ const widest = callsSizerText("read").split("\n").length;
+ const real = readSsim(
+ aviationLib,
+ state({ value: "31apr26", first: "2000" }),
+ );
+ expect(real.calls).toHaveLength(widest);
+ });
+
+ it("valid is true exactly when the read gives a date", () => {
+ for (const p of SSIM_PRESETS) {
+ const r = readSsim(aviationLib, presetState(p));
+ expect(r.valid).toBe(r.ssim !== null);
+ }
+ });
+});
+
+describe("the pattern and the table", () => {
+ it("makes no call while nothing is typed", () => {
+ const m = buildModel(aviationLib, blankState());
+ expect(m.pattern.date).toBeUndefined();
+ expect(m.pattern.calls).toEqual([]);
+ });
+
+ it("no SSIM call carries a locale", () => {
+ for (const p of SSIM_PRESETS) {
+ const m = buildModel(aviationLib, presetState(p));
+ for (const call of [...m.read.calls, ...m.write.calls]) {
+ if (call.startsWith("parseDateWithPattern")) continue;
+ expect(call).not.toContain(p.locale);
+ }
+ expect(m.pattern.calls.join("")).toContain(`"${p.locale}"`);
+ }
+ });
+
+ it("the SSIM reading does not move with the locale", () => {
+ const base = presetState(preset("french-locale"));
+ const first = readSsim(aviationLib, base).ssim;
+ for (const locale of ["en", "de-DE", "es-ES", "tr-TR", "ja-JP"]) {
+ expect(readSsim(aviationLib, { ...base, locale }).ssim).toBe(first);
+ }
+ });
+
+ it("the month letters come from the library, one per month", () => {
+ const table = monthTable(aviationLib, "en");
+ expect(table.rows).toHaveLength(MONTH_COUNT);
+ expect(table.rows.map((r) => r.letters)).toEqual([
+ "JAN",
+ "FEB",
+ "MAR",
+ "APR",
+ "MAY",
+ "JUN",
+ "JUL",
+ "AUG",
+ "SEP",
+ "OCT",
+ "NOV",
+ "DEC",
+ ]);
+ expect(table.rows[0]!.name).toBe("Jan");
+ expect(table.calls.at(-1)).toContain("getLocaleMonthNames");
+ });
+
+ it("the letters do not change with the locale, the names do", () => {
+ const en = monthTable(aviationLib, "en");
+ const es = monthTable(aviationLib, "es-ES");
+ expect(es.rows.map((r) => r.letters)).toEqual(
+ en.rows.map((r) => r.letters),
+ );
+ expect(es.rows[0]!.name).not.toBe(en.rows[0]!.name);
+ expect(es.widest.length).toBeGreaterThan(0);
+ });
+});
+
+describe("the write", () => {
+ it("makes no call for an empty date", () => {
+ const w = writeSsim(aviationLib, blankState());
+ expect(w.blank).toBe(true);
+ expect(w.calls).toEqual([]);
+ });
+
+ it("has a reason for each row of the reason table", () => {
+ const outside = writeSsim(
+ aviationLib,
+ state({ date: "1999-12-31", first: "2000" }),
+ );
+ const refused = writeSsim(
+ aviationLib,
+ state({ date: "2026-02-30", first: "2000" }),
+ );
+ const written = writeSsim(
+ aviationLib,
+ state({ date: "2026-01-01", first: "2000" }),
+ );
+ const none = writeSsim(aviationLib, state({ date: "2026-01-01" }));
+ expect(outside.reason).toBe("outside");
+ expect(refused.reason).toBe("refused");
+ expect(written.reason).toBe("written");
+ expect(none.reason).toBe("refused");
+ expect(blankWrite().reason).toBe("empty");
+ expect(
+ new Set(
+ [outside, refused, written, none, blankWrite()].map((w) => w.reason),
+ ),
+ ).toEqual(new Set(Object.keys(WRITE_REASONS)));
+ });
+
+ it("reads the written date back with the same window", () => {
+ const w = writeSsim(
+ aviationLib,
+ state({ date: "2026-01-01", first: "2000" }),
+ );
+ expect(w.written).toBe("01JAN26");
+ expect(w.back).toBe("2026-01-01");
+ expect(w.calls).toHaveLength(2);
+ });
+
+ it("with no window says it is refused, not outside", () => {
+ const w = writeSsim(aviationLib, state({ date: "2026-01-01" }));
+ expect(w.written).toBeNull();
+ expect(w.back).toBeNull();
+ expect(w.calls).toHaveLength(1);
+ });
+});
+
+function blankWrite() {
+ return writeSsim(aviationLib, blankState());
+}
+
+describe("the permalink and the chat seed", () => {
+ it("a preset's state links as that preset alone", () => {
+ for (const p of SSIM_PRESETS) {
+ expect(permalinkOf(presetState(p))).toEqual({ preset: p.id });
+ }
+ });
+
+ it("a custom state links as four strings and reads back as itself", () => {
+ const cases: SsimState[] = [
+ state({
+ value: "05MAR41",
+ first: "1990",
+ locale: "de-DE",
+ date: "2041-03-05",
+ }),
+ state({ value: "", first: "", locale: "en", date: "" }),
+ state({ value: "05MAR41", mode: "rolling", locale: "en" }),
+ state({ value: "05MAR41", first: "", locale: "en" }),
+ ];
+ for (const s of cases) {
+ const link = permalinkOf(s) as Record;
+ expect(readArgs(link)).toEqual(s);
+ }
+ });
+
+ it("a cleared value survives the link", () => {
+ const s = state({ value: "", first: "2000", locale: "en" });
+ const link = permalinkOf(s) as Record;
+ expect(link.value).toBe("");
+ expect(readArgs(link).value).toBe("");
+ });
+
+ it("a preset id in a link seeds the preset, and a named field wins", () => {
+ expect(readArgs({ preset: "archive" })).toEqual(
+ presetState(preset("archive")),
+ );
+ expect(readArgs({ preset: "archive", value: "01JAN50" }).value).toBe(
+ "01JAN50",
+ );
+ expect(readArgs({ preset: "nope" })).toEqual(blankState());
+ });
+
+ it("a chat call with no window opens with the window blank", () => {
+ const s = readArgs({ value: "01JAN26", locale: "fr-FR" });
+ expect(s.mode).toBe("fixed");
+ expect(s.first).toBe("");
+ expect(optionsOf(s)).toEqual({});
+ expect(buildModel(aviationLib, s).read.reason).toBe("noWindow");
+ });
+
+ it("a chat window is read as given, a number or a word", () => {
+ expect(readArgs({ window: 2000 }).first).toBe("2000");
+ expect(readArgs({ window: "rolling" }).mode).toBe("rolling");
+ expect(readArgs({ window: "1950" }).first).toBe("1950");
+ });
+
+ it("a blank locale falls back to the default, never to the machine's", () => {
+ const fallback = blankState().locale;
+ expect(readArgs({ value: "x", locale: " " }).locale).toBe(fallback);
+ expect(fallback).toBe("en");
+ });
+
+ it("no args seed nothing", () => {
+ expect(isSeeded({})).toBe(false);
+ expect(isSeeded({ date: "" })).toBe(true);
+ });
+});
+
+describe("the printed calls", () => {
+ it("each section's widest text prints every call it can make", () => {
+ // The read, the validator, and the window, case and day probes.
+ expect(callsSizerText("read").split("\n").length).toBe(5);
+ expect(callsSizerText("pattern").split("\n").length).toBe(
+ 1 + MONTH_COUNT + 1,
+ );
+ expect(callsSizerText("write").split("\n").length).toBe(2);
+ });
+});
diff --git a/apps/dox/src/lib/ssim-date-reader.ts b/apps/dox/src/lib/ssim-date-reader.ts
new file mode 100644
index 000000000..afdad421f
--- /dev/null
+++ b/apps/dox/src/lib/ssim-date-reader.ts
@@ -0,0 +1,646 @@
+/**
+ * Pure helpers for the SSIM Date Reader (AV-97).
+ *
+ * The reader types an IATA SSIM date (`DDMMMYY`, such as `01JAN26`), states the window a
+ * two-digit year is read in, and picks a locale. Section 1 reads the date with
+ * `parseSsimDate`. Section 2 puts the same text through `parseDateWithPattern` with the
+ * locale's own month names, beside a twelve-month table of the SSIM letters and the
+ * locale's short names. Section 3 writes an ISO date back with `formatSsimDate`. Every date
+ * and every month letter on screen is a library result; this module holds the state, the
+ * presets, the arguments a link or the chat can seed, the reasons and the printed calls.
+ *
+ * No DOM. Anything that reads the library takes an `AviationLib` as its first argument. The
+ * module holds no month-letter table and never inspects the typed text to decide a reason:
+ * a reason is the state, a preset's own flag or one more library call. The locale reaches
+ * `parseDateWithPattern` and `getLocaleMonthNames` only; no `parseSsimDate` call takes it.
+ */
+import type { AviationLib, YearWindowOptions } from "./aviation-lib";
+import { literal } from "./holiday-rule-builder";
+
+/** The locale the tool opens with when a link or the chat names none. */
+export const DEFAULT_LOCALE = "en";
+
+/** The pattern the locale parser reads the same text with. */
+export const PATTERN = "ddMMMyy";
+
+/** The window the month table's SSIM letters are probed in; any hundred years would do. */
+export const PROBE_WINDOW = 2000;
+
+/** The year the month table's probes are dated in, inside the probe window. */
+const PROBE_YEAR = 2026;
+
+/** The number of months in the table. */
+export const MONTH_COUNT = 12;
+
+/** What a plate reads while nothing has been typed: an empty field is not a refusal. */
+export const NOTHING_TYPED = "nothing typed";
+
+/** What the pattern plate reads when the locale parser returned no date. */
+export const NO_DATE = "no date";
+
+/** What a month cell reads when the locale gave no name. */
+export const NO_NAME = "no name";
+
+/** The widest ISO date a plate shows (`2026-01-01`), the plates' reserved width. */
+export const ISO_SAMPLE = "2026-12-31";
+
+// ---------------------------------------------------------------------------
+// Presets
+// ---------------------------------------------------------------------------
+
+export interface SsimPreset {
+ id: string;
+ label: string;
+ description: string;
+ /** The SSIM text, exactly as it is typed. */
+ value: string;
+ /** `"rolling"`, a first year as text, or `""` for no window. */
+ window: string;
+ locale: string;
+ /** An ISO date for section 3, or `""`. */
+ date: string;
+}
+
+const WINDOW_NOTE = "The window is this example's pick: change it.";
+
+export const SSIM_PRESETS: readonly SsimPreset[] = [
+ {
+ id: "french-locale",
+ label: "01JAN26 with a French pattern",
+ description: `The SSIM reader gives the date. Given fr-FR, the pattern parser reads the month as that locale's own short name, janv., so it does not. ${WINDOW_NOTE}`,
+ value: "01JAN26",
+ window: "2000",
+ locale: "fr-FR",
+ date: "2026-01-01",
+ },
+ {
+ id: "english-locale",
+ label: "01JAN26 with an English pattern",
+ description: `The two agree only because English short names happen to match the code. ${WINDOW_NOTE}`,
+ value: "01JAN26",
+ window: "2000",
+ locale: "en",
+ date: "",
+ },
+ {
+ id: "turkish-locale",
+ label: "25OCT26 with a Turkish pattern",
+ description: `The locale you pass the pattern parser changes nothing for the SSIM reader. ${WINDOW_NOTE}`,
+ value: "25OCT26",
+ window: "2000",
+ locale: "tr-TR",
+ date: "",
+ },
+ {
+ id: "lower-case",
+ label: "Lower case",
+ description: `The SSIM reader refuses lower case. The locale parser ignores case, as prose reads. ${WINDOW_NOTE}`,
+ value: "01jan26",
+ window: "2000",
+ locale: "en",
+ date: "",
+ },
+ {
+ id: "spanish-locale",
+ label: "A translated month",
+ description: `A translated month is not the code: the SSIM reader refuses what the Spanish pattern accepts. ${WINDOW_NOTE}`,
+ value: "01ENE26",
+ window: "2000",
+ locale: "es-ES",
+ date: "",
+ },
+ {
+ id: "archive",
+ label: "An archive window",
+ description:
+ "A window from 1950 places 09 in 2009. The window is this example's pick: change it.",
+ value: "16DEC09",
+ window: "1950",
+ locale: "en",
+ date: "",
+ },
+ {
+ id: "leap-2000",
+ label: "29FEB00 from 2000",
+ description: `Valid with a window from 2000, where 00 is a leap year. ${WINDOW_NOTE}`,
+ value: "29FEB00",
+ window: "2000",
+ locale: "en",
+ date: "",
+ },
+ {
+ id: "leap-1900",
+ label: "29FEB00 from 1900",
+ description: `Not valid from 1900: 1900 has no 29 February. ${WINDOW_NOTE}`,
+ value: "29FEB00",
+ window: "1900",
+ locale: "en",
+ date: "",
+ },
+ {
+ id: "rolling",
+ label: "A rolling window",
+ description:
+ "A live feed's window moves with today, so the same two digits can mean another year next century.",
+ value: "25OCT26",
+ window: "rolling",
+ locale: "en",
+ date: "",
+ },
+ {
+ id: "no-window",
+ label: "No window",
+ description:
+ "Nothing says which century 26 is, so the reader states it. Without a window there is no date.",
+ value: "01JAN26",
+ window: "",
+ locale: "en",
+ date: "",
+ },
+ {
+ id: "write-outside",
+ label: "Write a year outside the window",
+ description: `The writer refuses a year the window does not hold, because it would read back as another century. ${WINDOW_NOTE}`,
+ value: "01JAN26",
+ window: "2000",
+ locale: "en",
+ date: "1999-12-31",
+ },
+];
+
+export const CUSTOM_PRESET_ID = "custom";
+
+// ---------------------------------------------------------------------------
+// State and arguments
+// ---------------------------------------------------------------------------
+
+export type WindowMode = "fixed" | "rolling";
+
+export interface SsimState {
+ /** The SSIM text as typed: never trimmed, never upper-cased. */
+ value: string;
+ mode: WindowMode;
+ /** The first year as typed; read only while the mode is `fixed`. */
+ first: string;
+ /** A BCP 47 tag, passed to the locale parser, which judges it. */
+ locale: string;
+ /** The ISO date to write back, as typed. */
+ date: string;
+}
+
+/** The state with nothing typed and no window. */
+export function blankState(): SsimState {
+ return {
+ value: "",
+ mode: "fixed",
+ first: "",
+ locale: DEFAULT_LOCALE,
+ date: "",
+ };
+}
+
+export function presetState(preset: SsimPreset): SsimState {
+ return {
+ value: preset.value,
+ mode: preset.window === "rolling" ? "rolling" : "fixed",
+ first: preset.window === "rolling" ? "" : preset.window,
+ locale: preset.locale,
+ date: preset.date,
+ };
+}
+
+/** The window as one string: `"rolling"`, the first year as typed, or `""`. */
+export function windowOf(state: SsimState): string {
+ return state.mode === "rolling" ? "rolling" : state.first;
+}
+
+export interface SsimArgs {
+ /** A preset id, from a permalink. */
+ preset?: string;
+ value?: string;
+ /** `"rolling"`, a year as text or a number, or `""` for no window. */
+ window?: string | number;
+ locale?: string;
+ date?: string;
+}
+
+/** Whether the args seed anything. */
+export function isSeeded(args: SsimArgs): boolean {
+ return Object.values(args).some((v) => v !== undefined);
+}
+
+const INTEGER = /^-?\d+$/;
+
+/**
+ * Seed arguments as controls. Typed values (the chat) and their text forms (a permalink)
+ * both land here. A link or a call with no `window` opens with the window blank: a preset's
+ * window is taken only through the preset's own id, and the chat never picks a century.
+ */
+export function readArgs(args: SsimArgs): SsimState {
+ const named = SSIM_PRESETS.find((p) => p.id === args.preset);
+ const state = named === undefined ? blankState() : presetState(named);
+ if (typeof args.value === "string") state.value = args.value;
+ if (typeof args.date === "string") state.date = args.date;
+ if (typeof args.locale === "string" && args.locale.trim() !== "") {
+ state.locale = args.locale.trim();
+ }
+ if (args.window === "rolling") {
+ state.mode = "rolling";
+ state.first = "";
+ } else if (typeof args.window === "number") {
+ state.mode = "fixed";
+ state.first = String(args.window);
+ } else if (typeof args.window === "string") {
+ state.mode = "fixed";
+ state.first = args.window;
+ }
+ return state;
+}
+
+/** The preset the controls match, or `custom`. */
+export function matchPreset(state: SsimState): string {
+ const hit = SSIM_PRESETS.find(
+ (p) =>
+ p.value === state.value &&
+ p.window === windowOf(state) &&
+ p.locale === state.locale &&
+ p.date === state.date,
+ );
+ return hit ? hit.id : CUSTOM_PRESET_ID;
+}
+
+/**
+ * The permalink payload: `{ preset }` alone while the state matches one, else the four
+ * strings. The window is a string (`"rolling"`, a year, or `""`) because a number outside
+ * 1900 to 2100 is dropped from a link.
+ */
+export function permalinkOf(state: SsimState): Record {
+ const preset = matchPreset(state);
+ if (preset !== CUSTOM_PRESET_ID) return { preset };
+ return {
+ value: state.value,
+ window: windowOf(state),
+ locale: state.locale,
+ date: state.date,
+ };
+}
+
+/**
+ * The options every SSIM call takes. A blank or non-integer first year sends no
+ * `yearWindow`, so the library answers with its sentinel; an integer goes through whatever
+ * it is, and the library judges its range.
+ */
+export function optionsOf(state: SsimState): YearWindowOptions {
+ if (state.mode === "rolling") return { yearWindow: "rolling" };
+ const text = state.first.trim();
+ return INTEGER.test(text) ? { yearWindow: Number(text) } : {};
+}
+
+/** Whether the state states a window the library can be given. */
+function hasWindow(options: YearWindowOptions): boolean {
+ return options.yearWindow !== undefined;
+}
+
+// ---------------------------------------------------------------------------
+// Reasons
+// ---------------------------------------------------------------------------
+
+export type ReadReasonKey =
+ | "empty"
+ | "noWindow"
+ | "badWindow"
+ | "lowerCase"
+ | "noSuchDay"
+ | "shape"
+ | "read";
+
+export const READ_REASONS: Record = {
+ empty: "Type an SSIM date, such as 01JAN26, to read it.",
+ noWindow:
+ "No window, no date: SSIM does not say which century 26 is, so you state it.",
+ badWindow:
+ "The library refuses this window: a first year is a whole number from 0 to 9900.",
+ lowerCase:
+ "Lower case is refused: the letters are a code, written upper case.",
+ noSuchDay: "That month has no such day in the windowed year.",
+ shape:
+ "Not two digits, three upper-case English month letters and two digits.",
+ read: "Read with the window you gave; the locale played no part.",
+};
+
+export type WriteReasonKey = "empty" | "outside" | "refused" | "written";
+
+export const WRITE_REASONS: Record = {
+ empty: "Type an ISO date, such as 2026-01-01, to write it.",
+ outside:
+ "Outside your window: written, it would read back as another century.",
+ refused: "Not an ISO calendar date, or no window.",
+ written: "Written upper case with a two-digit year, in the window above.",
+};
+
+/** The lead sentence of section 2: fixed text, and never a fault in the library. */
+export const PATTERN_LEAD =
+ "parseDateWithPattern reads MMM as the chosen locale's own short month names, and ignores case, as a reader of prose should. An SSIM date is written in no locale, so this is the wrong function for it.";
+
+/** The note under section 3's field. */
+export const WRITE_NOTE =
+ "Section 3 uses the window from section 1: it has no window of its own.";
+
+// ---------------------------------------------------------------------------
+// Section 1: read
+// ---------------------------------------------------------------------------
+
+export interface ReadResult {
+ /** Nothing was typed: no call was made. */
+ blank: boolean;
+ /** `parseSsimDate`, or `null` for the sentinel. */
+ ssim: string | null;
+ /** `isValidSsimDate`, or `null` while nothing was typed. */
+ valid: boolean | null;
+ reason: ReadReasonKey;
+ calls: string[];
+}
+
+/** The first of January exists in every year, so it reads in every window the library takes. */
+const WINDOW_PROBE = "01JAN00";
+
+/** Two ASCII digits of day at the start: the day probe swaps them for `01`. */
+const LEADING_DAY = /^[0-9]{2}/;
+
+/** Ask the library to read `text`, print the call, and say whether it gave a date. */
+function probe(
+ lib: AviationLib,
+ text: string,
+ options: YearWindowOptions,
+ calls: string[],
+): boolean {
+ const read = lib.parseSsimDate(text, options);
+ calls.push(
+ `parseSsimDate(${literal(text)}, ${literal(options)}); // ${literal(read)}`,
+ );
+ return read !== "";
+}
+
+/**
+ * Read the typed SSIM text. A refusal with a window is named by asking the library again,
+ * each probe printed with the calls, in this order:
+ *
+ * 1. **The window.** `01JAN00` reads in every window the library takes, so a refusal of it is
+ * the window's.
+ * 2. **The case.** The text upper-cased. `toUpperCase` does not depend on the locale
+ * (ECMA-262 defines it by Unicode default case conversion, and only `toLocaleUpperCase`
+ * takes one), so the probe cannot be moved by the reader's machine.
+ * 3. **The day.** The text with its two digits of day swapped for `01`. Every month has a
+ * first day in every year, so when this reads, the day is the only fault.
+ *
+ * A probe whose text is the typed text is not run: it has already been refused. Whatever no
+ * probe reads has the wrong shape.
+ */
+export function readSsim(lib: AviationLib, state: SsimState): ReadResult {
+ if (state.value === "") {
+ return {
+ blank: true,
+ ssim: null,
+ valid: null,
+ reason: "empty",
+ calls: [],
+ };
+ }
+ const options = optionsOf(state);
+ const calls: string[] = [];
+ const read = lib.parseSsimDate(state.value, options);
+ calls.push(
+ `parseSsimDate(${literal(state.value)}, ${literal(options)}); // ${literal(read)}`,
+ );
+ const valid = lib.isValidSsimDate(state.value, options);
+ calls.push(
+ `isValidSsimDate(${literal(state.value)}, ${literal(options)}); // ${literal(valid)}`,
+ );
+ if (read !== "") {
+ return { blank: false, ssim: read, valid, reason: "read", calls };
+ }
+
+ const reads = (text: string): boolean =>
+ text !== state.value && probe(lib, text, options, calls);
+ const upper = state.value.toUpperCase();
+ const firstDay = LEADING_DAY.test(state.value)
+ ? `01${state.value.slice(2)}`
+ : state.value;
+ let reason: ReadReasonKey;
+ if (!hasWindow(options)) {
+ reason = "noWindow";
+ } else if (!reads(WINDOW_PROBE)) {
+ reason = "badWindow";
+ } else if (reads(upper)) {
+ reason = "lowerCase";
+ } else if (reads(firstDay)) {
+ reason = "noSuchDay";
+ } else {
+ reason = "shape";
+ }
+ return { blank: false, ssim: null, valid, reason, calls };
+}
+
+// ---------------------------------------------------------------------------
+// Section 2: the locale pattern
+// ---------------------------------------------------------------------------
+
+export interface PatternResult {
+ /** The locale parser's date, `null` for no date, or `undefined` while nothing was typed. */
+ date: string | null | undefined;
+ /** It disagrees with section 1. */
+ differs: boolean;
+ calls: string[];
+}
+
+export function readPattern(
+ lib: AviationLib,
+ state: SsimState,
+ read: ReadResult,
+): PatternResult {
+ if (read.blank) return { date: undefined, differs: false, calls: [] };
+ const options = optionsOf(state);
+ const out = lib.parseDateWithPattern(
+ state.value,
+ PATTERN,
+ state.locale,
+ options,
+ );
+ const calls = [
+ `parseDateWithPattern(${literal(state.value)}, ${literal(PATTERN)}, ${literal(state.locale)}, ${literal(options)}); // ${literal(out)}`,
+ ];
+ return {
+ date: out === "" ? null : out,
+ differs: (out === "" ? null : out) !== read.ssim,
+ calls,
+ };
+}
+
+export interface MonthRow {
+ /** `01` to `12`. */
+ month: string;
+ /** The three letters the library wrote, or `null` if it wrote none. */
+ letters: string | null;
+ /** The locale's short name, or `null` if the locale gave none. */
+ name: string | null;
+}
+
+export interface MonthTable {
+ rows: MonthRow[];
+ /** The longest short name the locale gave, for the locale column's reserved width. */
+ widest: string;
+ calls: string[];
+}
+
+/**
+ * The twelve months: SSIM letters from the library's writer (characters 2 to 5 of the
+ * seven-character result), and the locale's short names. The site holds no letter table.
+ */
+export function monthTable(lib: AviationLib, locale: string): MonthTable {
+ const calls: string[] = [];
+ const letters: (string | null)[] = [];
+ const probeOptions = { yearWindow: PROBE_WINDOW };
+ for (let i = 1; i <= MONTH_COUNT; i += 1) {
+ const iso = `${PROBE_YEAR}-${String(i).padStart(2, "0")}-01`;
+ const written = lib.formatSsimDate(iso, probeOptions);
+ calls.push(
+ `formatSsimDate(${literal(iso)}, ${literal(probeOptions)}); // ${literal(written)}`,
+ );
+ letters.push(written === "" ? null : written.slice(2, 5));
+ }
+ const names = lib.getLocaleMonthNames(locale, "short");
+ calls.push(
+ `getLocaleMonthNames(${literal(locale)}, "short"); // ${literal(names)}`,
+ );
+ const rows = letters.map((l, i) => ({
+ month: String(i + 1).padStart(2, "0"),
+ letters: l,
+ name: names[i] === undefined || names[i] === "" ? null : names[i]!,
+ }));
+ let widest = "";
+ for (const row of rows) {
+ if (row.name !== null && row.name.length > widest.length) widest = row.name;
+ }
+ return { rows, widest, calls };
+}
+
+// ---------------------------------------------------------------------------
+// Section 3: write back
+// ---------------------------------------------------------------------------
+
+export interface WriteResult {
+ /** Nothing was typed: no call was made. */
+ blank: boolean;
+ /** `formatSsimDate`, or `null` for the sentinel. */
+ written: string | null;
+ /** `parseSsimDate(written)`, or `null` when nothing was written. */
+ back: string | null;
+ reason: WriteReasonKey;
+ calls: string[];
+}
+
+export function writeSsim(lib: AviationLib, state: SsimState): WriteResult {
+ if (state.date === "") {
+ return {
+ blank: true,
+ written: null,
+ back: null,
+ reason: "empty",
+ calls: [],
+ };
+ }
+ const options = optionsOf(state);
+ const calls: string[] = [];
+ const written = lib.formatSsimDate(state.date, options);
+ calls.push(
+ `formatSsimDate(${literal(state.date)}, ${literal(options)}); // ${literal(written)}`,
+ );
+ if (written === "") {
+ // With no window every date is refused, so "outside your window" would be untrue.
+ let reason: WriteReasonKey = "refused";
+ if (hasWindow(options)) {
+ const calendar = lib.isValidDate(state.date);
+ calls.push(
+ `isValidDate(${literal(state.date)}); // ${literal(calendar)}`,
+ );
+ if (calendar) reason = "outside";
+ }
+ return { blank: false, written: null, back: null, reason, calls };
+ }
+ const back = lib.parseSsimDate(written, options);
+ calls.push(
+ `parseSsimDate(${literal(written)}, ${literal(options)}); // ${literal(back)}`,
+ );
+ return {
+ blank: false,
+ written,
+ back: back === "" ? null : back,
+ reason: "written",
+ calls,
+ };
+}
+
+// ---------------------------------------------------------------------------
+// The whole model
+// ---------------------------------------------------------------------------
+
+export interface SsimModel {
+ read: ReadResult;
+ pattern: PatternResult;
+ write: WriteResult;
+}
+
+/** Everything the page draws that depends on the typed fields. The month table is drawn apart. */
+export function buildModel(lib: AviationLib, state: SsimState): SsimModel {
+ const read = readSsim(lib, state);
+ return {
+ read,
+ pattern: readPattern(lib, state, read),
+ write: writeSsim(lib, state),
+ };
+}
+
+export type CallsSection = "read" | "pattern" | "write";
+
+/**
+ * The printed calls at their widest, for the frames' reserved height: the same lines the
+ * mount prints, built by the same functions over a library whose every call takes its
+ * longest path. A frame is the hidden twin's height, so it holds one height whatever the
+ * reader types.
+ */
+export function callsSizerText(section: CallsSection): string {
+ const wide = {
+ // The typed text and its upper-cased twin are refused and the window probe reads, so all
+ // three probes print.
+ parseSsimDate: (value: string) =>
+ value === "31apr26" || value === "31APR26" ? "" : "2026-01-01",
+ formatSsimDate: () => "01JAN26",
+ isValidSsimDate: () => false,
+ parseDateWithPattern: () => "2026-01-01",
+ getLocaleMonthNames: () =>
+ Array.from({ length: MONTH_COUNT }, () => "janv."),
+ isValidDate: () => true,
+ } as unknown as AviationLib;
+ const state: SsimState = {
+ value: "31apr26",
+ mode: "fixed",
+ first: "2000",
+ locale: "fr-FR",
+ date: "1999-12-31",
+ };
+ const read = readSsim(wide, state);
+ if (section === "read") return read.calls.join("\n");
+ if (section === "pattern") {
+ return [
+ ...readPattern(wide, state, read).calls,
+ ...monthTable(wide, state.locale).calls,
+ ].join("\n");
+ }
+ return writeSsim(
+ {
+ ...wide,
+ formatSsimDate: () => "",
+ } as unknown as AviationLib,
+ state,
+ ).calls.join("\n");
+}
diff --git a/apps/dox/src/lib/widget-load-error.test.tsx b/apps/dox/src/lib/widget-load-error.test.tsx
index bc3b36cbd..b97157b7a 100644
--- a/apps/dox/src/lib/widget-load-error.test.tsx
+++ b/apps/dox/src/lib/widget-load-error.test.tsx
@@ -127,6 +127,10 @@ import {
mountFixTimestampReader,
renderFixTimestampReaderTemplate,
} from "./fix-timestamp-reader-mount";
+import {
+ mountSsimDateReader,
+ renderSsimDateReaderTemplate,
+} from "./ssim-date-reader-mount";
import {
mountTerrestrialTimeStack,
renderTerrestrialTimeStackTemplate,
@@ -338,6 +342,11 @@ const MOUNTS: [string, () => SafeHtml, MountFn][] = [
() => renderFixTimestampReaderTemplate("test"),
mountFixTimestampReader as MountFn,
],
+ [
+ "ssim date reader",
+ () => renderSsimDateReaderTemplate("test"),
+ mountSsimDateReader as MountFn,
+ ],
[
"terrestrial time stack",
() => renderTerrestrialTimeStackTemplate("test"),
diff --git a/apps/dox/src/lib/widget-permalink.test.ts b/apps/dox/src/lib/widget-permalink.test.ts
index ef01d4cd7..7673b393f 100644
--- a/apps/dox/src/lib/widget-permalink.test.ts
+++ b/apps/dox/src/lib/widget-permalink.test.ts
@@ -243,6 +243,20 @@ describe("widget permalinks", () => {
);
});
+ it("round-trips an SSIM read with a blank window and a cleared value", () => {
+ for (const state of [
+ { value: "01JAN26", window: "", locale: "fr-FR", date: "" },
+ { value: "", window: "rolling", locale: "en", date: "2026-01-01" },
+ { value: "01JAN26", window: "2000", locale: "en", date: "" },
+ ]) {
+ const url = encodeWidgetPermalink("ssim", state);
+ expect(url).toContain("/tools/ssim-date-reader/");
+ expect(seedFromLocation("ssim", url.slice(url.indexOf("?")))).toEqual(
+ state,
+ );
+ }
+ });
+
it("opens each Terrestrial Time Stack preset's link on that preset", () => {
for (const preset of STACK_PRESETS) {
if (preset === DEFAULT_PRESET) continue;
diff --git a/apps/dox/src/lib/widget-permalink.ts b/apps/dox/src/lib/widget-permalink.ts
index 338839bf4..a7824f671 100644
--- a/apps/dox/src/lib/widget-permalink.ts
+++ b/apps/dox/src/lib/widget-permalink.ts
@@ -80,6 +80,7 @@ export type WidgetKind =
| "dbstamp"
| "tai64n"
| "fixstamp"
+ | "ssim"
| "ttstack";
/**
@@ -146,6 +147,7 @@ export const WIDGET_PAGE_PATHS: Record = {
dbstamp: "/tools/database-timestamp-reader/",
tai64n: "/tools/tai64n-log-reader/",
fixstamp: "/tools/fix-timestamp-reader/",
+ ssim: "/tools/ssim-date-reader/",
ttstack: "/tools/terrestrial-time-stack/",
};
@@ -250,6 +252,8 @@ const EMPTY_KEYS_BY_KIND: Readonly<
dbstamp: new Set(["value", "value2", "value3", "zone"]),
// A cleared stamp or instant is the empty state: the link must open cleared, not on the default.
fixstamp: new Set(["stamp", "write"]),
+ // A cleared value, window or date is a state of its own: a blank window is the no-date reason, and the link must open on it.
+ ssim: new Set(["value", "window", "date"]),
};
/**
diff --git a/apps/dox/src/test/aviation-lib.ts b/apps/dox/src/test/aviation-lib.ts
new file mode 100644
index 000000000..2b23b0339
--- /dev/null
+++ b/apps/dox/src/test/aviation-lib.ts
@@ -0,0 +1,20 @@
+/**
+ * The real gmt functions the aviation tests inject as an `AviationLib`, loaded by module
+ * path so a test never needs the loader's dynamic imports.
+ */
+import { formatSsimDate } from "@northguild/gmt/aviation/format";
+import { parseSsimDate } from "@northguild/gmt/aviation/parse";
+import { isValidSsimDate } from "@northguild/gmt/aviation/validate";
+import { getLocaleMonthNames } from "@northguild/gmt/plain/locale";
+import { parseDateWithPattern } from "@northguild/gmt/plain/parse";
+import { isValidDate } from "@northguild/gmt/plain/validate";
+import type { AviationLib } from "~/lib/aviation-lib";
+
+export const aviationLib = {
+ parseSsimDate,
+ formatSsimDate,
+ isValidSsimDate,
+ parseDateWithPattern,
+ getLocaleMonthNames,
+ isValidDate,
+} as unknown as AviationLib;
diff --git a/apps/dox/src/widgets/tools/ssim-date-reader.module.css b/apps/dox/src/widgets/tools/ssim-date-reader.module.css
new file mode 100644
index 000000000..085b1324e
--- /dev/null
+++ b/apps/dox/src/widgets/tools/ssim-date-reader.module.css
@@ -0,0 +1,143 @@
+/*
+ * SSIM Date Reader: what only this tool needs. The sections, preset, fields, chips, plates,
+ * badge, table, code frames and held lines are the kit's and the holiday family's; this sheet
+ * lays the controls out and sets the month table's cells.
+ *
+ * Amber is the sentinel's alone: a plate the library refused reads a bracketed NO SIGNAL. The
+ * pattern plate is neutral, because a missing date there is that function's right answer. The
+ * "differs" mark is a bottom edge with a hatch, never a left edge and never a colour alone.
+ */
+
+.controls {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
+ gap: var(--gmt-space-3);
+ min-inline-size: 0;
+}
+
+/* A group that needs the whole row: the preset and the window chips. */
+.wide {
+ grid-column: 1 / -1;
+ min-inline-size: 0;
+}
+
+.slot {
+ min-inline-size: 0;
+}
+
+.note {
+ margin: 0;
+ color: var(--gmt-ice-dim);
+ font-size: var(--gmt-text-sm);
+ line-height: 1.5;
+}
+
+/* The badge always takes its room: a hidden twin sits in the same cell as the live one. */
+.differsHold {
+ display: grid;
+ justify-items: start;
+ min-inline-size: 0;
+
+ & > * {
+ grid-area: 1 / 1;
+ }
+}
+
+.differs {
+ padding-block-end: var(--gmt-space-1);
+ border-block-end: 2px solid var(--gmt-series-2);
+ background-image: repeating-linear-gradient(
+ 45deg,
+ color-mix(in srgb, var(--gmt-series-2) 30%, transparent) 0,
+ color-mix(in srgb, var(--gmt-series-2) 30%, transparent) 2px,
+ transparent 2px,
+ transparent 8px
+ );
+}
+
+.differsGhost {
+ padding-block-end: var(--gmt-space-1);
+ border-block-end: 2px solid transparent;
+ visibility: hidden;
+ pointer-events: none;
+}
+
+/* A month cell: letters or a name, in tabular figures with no wrap. */
+.cell {
+ display: block;
+ font-family: var(--gmt-font-mono);
+ font-size: var(--gmt-text-xs);
+ font-variant-numeric: tabular-nums;
+ white-space: nowrap;
+}
+
+/* Under 40rem the twelve rows become labelled blocks: each cell names its column from the
+ `data-col` the table wrote, and the header row is read by the labels instead. */
+.strip {
+ min-inline-size: 0;
+
+ @container (inline-size < 40rem) {
+ & table,
+ & caption,
+ & tbody,
+ & tr,
+ & th,
+ & td {
+ display: block;
+ inline-size: 100%;
+ }
+
+ & thead {
+ position: absolute;
+ inline-size: 1px;
+ block-size: 1px;
+ overflow: hidden;
+ clip-path: inset(50%);
+ }
+
+ & tr {
+ padding-block: var(--gmt-space-2);
+ border-block-end: 1px solid var(--gmt-hairline);
+ }
+
+ & th,
+ & td {
+ display: grid;
+ grid-template-columns: minmax(5rem, 7rem) minmax(0, 1fr);
+ gap: var(--gmt-space-2);
+ border-block-end: 0;
+ text-align: start;
+ }
+
+ & th::before,
+ & td::before {
+ content: attr(data-col);
+ color: var(--gmt-ice-dim);
+ font-weight: 600;
+ }
+ }
+}
+
+@media (forced-colors: active) {
+ .differs {
+ background-image: none;
+ border-block-end-color: CanvasText;
+ border-block-end-style: double;
+ }
+
+ .strip td::before,
+ .strip th::before {
+ color: CanvasText;
+ }
+}
+
+@media (prefers-contrast: more) {
+ .differs {
+ border-block-end-width: 3px;
+ }
+
+ .strip td::before,
+ .strip th::before {
+ color: var(--gmt-ice);
+ }
+}
diff --git a/apps/dox/worker/select-vocabulary.test.ts b/apps/dox/worker/select-vocabulary.test.ts
index 6e2610ba6..a1ed0015a 100644
--- a/apps/dox/worker/select-vocabulary.test.ts
+++ b/apps/dox/worker/select-vocabulary.test.ts
@@ -18,6 +18,7 @@ const SKILL_NAMES = [
"gmt-integration",
"gmt-gnss",
"gmt-finance",
+ "gmt-aviation",
"gmt-transport",
"gmt-intermodal",
"gmt-workforce",
diff --git a/apps/dox/worker/tools.test.ts b/apps/dox/worker/tools.test.ts
index 4f7454136..3f183d100 100644
--- a/apps/dox/worker/tools.test.ts
+++ b/apps/dox/worker/tools.test.ts
@@ -429,6 +429,66 @@ describe("worker tool execute", () => {
});
});
+ describe("showSsimDateReader", () => {
+ const schema = (
+ tools.showSsimDateReader as unknown as {
+ inputSchema: {
+ safeParse: (v: unknown) => { success: boolean; data?: unknown };
+ };
+ }
+ ).inputSchema;
+
+ it("accepts a value, a date or both, with a window as a year or rolling", async () => {
+ for (const input of [
+ { value: "01JAN26", yearWindow: 2000, locale: "fr-FR" },
+ { value: "01JAN26", yearWindow: "rolling" },
+ { value: "01JAN26" },
+ { date: "2026-01-01", yearWindow: 2000 },
+ { value: "01jan26", date: "2026-01-01" },
+ ]) {
+ expect(schema.safeParse(input).success).toBe(true);
+ expect(await run("showSsimDateReader", input)).toMatchObject({
+ ok: true,
+ widget: "ssim-date-reader",
+ });
+ }
+ });
+
+ it("needs a value or a date", () => {
+ expect(schema.safeParse({}).success).toBe(false);
+ expect(schema.safeParse({ yearWindow: 2000 }).success).toBe(false);
+ });
+
+ it("refuses a window that is not a year or rolling, and a value over 16 characters", () => {
+ expect(schema.safeParse({ value: "x", yearWindow: "now" }).success).toBe(
+ false,
+ );
+ expect(schema.safeParse({ value: "x", yearWindow: 1.5 }).success).toBe(
+ false,
+ );
+ expect(schema.safeParse({ value: "x", yearWindow: -1 }).success).toBe(
+ false,
+ );
+ expect(schema.safeParse({ value: "a".repeat(16) }).success).toBe(true);
+ expect(schema.safeParse({ value: "a".repeat(17) }).success).toBe(false);
+ });
+
+ it("caps the locale at 35 characters, as the Duration Parser Bench does", () => {
+ const withLocale = (locale: string) =>
+ schema.safeParse({ value: "01JAN26", locale }).success;
+ expect(withLocale("en")).toBe(true);
+ expect(withLocale("a".repeat(35))).toBe(true);
+ expect(withLocale("a".repeat(36))).toBe(false);
+ expect(withLocale("e")).toBe(false);
+ });
+
+ it("does not default the window", () => {
+ expect(schema.safeParse({ value: "01JAN26" }).data).toEqual({
+ value: "01JAN26",
+ });
+ });
+ });
+
describe("showTerrestrialTimeStack", () => {
const schema = (
tools.showTerrestrialTimeStack as unknown as {
diff --git a/apps/dox/worker/tools.ts b/apps/dox/worker/tools.ts
index 98af2b3a3..38da11423 100644
--- a/apps/dox/worker/tools.ts
+++ b/apps/dox/worker/tools.ts
@@ -74,6 +74,7 @@ import {
showDatabaseTimestampReaderInput,
showTai64nLogReaderInput,
showFixTimestampReaderInput,
+ showSsimDateReaderInput,
showTerrestrialTimeStackInput,
showStoredTimeAuditInput,
showHolidayRuleBuilderInput,
@@ -658,6 +659,11 @@ export function buildWorkerTools(
inputSchema: showFixTimestampReaderInput,
execute: () => accept("fix-timestamp-reader"),
}),
+ showSsimDateReader: tool({
+ description: docFor("showSsimDateReader"),
+ inputSchema: showSsimDateReaderInput,
+ execute: () => accept("ssim-date-reader"),
+ }),
showTerrestrialTimeStack: tool({
description: docFor("showTerrestrialTimeStack"),
inputSchema: showTerrestrialTimeStackInput,
diff --git a/apps/dox/worker/vocabulary.ts b/apps/dox/worker/vocabulary.ts
index 236fa3551..aed84c179 100644
--- a/apps/dox/worker/vocabulary.ts
+++ b/apps/dox/worker/vocabulary.ts
@@ -27,6 +27,7 @@
import { parseSkill, type VocabularySkill } from "./select-vocabulary";
import gmtArithmetic from "../../../packages/gmt/skills/gmt-arithmetic/SKILL.md";
import gmtBasics from "../../../packages/gmt/skills/gmt-basics/SKILL.md";
+import gmtAviation from "../../../packages/gmt/skills/gmt-aviation/SKILL.md";
import gmtFinance from "../../../packages/gmt/skills/gmt-finance/SKILL.md";
import gmtGnss from "../../../packages/gmt/skills/gmt-gnss/SKILL.md";
import gmtHealthcare from "../../../packages/gmt/skills/gmt-healthcare/SKILL.md";
@@ -43,6 +44,7 @@ export const VOCABULARY_SKILLS: readonly VocabularySkill[] = [
gmtIntegration,
gmtGnss,
gmtFinance,
+ gmtAviation,
gmtTransport,
gmtIntermodal,
gmtWorkforce,
diff --git a/context/code-review-checklist.md b/context/code-review-checklist.md
index 969c6fae3..ca6eb3e89 100644
--- a/context/code-review-checklist.md
+++ b/context/code-review-checklist.md
@@ -15,7 +15,7 @@ This is the mechanical layer. Standards conformance and domain-convention correc
- [ ] Plain/zoned separation maintained — no `PlainDateTime`/`ZonedDateTime` mixing in the same function
- [ ] All Temporal method calls wrapped in `try-catch` — the only exception is the [UTC clock readers](./coding-standards.md#scoped-exception-the-utc-clock-readers); a read of the system time zone still needs one
-- [ ] New functions follow the existing directory structure (`calendar/`, `duration/`, `finance/`, `gnss/`, `instant/`, `intermodal/`, `interval/`, `plain/`, `precision/`, `regex/`, `span/`, `timescale/`, `transport/`, `unix/`, `utc/`, `workforce/`, `zoned/`) and the `get/` vs `calculate/` rule
+- [ ] New functions follow the existing directory structure (`aviation/`, `calendar/`, `duration/`, `finance/`, `gnss/`, `healthcare/`, `instant/`, `intermodal/`, `interval/`, `plain/`, `precision/`, `recurrence/`, `regex/`, `span/`, `timescale/`, `transport/`, `unix/`, `utc/`, `workforce/`, `zoned/`) and the `get/` vs `calculate/` rule
- [ ] A function shared across industries is in the cross-industry layer for its domain (`workforce/`, `gnss/`) or in Core if truly general — not in a grab-bag "shared" namespace, not in one industry's namespace, not in a new namespace that is not a recognised domain ([§ Plain / Zoned Separation](./coding-standards.md#plain--zoned-separation))
- [ ] Zoned unit boundaries are not computed by truncating the wall clock and re-resolving it (`round({ roundingMode: "trunc" })`, `.with()` + `"compatible"`) — see [§ Calendar & zone semantics](./coding-standards.md#calendar--zone-semantics)
- [ ] Bounded loops (walkers, steppers, caps) return the sentinel on exhaustion, never a partial value
diff --git a/context/coding-standards.md b/context/coding-standards.md
index 7b2421261..777735558 100644
--- a/context/coding-standards.md
+++ b/context/coding-standards.md
@@ -136,6 +136,20 @@ The same three rules extend to `parseFixUtcTimestamp`, `formatFixUtcTimestamp` a
This prohibition stands for every other function in the library.
+### Scoped exception: aviation message grammars in `aviation/` (AV-97)
+
+The same three rules extend to `parseSsimDate` and `formatSsimDate` in `packages/gmt/src/aviation/`. The SSIM date `DDMMMYY` (`01JAN26`) is not ISO 8601, and Temporal's `.from()` cannot parse it at any layer. The grammar is fixed, never caller-supplied:
+
+1. One regex, in `internal/ssimDate.ts`, built from the table of twelve month letters, with a field reader and a writer derived from the same table. No public function slices the string itself. The grammar is not a public pattern, because a value is a date only once its century is known: the public check is `isValidSsimDate(value, options)`, and `regex/` gains nothing.
+2. The extracted fields are always handed to `Temporal.PlainDate.from(fields, { overflow: "reject" })`.
+3. The try-catch and sentinel-return rules above are unchanged.
+
+**The month letters are a code.** They are fixed English and upper case, never read through `Intl`, and never case-folded. This is an explicit exception to the library's locale-aware formatting.
+
+**The century is the caller's.** Both functions take `TwoDigitYearOptions` and return the sentinel without `yearWindow`, under the INT-15 [No century is guessed](#scoped-exception-edi-datetime-grammars-in-the-parseedifact-and-parsex12-functions-int-15) rule.
+
+This prohibition stands for every other function in the library.
+
### Scoped exception: TAI64 text labels in `timescale/convert` (SPA-46)
The same three rules extend to `fromTai64n` (reader) and `toTai64n` (writer) in `packages/gmt/src/timescale/convert/`. A TAI64, TAI64N or TAI64NA label (`@400000002a2b2c2d00000000`) is hex text, not ISO 8601, and no `Temporal.*.from` reads it. Bernstein's [TAI64, TAI64N, and TAI64NA](https://cr.yp.to/libtai/tai64.html) defines the byte layouts (8, 12 and 16 bytes); daemontools [`tai64n`](https://cr.yp.to/daemontools/tai64n.html) defines only the TAI64N text, `@` and 24 lowercase hex digits. Reading 16 or 32 digits, an optional `@` and either hex case is GMT's own rule (precedent: `fromObjectId` reads either case). The grammar is fixed:
@@ -301,7 +315,7 @@ Avoid `while` loops in new code. Prefer `for` loops or array methods (`map`, `fi
- `plain/` — timezone-free operations (`PlainDate`, `PlainTime`, `PlainDateTime`)
- `zoned/` — IANA timezone-aware operations (`ZonedDateTime`)
- Never mix the two in the same function or module.
-- **Core namespaces, industry layers, cross-industry layers.** Core namespaces hold general time primitives anyone uses (`calendar/`, `duration/`, `instant/`, `zoned/`, `timescale/`, `precision/` and the rest). Industry layers are named for an industry and hold its own functions (`transport/`, `intermodal/`, `finance/`, later `maritime/`, `aviation/` and the rest). A cross-industry layer is a recognised industry domain that other industries draw on: `workforce/` (people's working time, the CORE-76 duty engine) and `gnss/`. A function shared across industries goes in the cross-industry layer for its domain, or in Core if it is truly general — never in a grab-bag "shared" namespace, never in one industry's namespace when other industries also need it, and never in a new namespace that is not a recognised domain.
+- **Core namespaces, industry layers, cross-industry layers.** Core namespaces hold general time primitives anyone uses (`calendar/`, `duration/`, `instant/`, `zoned/`, `timescale/`, `precision/` and the rest). Industry layers are named for an industry and hold its own functions (`transport/`, `intermodal/`, `finance/`, `aviation/`, `healthcare/` and, later, `maritime/` and the rest). A cross-industry layer is a recognised industry domain that other industries draw on: `workforce/` (people's working time, the CORE-76 duty engine) and `gnss/`. A function shared across industries goes in the cross-industry layer for its domain, or in Core if it is truly general — never in a grab-bag "shared" namespace, never in one industry's namespace when other industries also need it, and never in a new namespace that is not a recognised domain.
- The other namespaces follow the same one-type-per-function rule: `utc/`, `unix/`, `instant/`, `calendar/`, `span/`, `interval/`, `precision/`, `duration/`, `regex/`, `transport/`, `intermodal/`, `finance/`, `workforce/`, `gnss/` (see `packages/gmt/src/`).
## International authority first
diff --git a/context/domination/issues/AV-97.md b/context/domination/issues/AV-97.md
index 14a736750..3b7ae700f 100644
--- a/context/domination/issues/AV-97.md
+++ b/context/domination/issues/AV-97.md
@@ -7,7 +7,7 @@
Airline schedules are exchanged in IATA's Standard Schedules Information Manual (SSIM) formats,
and their dates are not ISO 8601. A schedule file's period of operation is written `DDMMMYY`:
two digits of day, the first three letters of the month in English, upper case, and two digits of
-year — `01JAN26` (the Chapter 7 layout is not reached; marked, not asserted). Slot messages use
+year — `01JAN26` (IATA's Chapter 7 layout is not reached; see Authority). Slot messages use
the same day and month letters without the year: "The last three are the first three letters of
the name of the month in English: JAN, FEB, …, NOV, DEC" ([painpoints § Aviation, SSIM
dates](../painpoints.md#aviation)). Schedules are filed against seasons and carry dates a year
@@ -17,9 +17,11 @@ Two defects follow. A parser that reads the month through the platform's locale
machine whose default locale is not English. A parser that picks a century itself is wrong for
either the archive or the forward schedule.
-(IATA, _Standard Schedules Information Manual_, Chapter 7 — not reached; marked, not asserted.
-[AECFA (Spain), _Quick Guide to Using the IATA SSIM format_, Chapter 6 slot messages](https://www.slotcoordination.es/sites/Satellite?blobcol=urldata&blobkey=id&blobtable=MungoBlobs&blobwhere=1576865330896&ssbinary=true) —
-a national coordinator's guide, labelled corroboration for the day and month letters.)
+(IATA, _Standard Schedules Information Manual_, Chapter 7 — not reached. AECFA (Spain), _Quick Guide
+to Using the IATA SSIM format_, Chapter 6 slot messages, a national coordinator's guide, is cited
+by name for the day and month letters; it is no longer online (the link returns 404 and no
+archived copy exists). The seven-character form rests on the sources in
+[Authority](#authority--what-each-rule-rests-on).)
## Scope
@@ -86,10 +88,8 @@ locale and see the answer stay the same. A second panel writes a date back. Call
one from 1900, so `isValidSsimDate` takes the parser's options and is false without
`yearWindow`. The grammar stays in `internal/`: a value is valid only once its century is known,
which no pattern can say.
-- **The Chapter 7 text is not reached.** IATA does not publish SSIM openly. The day and the English
- month letters are corroborated by AECFA's guide to Chapter 6; the two-digit year that follows them
- in a Chapter 7 period of operation is not. `/plan-story` cites Chapter 7, or public sources from at
- least two countries, before the function is built, and the JSDoc marks the form until then.
+- **The Chapter 7 text is not reached.** IATA does not publish SSIM openly. The JSDoc says so in
+ one line. The sources that stand in for it are in Authority.
- Seasons, days of operation and leg times are not part of this story.
## Authority — what each rule rests on
@@ -99,8 +99,8 @@ available.
| Rule | Source |
| --- | --- |
-| Day as two digits, month as three upper-case English letters | AECFA (Spain), _Quick Guide to Using the IATA SSIM format_, Chapter 6: "The first two are the day of the month. Shown as 01, 02,….30, 31"; "The last three are the first three letters of the name of the month in English: JAN, FEB, ……, NOV, DEC". Labelled corroboration; IATA SSIM Chapter 6 not reached |
-| Two digits of year after the month in a Chapter 7 period of operation | IATA SSIM Chapter 7 — **not reached; marked, not asserted** |
+| Day as two digits, month as three upper-case English letters | AECFA (Spain), _Quick Guide to Using the IATA SSIM format_, Chapter 6: "The first two are the day of the month. Shown as 01, 02,….30, 31"; "The last three are the first three letters of the name of the month in English: JAN, FEB, ……, NOV, DEC". The guide is no longer online, so it is cited by name only. ACL (UK), [_An Introductory Guide to SSIM_](https://www.acl-uk.org/wp-content/uploads/2021/04/SSIM-Review-Final2.pdf) (April 2021), a condensed extract of Chapter 6, shows the same form (`01APR`, `10JAN`). Corroboration; IATA SSIM Chapter 6 not reached |
+| Two digits of year after the month (`DDMMMYY`) | Only EUROCONTROL, [_CSST Users Guide_](https://www.eurocontrol.int/archive_download/all/node/9248) Ed. 8.0 (28-04-2021), §3.2 Figure 1, shows the seven-character form (`05APR10`, `11APR10`, `16DEC09`). Avinor's [SSIM description](https://xwiki.avinor.no/x/rYC5Ag) shows only a two-digit year ("ddmmyy"). IATA SSIM Chapter 7 was not reached. The owner accepted these two sources as meeting the story's bar |
| No `Intl` for the month | **GMT rule.** The letters are a code fixed in English |
| The century is the caller's | **GMT rule**, INT-15's: no standard names the century of a two-digit year |
| The grammar is internal; the public check is `isValidSsimDate` | **GMT rule**, INT-15's: IATA publishes no pattern |
@@ -114,7 +114,8 @@ available.
- `TwoDigitYearOptions` from INT-15 — the caller-stated hundred-year window
- `internal/twoDigitYear.ts` and `internal/yearWindowStart.ts` from INT-15 — placing a two-digit
year in that window, and reading the option
-- `isValidDate` — the ISO date the formatter takes
+- `isDateString` (`internal/inputChecks.ts`), the check `isValidDate` uses — the ISO date the formatter takes
+- `isOptionsArgument` (`internal/isObject.ts`) — an options argument that is not an object gives the sentinel
## Verification
@@ -123,7 +124,40 @@ available.
- `parseSsimDate('01jan26', …)`, `'01Jan26'`, `'01JANV26'`, `'1JAN26'` and `'01ENE26'` return the sentinel
- `parseSsimDate` returns the same answer under every locale in the full locale matrix
- `formatSsimDate('2026-10-25', { yearWindow: 2000 })` returns `25OCT26`; `formatSsimDate('1999-12-31', { yearWindow: 2000 })` returns the sentinel
-- Round-trip: `parseSsimDate(formatSsimDate(d, w), w)` returns `d` for every date `d` inside the window `w`
+- Round-trip: `parseSsimDate(formatSsimDate(d, w), w)` returns `d` for a sample of dates inside the window `w`: every day of 2024 and 2025 under window 2000, the first and last day of every month under window 1950, and the edges of windows 0 and 9900. The reverse direction, `formatSsimDate(parseSsimDate(s, w), w) === s`, is swept over all 1,462 valid `DDYY` strings for years 00, 24, 25 and 99. The window holds about 36,500 days, and checking each would break the per-test time budget
- `isValidSsimDate('01JAN26', { yearWindow: 2000 })` is `true`; `isValidSsimDate('01jan26', { yearWindow: 2000 })`, `isValidSsimDate('31APR26', { yearWindow: 2000 })` and `isValidSsimDate('01JAN26', {})` are `false`
- `isValidSsimDate` agrees with `parseSsimDate` on every parse row above, under every locale in the matrix; a number and `null` are `false`
- `pnpm run validate` stays green
+
+## Decisions
+
+- **The two-digit year is sourced well enough.** EUROCONTROL's CSST guide (§3.2 Figure 1) and
+ Avinor (a two-digit year only) meet the bar of public sources from two countries, so `DDMMMYY` is
+ built as asserted. Only the EUROCONTROL guide shows the seven-character form; Avinor shows a
+ two-digit year alone. The JSDoc keeps one line saying IATA's Chapter 7 text was not reached.
+- **The round trip is tested on a sample**, not on every date: the window holds about 36,500
+ days, and three polyfill calls on each would break the per-test time budget. The sample is
+ given under Verification.
+- **`DDMMM` with no year and `00XXX00` are out of scope.** A test shows `00XXX00` returning `""`
+ because `XXX` is not a month. No JSDoc or docs page says what `00XXX00` means in SSIM.
+- **The icon is a control tower** (`industry-aviation`).
+- **Upper case only.** A reader that accepts `jan` invites a writer that emits it, and folding
+ case can map other characters onto a month code (`"ſEP".toUpperCase() === "SEP"`) and depends on
+ the locale (`"i".toLocaleUpperCase("tr")`). No case folding, no trimming.
+- **ASCII digits only.** The grammar writes `[0-9]`, not `\d`, as the X12 and EDIFACT siblings do.
+- **No `Intl` for the month.** The letters are a constant table in `internal/ssimDate.ts`, a
+ separate literal and not derived from `ENGLISH_MONTH_NAMES` (a different authority, title
+ case, and deriving it would need a case conversion). The regex is built once from the table.
+- **The century is the caller's.** `options` is required in the type; `yearWindow` has no default;
+ an omitted or empty one, or an options argument that is not an object, gives the sentinel.
+- **The grammar stays internal.** IATA publishes no pattern, and a value is valid only once its
+ century is known, so nothing is added to `regex/`. `isValidSsimDate` calls the parser, so the
+ two cannot disagree.
+- **The formatter refuses a year outside the window**, and takes only an ISO calendar date; a
+ date-time, an instant or another calendar gives `""`.
+- **Days that do not exist are rejected** by Temporal with `overflow: "reject"`; the field reader
+ checks no date itself.
+- **Loop cost:** none of the three functions loops, so there are no bench rows.
+- **Aviation `drawsOn` is empty and there is no `calculate` module.** A `gmt-aviation` skill
+ was created. AV-98 adds its METAR and NOTAM functions to this realm.
+- **Out of scope:** days of operation, seasons, leg times and Record Types 1 to 5 as records.
diff --git a/context/domination/painpoints.md b/context/domination/painpoints.md
index 22322b87b..cce12a667 100644
--- a/context/domination/painpoints.md
+++ b/context/domination/painpoints.md
@@ -268,7 +268,7 @@ and GTFS-RT POSIX seconds.
NOV, DEC", upper case. A period of operation adds two digits of year after them (IATA
SSIM Chapter 7, not reached; marked, not asserted). A parser that reads the month
through the platform's locale breaks on any machine whose default locale is not
- English, and a two-digit year has no century until someone states one. ([AECFA, _Quick Guide to Using the IATA SSIM format_](https://www.slotcoordination.es/sites/Satellite?blobcol=urldata&blobkey=id&blobtable=MungoBlobs&blobwhere=1576865330896&ssbinary=true))
+ English, and a two-digit year has no century until someone states one. (AECFA, _Quick Guide to Using the IATA SSIM format_, no longer online; [ACL, _An Introductory Guide to SSIM_](https://www.acl-uk.org/wp-content/uploads/2021/04/SSIM-Review-Final2.pdf); [EUROCONTROL, _CSST Users Guide_](https://www.eurocontrol.int/archive_download/all/node/9248))
- **`DDHHMMZ` is ambiguous; NOTAM validity is not.** METAR and TAF report times carry
day-of-month, hour and minute only — **no month, no year** — so parsing one *requires*
a reference instant to disambiguate. ICAO NOTAM items B) and C), by contrast, use a
diff --git a/context/domination/tracker.md b/context/domination/tracker.md
index 49dd62f69..7e427d46b 100644
--- a/context/domination/tracker.md
+++ b/context/domination/tracker.md
@@ -121,8 +121,8 @@ ending with lengths of time counted from now, ahead of the remaining realms.
| 46 | HLTH-94 | Healthcare | FHIR datetimes: `parseFHIR`, `formatFHIR`,
`isValidFHIR`, three FHIR regexes | — | #402 | — | Not started |
| 47 | FIN-95 | Finance | FIX UTC timestamps: parse, format and
`isValidFixUtcTimestamp` | — | #403 | — | Done |
| 48 | FIN-96 | Finance | SWIFT dates: `parseSwiftDate`,
`formatSwiftDate`, `isValidSwiftDate` | — | #404 | — | Not started |
-| 49 | AV-97 | Aviation | SSIM dates: `parseSsimDate`,
`formatSsimDate`, `isValidSsimDate` | — | #405 | — | Not started |
-| 50 | AV-98 | Aviation | METAR and NOTAM times: parse,
`isValidMetarTime`, `isValidNotamValidity` | AV-97 | #406 | — | Not started |
+| 49 | AV-97 | Aviation | SSIM dates: `parseSsimDate`,
`formatSsimDate`, `isValidSsimDate` | — | #405 | — | Done |
+| 50 | AV-98 | Aviation | METAR and NOTAM times: parse,
`isValidMetarTime`, `isValidNotamValidity` | — | #406 | — | Not started |
| 51 | RAI-99 | Rail | GTFS time strings: `parseGtfsTime`,
`formatGtfsTime`, `isValidGtfsTime` | — | #407 | — | Not started |
| 52 | RAI-100 | Rail | GTFS times to instants: `gtfsToInstant` | RAI-99 | #408 | — | Not started |
| 53 | IOT-101 | IoT | PTP time: `ptpToUtc`, `utcToPtp`,
`isValidPtpTimestamp` | — | #409 | — | Not started |
diff --git a/context/dox/built.md b/context/dox/built.md
index b55760d8a..b4cc42bfb 100644
--- a/context/dox/built.md
+++ b/context/dox/built.md
@@ -435,6 +435,7 @@ that bind future changes, the traps, and the runbooks. Every story is done; stat
(`industry-`), `guide`, the `namespace` it owns (or none) and the modules it `drawsOn`.
Workforce owns `workforce`; Transport owns `transport` and draws on `workforce`; Intermodal
owns `intermodal` and draws on `transport`; GNSS owns `gnss` and draws on `timescale`;
+ Finance owns `finance` and Aviation owns `aviation`, each drawing on nothing;
Maritime owns none and draws on `gnss` and `timescale`. `src/lib/industry-tags.ts`, a leaf
module, reads it (`INDUSTRIES`, `INDUSTRY_TAG_IDS` with `core` first, `OWN_NAMESPACES`,
`industryOwning`, `drawsOn`, `industriesUsing`, `INDUSTRY_ICON_PATHS`); `core` and `space` are
@@ -2549,6 +2550,50 @@ Shared hooks come first, then the globe, then the clock-change pages.
- **Permalink `fixstamp`** at `/tools/fix-timestamp-reader/`: `stamp` and `write`, or `preset` and
`writePreset` while a box matches a preset. The chat tool is `showFixTimestampReader`
(`stamp`, `instant`; the registry maps `instant` to `write`), appended to `DOX_TOOL_DOCS`.
+- **Aviation** (AV-97): one tool, the **SSIM Date Reader** (`/tools/ssim-date-reader/`, `ssim`,
+ aviation). An IATA SSIM date (`DDMMMYY`, such as `01JAN26`) is read by `parseSsimDate` and
+ `isValidSsimDate` with a window the reader states, beside the locale pattern parser
+ (`parseDateWithPattern`, `ddMMMyy`) under a locale the reader picks. Section 2 also tables the
+ locale's short month names (`getLocaleMonthNames`) against the letters `formatSsimDate` writes,
+ and section 3 writes an ISO date back with `formatSsimDate` and reads it back. Aviation `drawsOn` is `[]`.
+ It opens on the `french-locale` preset (`01JAN26`, window 2000, `fr-FR`) so the comparison shows
+ a difference before anything is touched. Its rules:
+ - **The window is always an input, and never defaulted.** The century is the caller's, so
+ a blank window is the library's `""` with the reason "no window", and a chat call with no
+ `yearWindow` opens with the window blank. Both forms are offered (`Fixed from` and `Rolling`
+ chips) because the type has both; a test that uses the rolling window pins the clock.
+ - **The value is never upper-cased, trimmed or repaired before a call.** `parseSsimDate` reads
+ upper case only, so `01jan26` is a refusal whose reason says so, and the printed call carries
+ the text as typed.
+ - **The locale feeds the comparison alone.** `parseSsimDate` takes no locale and the printed
+ call shows none; the select (`CONVERTER_LOCALES`) reaches only the pattern parser and the
+ month table, so a locale change redraws section 2 and the month table redraws only then.
+ The page never says the parser reads the machine's language: that is what naive code does.
+ - **The month table's "Short name" header is constant.** The caption, not the header, names the
+ locale. Under 40rem the header becomes each block's `data-col` label, and "fr-FR short name"
+ wrapped to two lines where "en short name" did not, so the table changed height by 258 px
+ when the locale changed. A CSS `content` label cannot hold a hidden twin.
+ - **A refusal is told apart from an empty field and from "no date".** NO SIGNAL (amber) shows
+ only when the library refused typed text. An empty field reads "nothing typed" and makes no
+ call; the pattern plate reads a neutral "no date" because a locale that does not know `JAN`
+ is a finding, not a fault. A raw `""` appears only in a printed call.
+ - **A reason asks the library again.** The site holds no grammar: a refusal with a window is
+ probed once with the text upper-cased (a hit is "lower case"), and a preset marks the one
+ case (`noSuchDay`) that no probe tells from a bad shape, for that exact value and window.
+ The probe uses `toUpperCase`, which no locale moves. The month table's letters come from
+ `formatSsimDate`, so the site holds no month list.
+ - **Out of scope, so nowhere in a preset, hint or reason:** `00XXX00` (the open-ended date) and
+ `DDMMM` with no year.
+ - **Every region is present in every state and holds still.** The hero plates, the reasons, the
+ comparison badge ("differs from SSIM", with a ghost twin), the month table and each call
+ frame draw every text they can show, hidden; a blank section keeps its empty frame at its
+ reserved height rather than hiding it. The strip stacks under a 40rem container.
+ - **Permalink `ssim`** at `/tools/ssim-date-reader/`: `preset` alone while the state matches
+ one, else `value`, `window` (`rolling`, a year, or empty), `locale` and `date`; empty
+ `value`, `window` and `date` are real answers and survive the link. The chat tool is
+ `showSsimDateReader` (`value`, `yearWindow`, `locale`, `date`; the registry maps `yearWindow`
+ to `window`), appended to `DOX_TOOL_DOCS`. A call passes only what the reader gave: never a
+ window they did not state, never a locale inferred from a place.
- **Cron in a Zone** (CORE-84, `/tools/cron-in-a-zone/`, `cronzone`): a Core tool that draws
`@northguild/gmt/recurrence`. The reader types a five-field cron line and picks a zone, a year
and one of that year's clock changes.
@@ -4332,7 +4377,7 @@ Shared hooks come first, then the globe, then the clock-change pages.
- **Example cards open their widget on the click.** The `CHAT_STARTERS` live in the widget
rail, not the empty chat, as a scrolling panel of bevelled cards (`ExamplesPanel.tsx`)
grouped by area. The areas are industries: `EXAMPLE_AREAS` is Core, Transport, Intermodal,
- GNSS, Finance and Healthcare, each heading carries its industry's icon (`INDUSTRY_ICON_PATHS` through `industryTag`),
+ GNSS, Finance, Healthcare and Aviation, each heading carries its industry's icon (`INDUSTRY_ICON_PATHS` through `industryTag`),
and a card's `area` is its tool page's tag. An industry with no tool has no area (Workforce and
Maritime gain one with their first tool). `startersByArea()` returns the groups in that order.
`chat-starters.test.ts` asserts each area is an industry with that industry's label and icon,
diff --git a/packages/gmt/README.md b/packages/gmt/README.md
index f0e10e6fd..01f719170 100644
--- a/packages/gmt/README.md
+++ b/packages/gmt/README.md
@@ -53,7 +53,7 @@ addZoned("2024-03-30T12:00:00+01:00[Europe/Berlin]", { hours: 24 }); // "2024-03
resolveLocal("2024-03-31T02:30:00", "Europe/Berlin", { disambiguation: "reject" }); // ""
```
-- **748 functions, to the nanosecond**, tested in 17 locales.
+- **751 functions, to the nanosecond**, tested in 17 locales.
- **Never throws.** ISO 8601 strings in. Invalid input returns `""`, `null`, `false` or `[]`.
The latest test counts, CI volume and the comparison with Luxon, date-fns, Moment.js, Day.js, Spacetime and `@internationalized/date` are on the [Why GMT](https://northguild.dev/gmt/why-gmt/) page. The full comparison and the method are on the [compare](https://northguild.dev/gmt/compare/) page.
@@ -79,9 +79,9 @@ convertUtcToZoned("2024-06-15T12:00:00Z", "Asia/Tokyo"); // "2024-06-15T21:00:00
```
Every function has a reference page with a live playground:
-[plain](https://northguild.dev/gmt/reference/plain/) · [zoned](https://northguild.dev/gmt/reference/zoned/) · [utc](https://northguild.dev/gmt/reference/utc/) · [unix](https://northguild.dev/gmt/reference/unix/) · [instant](https://northguild.dev/gmt/reference/instant/) · [calendar](https://northguild.dev/gmt/reference/calendar/) · [duration](https://northguild.dev/gmt/reference/duration/) · [interval](https://northguild.dev/gmt/reference/interval/) · [workforce](https://northguild.dev/gmt/reference/workforce/) · [span](https://northguild.dev/gmt/reference/span/) · [precision](https://northguild.dev/gmt/reference/precision/) · [recurrence](https://northguild.dev/gmt/reference/recurrence/) · [timescale](https://northguild.dev/gmt/reference/timescale/) · [gnss](https://northguild.dev/gmt/reference/gnss/) · [transport](https://northguild.dev/gmt/reference/transport/) · [intermodal](https://northguild.dev/gmt/reference/intermodal/) · [finance](https://northguild.dev/gmt/reference/finance/) · [healthcare](https://northguild.dev/gmt/reference/healthcare/)
+[plain](https://northguild.dev/gmt/reference/plain/) · [zoned](https://northguild.dev/gmt/reference/zoned/) · [utc](https://northguild.dev/gmt/reference/utc/) · [unix](https://northguild.dev/gmt/reference/unix/) · [instant](https://northguild.dev/gmt/reference/instant/) · [calendar](https://northguild.dev/gmt/reference/calendar/) · [duration](https://northguild.dev/gmt/reference/duration/) · [interval](https://northguild.dev/gmt/reference/interval/) · [workforce](https://northguild.dev/gmt/reference/workforce/) · [span](https://northguild.dev/gmt/reference/span/) · [precision](https://northguild.dev/gmt/reference/precision/) · [recurrence](https://northguild.dev/gmt/reference/recurrence/) · [timescale](https://northguild.dev/gmt/reference/timescale/) · [gnss](https://northguild.dev/gmt/reference/gnss/) · [transport](https://northguild.dev/gmt/reference/transport/) · [intermodal](https://northguild.dev/gmt/reference/intermodal/) · [finance](https://northguild.dev/gmt/reference/finance/) · [healthcare](https://northguild.dev/gmt/reference/healthcare/) · [aviation](https://northguild.dev/gmt/reference/aviation/)
-By industry: [Workforce](https://northguild.dev/gmt/industries/workforce/) · [Transport](https://northguild.dev/gmt/industries/transport/) · [Intermodal](https://northguild.dev/gmt/industries/intermodal/) · [GNSS](https://northguild.dev/gmt/industries/gnss/) · [Maritime](https://northguild.dev/gmt/industries/maritime/) · [Finance](https://northguild.dev/gmt/industries/finance/) · [Healthcare](https://northguild.dev/gmt/industries/healthcare/)
+By industry: [Workforce](https://northguild.dev/gmt/industries/workforce/) · [Transport](https://northguild.dev/gmt/industries/transport/) · [Intermodal](https://northguild.dev/gmt/industries/intermodal/) · [GNSS](https://northguild.dev/gmt/industries/gnss/) · [Maritime](https://northguild.dev/gmt/industries/maritime/) · [Finance](https://northguild.dev/gmt/industries/finance/) · [Healthcare](https://northguild.dev/gmt/industries/healthcare/) · [Aviation](https://northguild.dev/gmt/industries/aviation/)
Then the [guides](https://northguild.dev/gmt/guides/) show how to do each job, and the [tools](https://northguild.dev/gmt/tools/) let you try it on your own values.
diff --git a/packages/gmt/package.json b/packages/gmt/package.json
index c7012ac77..f1b4569ba 100644
--- a/packages/gmt/package.json
+++ b/packages/gmt/package.json
@@ -60,6 +60,18 @@
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
+ "aviation": [
+ "./dist/aviation/index.d.ts"
+ ],
+ "aviation/format": [
+ "./dist/aviation/format/index.d.ts"
+ ],
+ "aviation/parse": [
+ "./dist/aviation/parse/index.d.ts"
+ ],
+ "aviation/validate": [
+ "./dist/aviation/validate/index.d.ts"
+ ],
"calendar": [
"./dist/calendar/index.d.ts"
],
@@ -382,6 +394,22 @@
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
+ "./aviation": {
+ "types": "./dist/aviation/index.d.ts",
+ "default": "./dist/aviation/index.js"
+ },
+ "./aviation/format": {
+ "types": "./dist/aviation/format/index.d.ts",
+ "default": "./dist/aviation/format/index.js"
+ },
+ "./aviation/parse": {
+ "types": "./dist/aviation/parse/index.d.ts",
+ "default": "./dist/aviation/parse/index.js"
+ },
+ "./aviation/validate": {
+ "types": "./dist/aviation/validate/index.d.ts",
+ "default": "./dist/aviation/validate/index.js"
+ },
"./calendar": {
"types": "./dist/calendar/index.d.ts",
"default": "./dist/calendar/index.js"
diff --git a/packages/gmt/skills/_artifacts/domain_map.yaml b/packages/gmt/skills/_artifacts/domain_map.yaml
index dab52721c..a553ba2ef 100644
--- a/packages/gmt/skills/_artifacts/domain_map.yaml
+++ b/packages/gmt/skills/_artifacts/domain_map.yaml
@@ -27,7 +27,7 @@ domains:
description: Integrating gmt with application frameworks and linting tools
- name: Industry Layers
slug: industry-layers
- description: One skill per industry layer (gnss/, finance/, transport/, intermodal/, workforce/, healthcare/) drawing on the core skills; core namespaces such as timescale/ stay in the core skills
+ description: One skill per industry layer (gnss/, finance/, transport/, intermodal/, workforce/, healthcare/, aviation/) drawing on the core skills; core namespaces such as timescale/ stay in the core skills
- name: Contributor
slug: contributor
description: Library maintainer workflows — issues, PRs, implementation, testing
@@ -456,6 +456,23 @@ skills:
- Tell a real inserted leap second from a second 60 on an ordinary day in a FIX message
- Check whether a value is a FIX UTCTimestamp
+ - name: GMT Aviation
+ slug: gmt-aviation
+ domain: industry-layers
+ description: Read, write and check the IATA SSIM schedule date DDMMMYY (parseSsimDate/formatSsimDate/isValidSsimDate) — fixed English upper-case month letters that never go through Intl, a required yearWindow for the century, sentinels instead of exceptions
+ type: core
+ packages:
+ - '@northguild/gmt'
+ covers:
+ - parseSsimDate
+ - formatSsimDate
+ - isValidSsimDate
+ tasks:
+ - Read an SSIM schedule date such as 01JAN26 as an ISO date, in a century the caller states with yearWindow
+ - Write an ISO date as an SSIM date, refusing a year outside the window
+ - Check whether a value is a valid SSIM date
+ - Know that the month letters are a fixed English code, never read through Intl, and that lower case and other languages are not read
+
- name: GMT Transport
slug: gmt-transport
domain: industry-layers
diff --git a/packages/gmt/skills/_artifacts/skill_spec.md b/packages/gmt/skills/_artifacts/skill_spec.md
index bb33102af..c8fe6bce4 100644
--- a/packages/gmt/skills/_artifacts/skill_spec.md
+++ b/packages/gmt/skills/_artifacts/skill_spec.md
@@ -10,7 +10,7 @@ Temporal-based date and time utilities with timezone support and polyfill integr
| Arithmetic | Add/subtract, durations, interval range math | gmt-arithmetic |
| Zoned Date Operations | IANA timezone-aware date operations, DST disambiguation | gmt-timezone |
| Integration | Application framework integration, cache keys, lint package selection | gmt-integration |
-| Industry Layers | One skill per industry layer, drawing on the core skills | gmt-gnss, gmt-finance, gmt-transport, gmt-intermodal, gmt-workforce, gmt-healthcare |
+| Industry Layers | One skill per industry layer, drawing on the core skills | gmt-gnss, gmt-finance, gmt-transport, gmt-intermodal, gmt-workforce, gmt-healthcare, gmt-aviation |
| Contributor | Library maintainer workflows — issues, PRs, implementation, testing | issue-creation, pr-contribution, new-method-implementation, unit-test-generation, api-expansion-workflow |
## Skill Inventory
@@ -23,6 +23,7 @@ Temporal-based date and time utilities with timezone support and polyfill integr
| gmt-integration | composition | Integration | Cache keys, router/query params, table-sort keys, foreign epochs, TAI and leap seconds (timescale/), lint package selection | |
| gmt-gnss | core | Industry Layers | utcToGnss, gnssToUtc, gnssWeekToUtc, utcToGnssWeek, rinexWeekToUtc, utcToRinexWeek (gnss/) | |
| gmt-finance | core | Industry Layers | parseFixUtcTimestamp, formatFixUtcTimestamp, isValidFixUtcTimestamp (finance/) | |
+| gmt-aviation | core | Industry Layers | parseSsimDate, formatSsimDate, isValidSsimDate (aviation/) | |
| gmt-transport | core | Industry Layers | transitTime, etaAtZone, dwellTime, scheduleDelivery, cutoffAt, classifyPunctuality, nextDeparture (transport/) | |
| gmt-intermodal | core | Industry Layers | freeTimeExpiry, chargeableDays, demurrageClock, billingTimeline, bolTimestamp, EDI and EPCIS timestamps (intermodal/) | |
| gmt-workforce | core | Industry Layers | evaluateDutyLog, dutyViolations, dutyDayFor, dutyTotals (workforce/) | |
@@ -66,7 +67,8 @@ examples of industry functions.
- **Consumer skills** (shipped in the npm tarball): `skills/gmt-basics/`,
`skills/gmt-arithmetic/`, `skills/gmt-timezone/`, `skills/gmt-integration/`,
`skills/gmt-gnss/`, `skills/gmt-finance/`, `skills/gmt-transport/`, `skills/gmt-intermodal/`,
- `skills/gmt-workforce/`, `skills/gmt-healthcare/`
+ `skills/gmt-workforce/`, `skills/gmt-healthcare/`,
+ `skills/gmt-aviation/`
— lightweight routing pointers (~30-60 lines each) that point agents to the
docs site and the JSDoc in the installed package for full API details.
- **Contributor skills** (excluded from the npm tarball via `.npmignore`):
@@ -74,7 +76,7 @@ examples of industry functions.
## Recommended Skill File Structure
-- **Consumer skills:** gmt-basics, gmt-arithmetic, gmt-timezone, gmt-integration, gmt-gnss, gmt-finance, gmt-transport, gmt-intermodal, gmt-workforce, gmt-healthcare
+- **Consumer skills:** gmt-basics, gmt-arithmetic, gmt-timezone, gmt-integration, gmt-gnss, gmt-finance, gmt-transport, gmt-intermodal, gmt-workforce, gmt-healthcare, gmt-aviation
- **Contributor skills:** issue-creation, pr-contribution, new-method-implementation, unit-test-generation, api-expansion-workflow
## Notes
diff --git a/packages/gmt/skills/_artifacts/skill_tree.yaml b/packages/gmt/skills/_artifacts/skill_tree.yaml
index bc06521e4..f393cc51a 100644
--- a/packages/gmt/skills/_artifacts/skill_tree.yaml
+++ b/packages/gmt/skills/_artifacts/skill_tree.yaml
@@ -172,6 +172,22 @@ skills:
- 'northguild/gmt:packages/gmt/src/finance/validate/index.ts'
- 'northguild/gmt:packages/gmt/src/types/fix.ts'
+ - name: GMT Aviation
+ slug: gmt-aviation
+ type: core
+ domain: industry-layers
+ path: 'skills/gmt-aviation/SKILL.md'
+ package: 'packages/gmt'
+ description: Read, write and check the IATA SSIM schedule date DDMMMYY (parseSsimDate/formatSsimDate/isValidSsimDate) — fixed English upper-case month letters that never go through Intl, a required yearWindow for the century, sentinels instead of exceptions
+ requires:
+ - gmt-intermodal
+ sources:
+ - 'northguild/gmt:apps/dox/src/content/docs/guides/industries/aviation-message-times.mdx'
+ - 'northguild/gmt:packages/gmt/src/aviation/format/index.ts'
+ - 'northguild/gmt:packages/gmt/src/aviation/parse/index.ts'
+ - 'northguild/gmt:packages/gmt/src/aviation/validate/index.ts'
+ - 'northguild/gmt:packages/gmt/src/types/two-digit-year.ts'
+
- name: GMT Transport
slug: gmt-transport
type: core
diff --git a/packages/gmt/skills/gmt-aviation/SKILL.md b/packages/gmt/skills/gmt-aviation/SKILL.md
new file mode 100644
index 000000000..4bf47ff33
--- /dev/null
+++ b/packages/gmt/skills/gmt-aviation/SKILL.md
@@ -0,0 +1,80 @@
+---
+name: gmt-aviation
+description: >
+ Aviation schedule dates in @northguild/gmt/aviation — the seven-character
+ IATA SSIM date (DDMMMYY, e.g. 01JAN26) read, written and checked:
+ parseSsimDate, formatSsimDate and isValidSsimDate. The month is a fixed
+ English letter code that never goes through Intl, and the century is the
+ caller's through a required yearWindow. Reads the docs site (llms.txt) and
+ the installed package's JSDoc; a routing pointer, not an API dump.
+sources:
+ - 'northguild/gmt:apps/dox/src/content/docs/guides/industries/aviation-message-times.mdx'
+ - 'northguild/gmt:packages/gmt/src/aviation/format/index.ts'
+ - 'northguild/gmt:packages/gmt/src/aviation/parse/index.ts'
+ - 'northguild/gmt:packages/gmt/src/aviation/validate/index.ts'
+ - 'northguild/gmt:packages/gmt/src/types/two-digit-year.ts'
+metadata:
+ type: core
+ library: '@northguild/gmt'
+ library_version: '1.21.0'
+---
+
+# GMT Aviation
+
+Use this skill when the task is reading or writing a date from an IATA SSIM
+schedule file, such as `01JAN26` in a validity period. The `yearWindow` option
+is the same one the EDI parsers take; see the `gmt-intermodal` skill.
+
+## When to load
+
+- The user has an SSIM date such as `25OCT26` to read, or an ISO date to write
+ in that form.
+- The user asks whether a value is a valid SSIM date.
+
+## Core rules
+
+1. **An SSIM date is not a date pattern.** It is `DDMMMYY`: two digits of day,
+ three upper-case letters of month, two digits of year. Do not read it with
+ `parseDateWithPattern` and `ddMMMyy`: that reads month names from the
+ platform's CLDR data and accepts `01jan26`. Use the three functions.
+2. **The month letters are a fixed English code.** `JAN` to `DEC`, upper case
+ only, read from a constant table and never through `Intl`, so the machine's
+ language changes nothing. `01jan26`, `01Jan26`, `01ENE26` and `01JANV26`
+ return `""`.
+3. **The century is the caller's, and there is no default.** `yearWindow` is
+ required: a fixed first year (`2000`) for stored schedules, or `"rolling"`
+ for live feeds. It places the two-digit year in a hundred-year window.
+ ```typescript
+ parseSsimDate("01JAN26", { yearWindow: 2000 }); // "2026-01-01"
+ parseSsimDate("16DEC09", { yearWindow: 1950 }); // "2009-12-16"
+ parseSsimDate("29FEB00", { yearWindow: 2000 }); // "2000-02-29"
+ parseSsimDate("29FEB00", { yearWindow: 1900 }); // ""
+ ```
+4. **Sentinels, never exceptions.** Without `yearWindow` (or with an options
+ argument that is not an object) the parser and the formatter return `""` and
+ the validator returns `false`. So do a day that does not exist (`31FEB26`),
+ non-ASCII digits and extra characters. No function throws.
+5. **The formatter refuses a year outside the window.** It would read back as
+ another century, so `formatSsimDate` returns `""` for it. It takes an ISO
+ calendar date; a date-time, an instant or another calendar returns `""`.
+ ```typescript
+ formatSsimDate("2026-10-25", { yearWindow: 2000 }); // "25OCT26"
+ formatSsimDate("1999-12-31", { yearWindow: 2000 }); // ""
+ ```
+6. **Validate before you trust.** `isValidSsimDate(value, options)` is `true`
+ exactly when the parser returns a date.
+7. **Read the docs site.** This skill is a routing pointer. The map of the
+ docs is `https://northguild.dev/gmt/llms.txt`, and each page has a `.md`
+ twin that holds its text. The JSDoc ships in the installed package:
+ `node_modules/@northguild/gmt/dist/**/*.d.ts`.
+
+## Key functions
+
+- **SSIM dates** (`@northguild/gmt/aviation`): `parseSsimDate`,
+ `formatSsimDate`, `isValidSsimDate`
+
+## References
+
+- [aviation reference](https://northguild.dev/gmt/reference/aviation/)
+- [Docs map for agents (llms.txt)](https://northguild.dev/gmt/llms.txt)
+- [GMT Intermodal skill](../gmt-intermodal/SKILL.md)
diff --git a/packages/gmt/src/aviation/README.md b/packages/gmt/src/aviation/README.md
new file mode 100644
index 000000000..71b7b709e
--- /dev/null
+++ b/packages/gmt/src/aviation/README.md
@@ -0,0 +1,3 @@
+# Aviation API
+
+See the full reference at [/reference/aviation](/reference/aviation).
diff --git a/packages/gmt/src/aviation/format/formatSsimDate.test.ts b/packages/gmt/src/aviation/format/formatSsimDate.test.ts
new file mode 100644
index 000000000..c1ee836af
--- /dev/null
+++ b/packages/gmt/src/aviation/format/formatSsimDate.test.ts
@@ -0,0 +1,240 @@
+import { Temporal } from "../../internal/temporal";
+import { countIntlConstructions } from "../../test/countIntlConstructions";
+import { MustTestLocales } from "../../test/localeMatrix";
+import { mockTemporalPlainDateFromThrow } from "../../test/mocks";
+import { NON_STRINGS } from "../../test/nonStrings";
+import { SSIM_VALID_ROWS } from "../../test/ssimDateRows";
+import { isValidDate } from "../../plain/validate/isValidDate";
+import { formatSsimDate } from "./formatSsimDate";
+
+/**
+ * Every expected value is read off the date by hand: the day, the month's letters, and the
+ * year modulo 100.
+ */
+describe("formatSsimDate", () => {
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ it.each`
+ value | yearWindow | expected
+ ${"2026-10-25"} | ${2000} | ${"25OCT26"}
+ ${"2026-01-01"} | ${2000} | ${"01JAN26"}
+ ${"2000-01-01"} | ${2000} | ${"01JAN00"}
+ ${"2099-12-31"} | ${2000} | ${"31DEC99"}
+ ${"2000-02-29"} | ${2000} | ${"29FEB00"}
+ ${"1950-01-01"} | ${1950} | ${"01JAN50"}
+ ${"2049-12-31"} | ${1950} | ${"31DEC49"}
+ ${"2010-04-05"} | ${1950} | ${"05APR10"}
+ ${"0000-01-01"} | ${0} | ${"01JAN00"}
+ ${"9999-12-31"} | ${9900} | ${"31DEC99"}
+ ${"2026-01-09"} | ${2000} | ${"09JAN26"}
+ ${"2026-02-09"} | ${2000} | ${"09FEB26"}
+ ${"2026-03-09"} | ${2000} | ${"09MAR26"}
+ ${"2026-04-09"} | ${2000} | ${"09APR26"}
+ ${"2026-05-09"} | ${2000} | ${"09MAY26"}
+ ${"2026-06-09"} | ${2000} | ${"09JUN26"}
+ ${"2026-07-09"} | ${2000} | ${"09JUL26"}
+ ${"2026-08-09"} | ${2000} | ${"09AUG26"}
+ ${"2026-09-09"} | ${2000} | ${"09SEP26"}
+ ${"2026-10-09"} | ${2000} | ${"09OCT26"}
+ ${"2026-11-09"} | ${2000} | ${"09NOV26"}
+ ${"2026-12-09"} | ${2000} | ${"09DEC26"}
+ ${"2026-01-01[u-ca=iso8601]"} | ${2000} | ${"01JAN26"}
+ ${"2026-10-25[Europe/Paris]"} | ${2000} | ${"25OCT26"}
+ `(
+ "writes '$value' in window $yearWindow as $expected",
+ ({ value, yearWindow, expected }) => {
+ expect(formatSsimDate(value, { yearWindow })).toBe(expected);
+ },
+ );
+
+ it.each`
+ value | yearWindow | reason
+ ${"1999-12-31"} | ${2000} | ${"one year before a window from 2000"}
+ ${"2100-01-01"} | ${2000} | ${"one year after a window from 2000"}
+ ${"1949-12-31"} | ${1950} | ${"one year before a window from 1950"}
+ ${"2050-01-01"} | ${1950} | ${"one year after a window from 1950"}
+ ${"2026-10-25T10:00"} | ${2000} | ${"a date-time"}
+ ${"2026-10-25T10:00:00Z"} | ${2000} | ${"an instant"}
+ ${"2026-10-25[u-ca=japanese]"} | ${2000} | ${"a non-ISO calendar"}
+ ${"2026-10-25[!foo=bar]"} | ${2000} | ${"a critical unknown annotation"}
+ ${"2026-02-30"} | ${2000} | ${"February has no day 30"}
+ ${"2025-02-29"} | ${2000} | ${"2025 is not a leap year"}
+ ${"2026-13-01"} | ${2000} | ${"there is no month 13"}
+ ${"25OCT26"} | ${2000} | ${"an SSIM date is not this input"}
+ ${""} | ${2000} | ${"empty"}
+ ${" 2026-10-25"} | ${2000} | ${"leading space"}
+ ${"+010000-01-01"} | ${2000} | ${"year 10000 is outside every window"}
+ `(
+ "returns '' for '$value' (window $yearWindow): $reason",
+ ({ value, yearWindow }) => {
+ expect(formatSsimDate(value, { yearWindow })).toBe("");
+ },
+ );
+
+ it("agrees with isValidDate on the basic ISO format", () => {
+ const expected = isValidDate("20261025") ? "25OCT26" : "";
+ expect(formatSsimDate("20261025", { yearWindow: 2000 })).toBe(expected);
+ });
+
+ it.each`
+ options | reason
+ ${{}} | ${"no yearWindow"}
+ ${{ yearWindow: -1 }} | ${"below 0"}
+ ${{ yearWindow: 9901 }} | ${"above 9900"}
+ ${{ yearWindow: 2000.5 }} | ${"not an integer"}
+ ${{ yearWindow: Number.NaN }} | ${"NaN"}
+ ${{ yearWindow: "2000" }} | ${"a numeric string"}
+ ${{ yearWindow: null }} | ${"null"}
+ ${{ yearWindow: "Rolling" }} | ${"a capitalised string is not 'rolling'"}
+ `("returns '' for the window $reason", ({ options }) => {
+ expect(formatSsimDate("2026-10-25", options)).toBe("");
+ });
+
+ describe("arguments", () => {
+ it("returns '' for every non-string value", () => {
+ for (const [kind, make] of NON_STRINGS) {
+ expect(
+ formatSsimDate(make() as string, { yearWindow: 2000 }),
+ kind,
+ ).toBe("");
+ }
+ });
+
+ it("returns '' for a String object", () => {
+ expect(
+ formatSsimDate(new String("2026-10-25") as string, {
+ yearWindow: 2000,
+ }),
+ ).toBe("");
+ });
+
+ it("returns '' for omitted options", () => {
+ expect(formatSsimDate("2026-10-25", undefined as never)).toBe("");
+ });
+
+ it.each`
+ options
+ ${null}
+ ${"x"}
+ ${1}
+ ${true}
+ `("returns '' for the non-object options $options", ({ options }) => {
+ expect(formatSsimDate("2026-10-25", options)).toBe("");
+ });
+
+ it("reads a function carrying yearWindow like any options bag", () => {
+ const options = Object.assign(() => {}, { yearWindow: 2000 });
+ expect(formatSsimDate("2026-10-25", options)).toBe("25OCT26");
+ });
+
+ it("returns '' when the yearWindow getter throws", () => {
+ const options = {
+ get yearWindow(): number {
+ throw new Error("hostile getter");
+ },
+ };
+ expect(formatSsimDate("2026-10-25", options)).toBe("");
+ });
+
+ it("returns '' when Temporal.PlainDate.from throws", () => {
+ mockTemporalPlainDateFromThrow();
+ expect(formatSsimDate("2026-10-25", { yearWindow: 2000 })).toBe("");
+ });
+ });
+
+ describe("rolling window", () => {
+ it.each`
+ now | value | expected
+ ${"2026-06-01T00:00:00Z"} | ${"1976-01-01"} | ${"01JAN76"}
+ ${"2026-06-01T00:00:00Z"} | ${"2075-12-31"} | ${"31DEC75"}
+ ${"2026-06-01T00:00:00Z"} | ${"1975-12-31"} | ${""}
+ ${"2026-06-01T00:00:00Z"} | ${"2076-01-01"} | ${""}
+ ${"2077-06-01T00:00:00Z"} | ${"2027-01-01"} | ${"01JAN27"}
+ ${"2077-06-01T00:00:00Z"} | ${"2126-12-31"} | ${"31DEC26"}
+ ${"2077-06-01T00:00:00Z"} | ${"2026-12-31"} | ${""}
+ ${"2026-12-31T23:59:59Z"} | ${"1976-01-01"} | ${"01JAN76"}
+ ${"2027-01-01T00:00:00Z"} | ${"1976-01-01"} | ${""}
+ `(
+ "writes '$value' as '$expected' when now is $now",
+ ({ now, value, expected }) => {
+ vi.spyOn(Temporal.Now, "instant").mockReturnValue(
+ Temporal.Instant.from(now),
+ );
+ expect(formatSsimDate(value, { yearWindow: "rolling" })).toBe(expected);
+ },
+ );
+ });
+
+ describe("locale independence", () => {
+ function stubLocale(locale: string): void {
+ vi.spyOn(
+ Intl.DateTimeFormat.prototype,
+ "resolvedOptions",
+ ).mockReturnValue({
+ locale,
+ } as Intl.ResolvedDateTimeFormatOptions);
+ if (typeof navigator !== "undefined") {
+ vi.spyOn(navigator, "language", "get").mockReturnValue(locale);
+ }
+ }
+
+ it.each`
+ locale
+ ${MustTestLocales.enUS}
+ ${MustTestLocales.enGB}
+ ${MustTestLocales.deDE}
+ ${MustTestLocales.frFR}
+ ${MustTestLocales.esES}
+ ${MustTestLocales.itIT}
+ ${MustTestLocales.ptPT}
+ ${MustTestLocales.svSE}
+ ${MustTestLocales.isIS}
+ ${MustTestLocales.zhCN}
+ ${MustTestLocales.zhTW}
+ ${MustTestLocales.jaJP}
+ ${MustTestLocales.koKR}
+ ${MustTestLocales.arSA}
+ ${MustTestLocales.heIL}
+ ${MustTestLocales.ruRU}
+ ${MustTestLocales.trTR}
+ `(
+ "gives the fixed answers under the ambient locale $locale",
+ ({ locale }) => {
+ stubLocale(locale);
+ const options = { yearWindow: 2000 };
+ expect(formatSsimDate("2026-10-25", options)).toBe("25OCT26");
+ expect(formatSsimDate("2026-05-01", options)).toBe("01MAY26");
+ expect(formatSsimDate("2026-12-31", options)).toBe("31DEC26");
+ },
+ );
+
+ it("constructs no Intl formatter", () => {
+ const run = (): void => {
+ for (const { expected, yearWindow } of SSIM_VALID_ROWS) {
+ formatSsimDate(expected, { yearWindow });
+ }
+ };
+ expect(
+ countIntlConstructions(["DateTimeFormat", "NumberFormat"], run, run),
+ ).toBe(0);
+ });
+
+ it("calls no locale-sensitive string method", () => {
+ const upper = vi.spyOn(String.prototype, "toLocaleUpperCase");
+ const lower = vi.spyOn(String.prototype, "toLocaleLowerCase");
+ const compare = vi.spyOn(String.prototype, "localeCompare");
+ for (const { expected, yearWindow } of SSIM_VALID_ROWS) {
+ formatSsimDate(expected, { yearWindow });
+ }
+ const calls = [
+ upper.mock.calls.length,
+ lower.mock.calls.length,
+ compare.mock.calls.length,
+ ];
+ vi.restoreAllMocks();
+ expect(calls).toStrictEqual([0, 0, 0]);
+ });
+ });
+});
diff --git a/packages/gmt/src/aviation/format/formatSsimDate.ts b/packages/gmt/src/aviation/format/formatSsimDate.ts
new file mode 100644
index 000000000..7f58376b4
--- /dev/null
+++ b/packages/gmt/src/aviation/format/formatSsimDate.ts
@@ -0,0 +1,64 @@
+import { isOptionsArgument } from "../../internal";
+import { isDateString } from "../../internal/inputChecks";
+import { writeSsimDate } from "../../internal/ssimDate";
+import { Temporal } from "../../internal/temporal";
+import { readYearWindowStart } from "../../internal/yearWindowStart";
+import type { TwoDigitYearOptions } from "../../types/two-digit-year";
+
+/**
+ * Write an ISO 8601 date as an SSIM schedule date. The inverse of `parseSsimDate`.
+ *
+ * - **What it writes.** An SSIM date is `DDMMMYY`: two digits of day, the first three letters of
+ * the month's English name in upper case, and two digits of year.
+ * - **Locale-independent.** The letters are a fixed code. They are never read or written
+ * through `Intl`, so the platform's or the caller's locale changes nothing.
+ * - **`value`** is a date, as `isValidDate` accepts it, in the ISO calendar. A date-time, an
+ * instant or a non-ISO calendar returns `""`.
+ * - **The year must lie inside the window.** `options.yearWindow` is a fixed first year or
+ * `"rolling"`. A year outside the hundred years it covers returns `""`: written as two
+ * digits, it would read back as another century. So
+ * `parseSsimDate(formatSsimDate(d, o), o)` is `d` for every canonical date it writes, with the
+ * same fixed window.
+ * - **Without `yearWindow`** the result is `""`.
+ * - **Sources.** The day and the month letters: SSIM Chapter 6, as two guides give it. They are
+ * ACL's _An Introductory Guide to SSIM_ (April 2021), which shows `01APR`, and AECFA's
+ * _Quick Guide to Using the IATA SSIM format_, which is no longer online. The seven-character
+ * form: EUROCONTROL's _CSST Users Guide_ §3.2 Figure 1. Avinor's SSIM description shows a
+ * two-digit year in the validity period. IATA's own Chapter 7 text was not reached.
+ *
+ * @param value An ISO 8601 calendar date (e.g. "2026-10-25")
+ * @param options The hundred-year window the year must lie in
+ * @returns the `DDMMMYY` string ("25OCT26"), or "" on invalid input
+ *
+ * @example formatSsimDate("2026-10-25", { yearWindow: 2000 }) // "25OCT26"
+ * @example formatSsimDate("2000-02-29", { yearWindow: 2000 }) // "29FEB00"
+ * @example formatSsimDate("2049-12-31", { yearWindow: 1950 }) // "31DEC49"
+ * @example formatSsimDate("1999-12-31", { yearWindow: 2000 }) // ""
+ * @example formatSsimDate("2026-10-25", { yearWindow: "rolling" }) // "25OCT26" (while the current UTC year is 1977–2076)
+ * @example formatSsimDate("2026-10-25", {}) // ""
+ * @example formatSsimDate("2026-10-25T10:00", { yearWindow: 2000 }) // ""
+ */
+export function formatSsimDate(
+ value: string,
+ options: TwoDigitYearOptions,
+): string {
+ try {
+ if (typeof value !== "string" || !isDateString(value)) {
+ return "";
+ }
+ if (!isOptionsArgument(options)) {
+ return "";
+ }
+ const windowStart = readYearWindowStart(options);
+ if (windowStart === null) {
+ return "";
+ }
+ const date = Temporal.PlainDate.from(value);
+ if (date.year < windowStart || date.year > windowStart + 99) {
+ return "";
+ }
+ return writeSsimDate(date.day, date.month, date.year % 100);
+ } catch {
+ return "";
+ }
+}
diff --git a/packages/gmt/src/aviation/format/index.ts b/packages/gmt/src/aviation/format/index.ts
new file mode 100644
index 000000000..98cc0e182
--- /dev/null
+++ b/packages/gmt/src/aviation/format/index.ts
@@ -0,0 +1 @@
+export * from "./formatSsimDate";
diff --git a/packages/gmt/src/aviation/index.ts b/packages/gmt/src/aviation/index.ts
new file mode 100644
index 000000000..663347f97
--- /dev/null
+++ b/packages/gmt/src/aviation/index.ts
@@ -0,0 +1,5 @@
+// Re-export `Temporal`, `Intl` and `toTemporalInstant` from the internal seam so every namespace subpath offers them
+export { Intl, Temporal, toTemporalInstant } from "../internal/temporal";
+export * from "./format";
+export * from "./parse";
+export * from "./validate";
diff --git a/packages/gmt/src/aviation/parse/index.ts b/packages/gmt/src/aviation/parse/index.ts
new file mode 100644
index 000000000..3eddd8b96
--- /dev/null
+++ b/packages/gmt/src/aviation/parse/index.ts
@@ -0,0 +1 @@
+export * from "./parseSsimDate";
diff --git a/packages/gmt/src/aviation/parse/parseSsimDate.test.ts b/packages/gmt/src/aviation/parse/parseSsimDate.test.ts
new file mode 100644
index 000000000..2f75d1818
--- /dev/null
+++ b/packages/gmt/src/aviation/parse/parseSsimDate.test.ts
@@ -0,0 +1,196 @@
+import { Temporal } from "../../internal/temporal";
+import { countIntlConstructions } from "../../test/countIntlConstructions";
+import { MustTestLocales } from "../../test/localeMatrix";
+import { mockTemporalPlainDateFromThrow } from "../../test/mocks";
+import { NON_STRINGS } from "../../test/nonStrings";
+import { SSIM_SENTINEL_ROWS, SSIM_VALID_ROWS } from "../../test/ssimDateRows";
+import { parseSsimDate } from "./parseSsimDate";
+
+/**
+ * Every expected year is read off the grammar by hand: the window start's century plus `YY`,
+ * plus 100 when that is below the start. Each expected date was also run through the polyfill.
+ */
+describe("parseSsimDate", () => {
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ it.each(SSIM_VALID_ROWS)(
+ "reads '$value' in window $yearWindow as $expected",
+ ({ value, yearWindow, expected }) => {
+ expect(parseSsimDate(value, { yearWindow })).toBe(expected);
+ },
+ );
+
+ it.each(SSIM_SENTINEL_ROWS)(
+ "returns '' for '$value' (window $yearWindow): $reason",
+ ({ value, yearWindow }) => {
+ expect(parseSsimDate(value, { yearWindow })).toBe("");
+ },
+ );
+
+ it.each`
+ options | reason
+ ${{}} | ${"no yearWindow"}
+ ${{ yearWindow: undefined }} | ${"yearWindow undefined"}
+ ${{ yearWindow: -1 }} | ${"below 0"}
+ ${{ yearWindow: 9901 }} | ${"above 9900"}
+ ${{ yearWindow: 2000.5 }} | ${"not an integer"}
+ ${{ yearWindow: Number.NaN }} | ${"NaN"}
+ ${{ yearWindow: Infinity }} | ${"Infinity"}
+ ${{ yearWindow: "2000" }} | ${"a numeric string"}
+ ${{ yearWindow: null }} | ${"null"}
+ ${{ yearWindow: "Rolling" }} | ${"a capitalised string is not 'rolling'"}
+ `("returns '' for the window $reason", ({ options }) => {
+ expect(parseSsimDate("01JAN26", options)).toBe("");
+ });
+
+ describe("arguments", () => {
+ it("returns '' for every non-string value", () => {
+ for (const [kind, make] of NON_STRINGS) {
+ expect(
+ parseSsimDate(make() as string, { yearWindow: 2000 }),
+ kind,
+ ).toBe("");
+ }
+ });
+
+ it("returns '' for a String object", () => {
+ expect(
+ parseSsimDate(new String("01JAN26") as string, { yearWindow: 2000 }),
+ ).toBe("");
+ });
+
+ it("returns '' for omitted options", () => {
+ expect(parseSsimDate("01JAN26", undefined as never)).toBe("");
+ });
+
+ it.each`
+ options
+ ${null}
+ ${"x"}
+ ${1}
+ ${true}
+ `("returns '' for the non-object options $options", ({ options }) => {
+ expect(parseSsimDate("01JAN26", options)).toBe("");
+ });
+
+ it("reads a function carrying yearWindow like any options bag", () => {
+ const options = Object.assign(() => {}, { yearWindow: 2000 });
+ expect(parseSsimDate("01JAN26", options)).toBe("2026-01-01");
+ });
+
+ it("returns '' when the yearWindow getter throws", () => {
+ const options = {
+ get yearWindow(): number {
+ throw new Error("hostile getter");
+ },
+ };
+ expect(parseSsimDate("01JAN26", options)).toBe("");
+ });
+
+ it("returns '' when Temporal.PlainDate.from throws", () => {
+ mockTemporalPlainDateFromThrow();
+ expect(parseSsimDate("01JAN26", { yearWindow: 2000 })).toBe("");
+ });
+ });
+
+ describe("rolling window", () => {
+ function setNow(instant: string): void {
+ vi.spyOn(Temporal.Now, "instant").mockReturnValue(
+ Temporal.Instant.from(instant),
+ );
+ }
+
+ it.each`
+ now | value | expected
+ ${"2026-06-01T00:00:00Z"} | ${"01JAN76"} | ${"1976-01-01"}
+ ${"2026-06-01T00:00:00Z"} | ${"31DEC75"} | ${"2075-12-31"}
+ ${"2026-06-01T00:00:00Z"} | ${"01JAN26"} | ${"2026-01-01"}
+ ${"2077-06-01T00:00:00Z"} | ${"01JAN26"} | ${"2126-01-01"}
+ ${"2026-12-31T23:59:59Z"} | ${"01JAN76"} | ${"1976-01-01"}
+ ${"2027-01-01T00:00:00Z"} | ${"01JAN76"} | ${"2076-01-01"}
+ ${"2051-06-01T00:00:00Z"} | ${"29FEB00"} | ${""}
+ ${"2026-06-01T00:00:00Z"} | ${"29FEB00"} | ${"2000-02-29"}
+ `(
+ "reads '$value' as '$expected' when now is $now",
+ ({ now, value, expected }) => {
+ setNow(now);
+ expect(parseSsimDate(value, { yearWindow: "rolling" })).toBe(expected);
+ },
+ );
+ });
+
+ describe("locale independence", () => {
+ function stubLocale(locale: string): void {
+ vi.spyOn(
+ Intl.DateTimeFormat.prototype,
+ "resolvedOptions",
+ ).mockReturnValue({
+ locale,
+ } as Intl.ResolvedDateTimeFormatOptions);
+ if (typeof navigator !== "undefined") {
+ vi.spyOn(navigator, "language", "get").mockReturnValue(locale);
+ }
+ }
+
+ it.each`
+ locale
+ ${MustTestLocales.enUS}
+ ${MustTestLocales.enGB}
+ ${MustTestLocales.deDE}
+ ${MustTestLocales.frFR}
+ ${MustTestLocales.esES}
+ ${MustTestLocales.itIT}
+ ${MustTestLocales.ptPT}
+ ${MustTestLocales.svSE}
+ ${MustTestLocales.isIS}
+ ${MustTestLocales.zhCN}
+ ${MustTestLocales.zhTW}
+ ${MustTestLocales.jaJP}
+ ${MustTestLocales.koKR}
+ ${MustTestLocales.arSA}
+ ${MustTestLocales.heIL}
+ ${MustTestLocales.ruRU}
+ ${MustTestLocales.trTR}
+ `(
+ "gives the fixed answers under the ambient locale $locale",
+ ({ locale }) => {
+ stubLocale(locale);
+ const options = { yearWindow: 2000 };
+ expect(parseSsimDate("01JAN26", options)).toBe("2026-01-01");
+ expect(parseSsimDate("25OCT26", options)).toBe("2026-10-25");
+ expect(parseSsimDate("01jan26", options)).toBe("");
+ expect(parseSsimDate("01ENE26", options)).toBe("");
+ expect(parseSsimDate("01JANV26", options)).toBe("");
+ },
+ );
+
+ it("constructs no Intl formatter", () => {
+ const run = (): void => {
+ for (const { value, yearWindow } of SSIM_VALID_ROWS) {
+ parseSsimDate(value, { yearWindow });
+ }
+ };
+ expect(
+ countIntlConstructions(["DateTimeFormat", "NumberFormat"], run, run),
+ ).toBe(0);
+ });
+
+ it("calls no locale-sensitive string method", () => {
+ const upper = vi.spyOn(String.prototype, "toLocaleUpperCase");
+ const lower = vi.spyOn(String.prototype, "toLocaleLowerCase");
+ const compare = vi.spyOn(String.prototype, "localeCompare");
+ for (const { value, yearWindow } of SSIM_VALID_ROWS) {
+ parseSsimDate(value, { yearWindow });
+ }
+ const calls = [
+ upper.mock.calls.length,
+ lower.mock.calls.length,
+ compare.mock.calls.length,
+ ];
+ vi.restoreAllMocks();
+ expect(calls).toStrictEqual([0, 0, 0]);
+ });
+ });
+});
diff --git a/packages/gmt/src/aviation/parse/parseSsimDate.ts b/packages/gmt/src/aviation/parse/parseSsimDate.ts
new file mode 100644
index 000000000..71e8a8a4d
--- /dev/null
+++ b/packages/gmt/src/aviation/parse/parseSsimDate.ts
@@ -0,0 +1,71 @@
+import { isOptionsArgument } from "../../internal";
+import { readSsimDateFields } from "../../internal/ssimDate";
+import { Temporal } from "../../internal/temporal";
+import { twoDigitYear } from "../../internal/twoDigitYear";
+import { readYearWindowStart } from "../../internal/yearWindowStart";
+import type { TwoDigitYearOptions } from "../../types/two-digit-year";
+
+/**
+ * Parse an SSIM schedule date as an ISO 8601 date.
+ *
+ * - **What it reads.** An SSIM date is `DDMMMYY`: two digits of day, the first three letters of
+ * the month's English name in upper case (`JAN` … `DEC`), and two digits of year. The result
+ * is an ISO `PlainDate` string.
+ * - **Locale-independent.** The month letters are a fixed code, not a translation. They are
+ * never read through `Intl`, so the platform's or the caller's locale changes nothing. Lower
+ * and mixed case (`jan`, `Jan`) and other languages (`ENE`, `JANV`) return `""`.
+ * - **The century is the caller's.** `options.yearWindow` places `YY` in a hundred-year window:
+ * a fixed first year, for stored schedules, or `"rolling"`, for live feeds. Without
+ * `yearWindow` the result is `""`.
+ * - **Days must exist.** A day that does not exist in that month and windowed year returns `""`.
+ * `29FEB00` is a date in a window from 2000, and not in one from 1900.
+ * - **Sources.** The day and the month letters: SSIM Chapter 6, as two guides give it. They are
+ * ACL's _An Introductory Guide to SSIM_ (April 2021), which shows `01APR`, and AECFA's
+ * _Quick Guide to Using the IATA SSIM format_, which is no longer online. The seven-character
+ * form: EUROCONTROL's _CSST Users Guide_ §3.2 Figure 1. Avinor's SSIM description shows a
+ * two-digit year in the validity period. IATA's own Chapter 7 text was not reached.
+ *
+ * @param value An SSIM date, `DDMMMYY` (e.g. "01JAN26")
+ * @param options The hundred-year window a two-digit year is read in
+ * @returns the ISO date ("2026-01-01"), or "" on invalid input
+ *
+ * @example parseSsimDate("01JAN26", { yearWindow: 2000 }) // "2026-01-01"
+ * @example parseSsimDate("29FEB00", { yearWindow: 2000 }) // "2000-02-29"
+ * @example parseSsimDate("29FEB00", { yearWindow: 1900 }) // ""
+ * @example parseSsimDate("16DEC09", { yearWindow: 1950 }) // "2009-12-16"
+ * @example parseSsimDate("01JAN26", { yearWindow: "rolling" }) // "2026-01-01" (while the current UTC year is 1977–2076)
+ * @example parseSsimDate("01jan26", { yearWindow: 2000 }) // ""
+ * @example parseSsimDate("01ENE26", { yearWindow: 2000 }) // ""
+ * @example parseSsimDate("01JAN26", {}) // ""
+ */
+export function parseSsimDate(
+ value: string,
+ options: TwoDigitYearOptions,
+): string {
+ try {
+ if (typeof value !== "string") {
+ return "";
+ }
+ if (!isOptionsArgument(options)) {
+ return "";
+ }
+ const fields = readSsimDateFields(value);
+ if (fields === null) {
+ return "";
+ }
+ const windowStart = readYearWindowStart(options);
+ if (windowStart === null) {
+ return "";
+ }
+ return Temporal.PlainDate.from(
+ {
+ year: twoDigitYear(fields.yy, windowStart),
+ month: fields.month,
+ day: fields.day,
+ },
+ { overflow: "reject" },
+ ).toString();
+ } catch {
+ return "";
+ }
+}
diff --git a/packages/gmt/src/aviation/validate/index.ts b/packages/gmt/src/aviation/validate/index.ts
new file mode 100644
index 000000000..e456f386d
--- /dev/null
+++ b/packages/gmt/src/aviation/validate/index.ts
@@ -0,0 +1 @@
+export * from "./isValidSsimDate";
diff --git a/packages/gmt/src/aviation/validate/isValidSsimDate.test.ts b/packages/gmt/src/aviation/validate/isValidSsimDate.test.ts
new file mode 100644
index 000000000..894d3fb97
--- /dev/null
+++ b/packages/gmt/src/aviation/validate/isValidSsimDate.test.ts
@@ -0,0 +1,338 @@
+import { Temporal } from "../../internal/temporal";
+import { MustTestLocales } from "../../test/localeMatrix";
+import { mockTemporalPlainDateFromThrow } from "../../test/mocks";
+import { NON_STRINGS } from "../../test/nonStrings";
+import { SSIM_SENTINEL_ROWS, SSIM_VALID_ROWS } from "../../test/ssimDateRows";
+import { formatSsimDate } from "../format/formatSsimDate";
+import { parseSsimDate } from "../parse/parseSsimDate";
+import { isValidSsimDate } from "./isValidSsimDate";
+
+interface Sweep {
+ count: number;
+ first: string[];
+}
+
+/** Collects up to three failure descriptions, so one assertion shows what broke. */
+function sweep(): { sweep: Sweep; fail: (what: string) => void } {
+ const result: Sweep = { count: 0, first: [] };
+ return {
+ sweep: result,
+ fail(what) {
+ result.count += 1;
+ if (result.first.length < 3) {
+ result.first.push(what);
+ }
+ },
+ };
+}
+
+/** Every date from `start` to `end` inclusive, built by adding one day to the previous. */
+function eachDay(start: string, end: string): string[] {
+ const days: string[] = [];
+ let day = Temporal.PlainDate.from(start);
+ const last = Temporal.PlainDate.from(end);
+ while (Temporal.PlainDate.compare(day, last) <= 0) {
+ days.push(day.toString());
+ day = day.add({ days: 1 });
+ }
+ return days;
+}
+
+/** Asserts `parse(format(d, w), w) === d` for each date, collecting failures. */
+function roundTrip(dates: string[], yearWindow: number): Sweep {
+ const { sweep: result, fail } = sweep();
+ for (const date of dates) {
+ const text = formatSsimDate(date, { yearWindow });
+ const back = parseSsimDate(text, { yearWindow });
+ if (text === "" || back !== date) {
+ fail(`${date} -> '${text}' -> '${back}'`);
+ }
+ }
+ return result;
+}
+
+/**
+ * Every expected value is decided from the grammar: a value is valid when `parseSsimDate` gives
+ * a date, and the shared rows state by hand which values those are.
+ */
+describe("isValidSsimDate", () => {
+ afterEach(() => {
+ vi.restoreAllMocks();
+ });
+
+ it.each`
+ value | options | expected
+ ${"01JAN26"} | ${{ yearWindow: 2000 }} | ${true}
+ ${"01jan26"} | ${{ yearWindow: 2000 }} | ${false}
+ ${"31APR26"} | ${{ yearWindow: 2000 }} | ${false}
+ ${"01JAN26"} | ${{}} | ${false}
+ ${26} | ${{ yearWindow: 2000 }} | ${false}
+ ${null} | ${{ yearWindow: 2000 }} | ${false}
+ ${"29FEB00"} | ${{ yearWindow: 2000 }} | ${true}
+ ${"29FEB00"} | ${{ yearWindow: 1900 }} | ${false}
+ `(
+ "returns $expected for $value with options $options",
+ ({ value, options, expected }) => {
+ expect(isValidSsimDate(value, options)).toBe(expected);
+ },
+ );
+
+ describe("rolling window", () => {
+ // The clock is pinned: a rolling window moves with the UTC year, so an unpinned row only
+ // holds while the real year is in a fixed range.
+ it.each`
+ now | value | expected
+ ${"2026-06-01T00:00:00Z"} | ${"01JAN26"} | ${true}
+ ${"2026-06-01T00:00:00Z"} | ${"29FEB00"} | ${true}
+ ${"2051-06-01T00:00:00Z"} | ${"29FEB00"} | ${false}
+ ${"2026-12-31T23:59:59Z"} | ${"29FEB00"} | ${true}
+ ${"2051-01-01T00:00:00Z"} | ${"29FEB00"} | ${false}
+ ${"2026-06-01T00:00:00Z"} | ${"01jan26"} | ${false}
+ `(
+ "returns $expected for '$value' in a rolling window when now is $now",
+ ({ now, value, expected }) => {
+ vi.spyOn(Temporal.Now, "instant").mockReturnValue(
+ Temporal.Instant.from(now),
+ );
+ expect(isValidSsimDate(value, { yearWindow: "rolling" })).toBe(
+ expected,
+ );
+ },
+ );
+ });
+
+ describe("agrees with the parser", () => {
+ function disagreements(): Sweep {
+ const { sweep: result, fail } = sweep();
+ const rows: [string, number, boolean][] = [
+ ...SSIM_VALID_ROWS.map(
+ ({ value, yearWindow }): [string, number, boolean] => [
+ value,
+ yearWindow,
+ true,
+ ],
+ ),
+ ...SSIM_SENTINEL_ROWS.map(
+ ({ value, yearWindow }): [string, number, boolean] => [
+ value,
+ yearWindow,
+ false,
+ ],
+ ),
+ ];
+ for (const [value, yearWindow, expected] of rows) {
+ const options = { yearWindow };
+ const actual = isValidSsimDate(value, options);
+ if (actual !== (parseSsimDate(value, options) !== "")) {
+ fail(`${value} (${yearWindow}): differs from parseSsimDate`);
+ }
+ if (actual !== expected) {
+ fail(`${value} (${yearWindow}): expected ${expected}`);
+ }
+ }
+ return result;
+ }
+
+ it("matches parseSsimDate and the expected value on every shared row", () => {
+ expect(disagreements()).toStrictEqual({ count: 0, first: [] });
+ });
+
+ function stubLocale(locale: string): void {
+ vi.spyOn(
+ Intl.DateTimeFormat.prototype,
+ "resolvedOptions",
+ ).mockReturnValue({
+ locale,
+ } as Intl.ResolvedDateTimeFormatOptions);
+ if (typeof navigator !== "undefined") {
+ vi.spyOn(navigator, "language", "get").mockReturnValue(locale);
+ }
+ }
+
+ it.each`
+ locale
+ ${MustTestLocales.enUS}
+ ${MustTestLocales.enGB}
+ ${MustTestLocales.deDE}
+ ${MustTestLocales.frFR}
+ ${MustTestLocales.esES}
+ ${MustTestLocales.itIT}
+ ${MustTestLocales.ptPT}
+ ${MustTestLocales.svSE}
+ ${MustTestLocales.isIS}
+ ${MustTestLocales.zhCN}
+ ${MustTestLocales.zhTW}
+ ${MustTestLocales.jaJP}
+ ${MustTestLocales.koKR}
+ ${MustTestLocales.arSA}
+ ${MustTestLocales.heIL}
+ ${MustTestLocales.ruRU}
+ ${MustTestLocales.trTR}
+ `(
+ "agrees on every shared row under the ambient locale $locale",
+ ({ locale }) => {
+ stubLocale(locale);
+ expect(disagreements()).toStrictEqual({ count: 0, first: [] });
+ },
+ );
+ });
+
+ describe("arguments", () => {
+ it("returns false for every non-string value", () => {
+ for (const [kind, make] of NON_STRINGS) {
+ expect(
+ isValidSsimDate(make() as string, { yearWindow: 2000 }),
+ kind,
+ ).toBe(false);
+ }
+ });
+
+ it("returns false for a String object", () => {
+ expect(
+ isValidSsimDate(new String("01JAN26") as string, { yearWindow: 2000 }),
+ ).toBe(false);
+ });
+
+ it("returns false for omitted options", () => {
+ expect(isValidSsimDate("01JAN26", undefined as never)).toBe(false);
+ });
+
+ it.each`
+ options
+ ${null}
+ ${"x"}
+ ${1}
+ ${true}
+ `("returns false for the non-object options $options", ({ options }) => {
+ expect(isValidSsimDate("01JAN26", options)).toBe(false);
+ });
+
+ it("returns false when the yearWindow getter throws", () => {
+ const options = {
+ get yearWindow(): number {
+ throw new Error("hostile getter");
+ },
+ };
+ expect(isValidSsimDate("01JAN26", options)).toBe(false);
+ });
+
+ it("returns false when Temporal.PlainDate.from throws", () => {
+ mockTemporalPlainDateFromThrow();
+ expect(isValidSsimDate("01JAN26", { yearWindow: 2000 })).toBe(false);
+ });
+ });
+
+ /**
+ * A sample, not every day of a window: three polyfill calls on 36,525 days would break the
+ * 0.3 s budget (AV-97 index.md, Decisions item 2).
+ */
+ describe("round trip", () => {
+ it("returns every day of leap year 2024 unchanged in window 2000", () => {
+ expect(
+ roundTrip(eachDay("2024-01-01", "2024-12-31"), 2000),
+ ).toStrictEqual({ count: 0, first: [] });
+ });
+
+ it("returns every day of common year 2025 unchanged in window 2000", () => {
+ expect(
+ roundTrip(eachDay("2025-01-01", "2025-12-31"), 2000),
+ ).toStrictEqual({ count: 0, first: [] });
+ });
+
+ it("counts 731 dates in 2024 and 2025", () => {
+ expect(
+ eachDay("2024-01-01", "2024-12-31").length +
+ eachDay("2025-01-01", "2025-12-31").length,
+ ).toBe(731);
+ });
+
+ function monthEnds(fromYear: number, toYear: number): string[] {
+ const dates: string[] = [];
+ for (let year = fromYear; year <= toYear; year++) {
+ for (let month = 1; month <= 12; month++) {
+ const first = Temporal.PlainDate.from({ year, month, day: 1 });
+ dates.push(
+ first.toString(),
+ first.with({ day: first.daysInMonth }).toString(),
+ );
+ }
+ }
+ return dates;
+ }
+
+ it("returns the month ends of 1950 to 1999 unchanged in window 1950", () => {
+ const dates = monthEnds(1950, 1999);
+ expect(dates).toHaveLength(1200);
+ expect(roundTrip(dates, 1950)).toStrictEqual({ count: 0, first: [] });
+ });
+
+ it("returns the month ends of 2000 to 2049 unchanged in window 1950", () => {
+ const dates = monthEnds(2000, 2049);
+ expect(dates).toHaveLength(1200);
+ expect(dates).toContain("2000-02-29");
+ expect(roundTrip(dates, 1950)).toStrictEqual({ count: 0, first: [] });
+ });
+
+ it.each`
+ yearWindow | first | last
+ ${0} | ${"0000-01-01"} | ${"0099-12-31"}
+ ${9900} | ${"9900-01-01"} | ${"9999-12-31"}
+ `(
+ "returns the edges $first and $last unchanged in window $yearWindow",
+ ({ yearWindow, first, last }) => {
+ expect(roundTrip([first, last], yearWindow)).toStrictEqual({
+ count: 0,
+ first: [],
+ });
+ },
+ );
+
+ it("reads back every DDYY that parses as the same text", () => {
+ const letters = [
+ "JAN",
+ "FEB",
+ "MAR",
+ "APR",
+ "MAY",
+ "JUN",
+ "JUL",
+ "AUG",
+ "SEP",
+ "OCT",
+ "NOV",
+ "DEC",
+ ];
+ const { sweep: result, fail } = sweep();
+ let parsed = 0;
+ for (const yy of ["00", "24", "25", "99"]) {
+ for (let day = 1; day <= 31; day++) {
+ for (const letter of letters) {
+ const text = `${String(day).padStart(2, "0")}${letter}${yy}`;
+ const options = { yearWindow: 2000 };
+ const iso = parseSsimDate(text, options);
+ if (iso === "") {
+ continue;
+ }
+ parsed += 1;
+ const back = formatSsimDate(iso, options);
+ if (back !== text) {
+ fail(`${text} -> ${iso} -> ${back}`);
+ }
+ }
+ }
+ }
+ // Per year: 7 x 31 + 4 x 30 = 337 days outside February, plus 29 (2000, 2024) or 28
+ // (2025, 2099) February days: 366 + 366 + 365 + 365.
+ expect(parsed).toBe(1462);
+ expect(result).toStrictEqual({ count: 0, first: [] });
+ });
+
+ it.each`
+ value | reason
+ ${"1999-12-31"} | ${"the day before the window"}
+ ${"2100-01-01"} | ${"the first day after the window"}
+ `("writes nothing for $value in window 2000: $reason", ({ value }) => {
+ expect(formatSsimDate(value, { yearWindow: 2000 })).toBe("");
+ });
+ });
+});
diff --git a/packages/gmt/src/aviation/validate/isValidSsimDate.ts b/packages/gmt/src/aviation/validate/isValidSsimDate.ts
new file mode 100644
index 000000000..3935f56cc
--- /dev/null
+++ b/packages/gmt/src/aviation/validate/isValidSsimDate.ts
@@ -0,0 +1,30 @@
+import { parseSsimDate } from "../parse/parseSsimDate";
+import type { TwoDigitYearOptions } from "../../types/two-digit-year";
+
+/**
+ * Return true when `value` is a real SSIM date (`DDMMMYY`) in the stated hundred-year window.
+ *
+ * - **True exactly when `parseSsimDate` returns a date** for the same arguments. It calls the
+ * parser, so the two cannot disagree.
+ * - **It needs the window.** A day is real only once its century is known: `29FEB00` is valid
+ * with a window from 2000 and not with one from 1900. It is false without `yearWindow`.
+ * - **Locale-independent**, as the parser is: the month letters are a fixed upper-case English
+ * code, never read through `Intl`.
+ *
+ * @param value The value to check
+ * @param options The hundred-year window a two-digit year is read in
+ * @returns `true` for a real SSIM date in the window, or `false` on invalid input
+ *
+ * @example isValidSsimDate("01JAN26", { yearWindow: 2000 }) // true
+ * @example isValidSsimDate("29FEB00", { yearWindow: 2000 }) // true
+ * @example isValidSsimDate("29FEB00", { yearWindow: 1900 }) // false
+ * @example isValidSsimDate("01jan26", { yearWindow: 2000 }) // false
+ * @example isValidSsimDate("31APR26", { yearWindow: 2000 }) // false
+ * @example isValidSsimDate("01JAN26", {}) // false
+ */
+export function isValidSsimDate(
+ value: string,
+ options: TwoDigitYearOptions,
+): boolean {
+ return parseSsimDate(value, options) !== "";
+}
diff --git a/packages/gmt/src/index.ts b/packages/gmt/src/index.ts
index 8bc96e34c..2d16c5275 100644
--- a/packages/gmt/src/index.ts
+++ b/packages/gmt/src/index.ts
@@ -1,4 +1,5 @@
export { Intl, Temporal, toTemporalInstant } from "./internal/temporal";
+export * from "./aviation";
export * from "./calendar";
export * from "./duration";
export * from "./finance";
diff --git a/packages/gmt/src/internal/index.ts b/packages/gmt/src/internal/index.ts
index 49a476d99..a7a9e4ccf 100644
--- a/packages/gmt/src/internal/index.ts
+++ b/packages/gmt/src/internal/index.ts
@@ -198,6 +198,12 @@ export {
ENGLISH_MONTH_NAMES,
ENGLISH_WEEKDAY_NAMES,
} from "./englishCalendarNames";
+export {
+ readSsimDateFields,
+ SSIM_MONTH_LETTERS,
+ type SsimDateFields,
+ writeSsimDate,
+} from "./ssimDate";
export { defaultFractionalDigits } from "./defaultFractionalDigits";
export { getLocaleFirstDayOfWeek } from "./getLocaleFirstDayOfWeek";
export { resolveMinimalDaysInFirstWeek } from "./resolveMinimalDaysInFirstWeek";
diff --git a/packages/gmt/src/internal/ssimDate.test.ts b/packages/gmt/src/internal/ssimDate.test.ts
new file mode 100644
index 000000000..2f354f238
--- /dev/null
+++ b/packages/gmt/src/internal/ssimDate.test.ts
@@ -0,0 +1,138 @@
+import {
+ readSsimDateFields,
+ SSIM_MONTH_LETTERS,
+ writeSsimDate,
+} from "./ssimDate";
+
+describe("SSIM_MONTH_LETTERS", () => {
+ it("holds twelve upper-case three-letter codes", () => {
+ const bad = SSIM_MONTH_LETTERS.filter((m) => !/^[A-Z]{3}$/.test(m));
+ expect({
+ count: bad.length,
+ first: bad.slice(0, 3),
+ length: SSIM_MONTH_LETTERS.length,
+ }).toEqual({ count: 0, first: [], length: 12 });
+ });
+});
+
+describe("readSsimDateFields", () => {
+ it.each`
+ value | expected
+ ${"01JAN26"} | ${{ day: 1, month: 1, yy: 26 }}
+ ${"31DEC99"} | ${{ day: 31, month: 12, yy: 99 }}
+ ${"00JAN00"} | ${{ day: 0, month: 1, yy: 0 }}
+ ${"32JAN26"} | ${{ day: 32, month: 1, yy: 26 }}
+ `(
+ "reads the shape of '$value' without checking the date",
+ ({ value, expected }) => {
+ expect(readSsimDateFields(value)).toEqual(expected);
+ },
+ );
+
+ it.each`
+ letters | month
+ ${"JAN"} | ${1}
+ ${"FEB"} | ${2}
+ ${"MAR"} | ${3}
+ ${"APR"} | ${4}
+ ${"MAY"} | ${5}
+ ${"JUN"} | ${6}
+ ${"JUL"} | ${7}
+ ${"AUG"} | ${8}
+ ${"SEP"} | ${9}
+ ${"OCT"} | ${10}
+ ${"NOV"} | ${11}
+ ${"DEC"} | ${12}
+ `("reads $letters as month $month", ({ letters, month }) => {
+ expect(readSsimDateFields(`15${letters}26`)).toEqual({
+ day: 15,
+ month,
+ yy: 26,
+ });
+ });
+
+ it.each`
+ value | label
+ ${"01jan26"} | ${"lower case"}
+ ${"01Jan26"} | ${"title case"}
+ ${"01jAN26"} | ${"mixed case"}
+ ${"01JANV26"} | ${"French"}
+ ${"01SEPT26"} | ${"long form"}
+ ${"01ENE26"} | ${"Spanish"}
+ ${"01MRZ26"} | ${"German"}
+ ${"01OCA26"} | ${"Turkish"}
+ ${"1JAN26"} | ${"one-digit day"}
+ ${"001JAN26"} | ${"three-digit day"}
+ ${"01JAN6"} | ${"one-digit year"}
+ ${"01JAN2026"} | ${"four-digit year"}
+ ${"01JAN"} | ${"no year"}
+ ${" 01JAN26"} | ${"leading space"}
+ ${"01JAN26 "} | ${"trailing space"}
+ ${"01JAN26\n"} | ${"trailing newline"}
+ ${"01 JAN 26"} | ${"spaced"}
+ ${"01-JAN-26"} | ${"hyphenated"}
+ ${"01JAN26"} | ${"full-width digits"}
+ ${"٠١JAN٢٦"} | ${"Arabic-Indic digits"}
+ ${"00XXX00"} | ${"XXX is not a month"}
+ ${"X01JAN26"} | ${"leading letter: the pattern is anchored at the start"}
+ ${"01JAN26X"} | ${"trailing letter: the pattern is anchored at the end"}
+ ${"01JAN٢٦"} | ${"Arabic-Indic year digits"}
+ ${""} | ${"empty"}
+ `("returns null for '$value' ($label)", ({ value }) => {
+ expect(readSsimDateFields(value)).toBeNull();
+ });
+});
+
+describe("writeSsimDate", () => {
+ it.each`
+ day | month | yy | expected
+ ${1} | ${1} | ${26} | ${"01JAN26"}
+ ${25} | ${10} | ${26} | ${"25OCT26"}
+ ${31} | ${12} | ${0} | ${"31DEC00"}
+ ${9} | ${9} | ${5} | ${"09SEP05"}
+ `("writes $day/$month/$yy as '$expected'", ({ day, month, yy, expected }) => {
+ expect(writeSsimDate(day, month, yy)).toBe(expected);
+ });
+});
+
+describe("reader and writer together", () => {
+ it("reads back every day-month pair the writer produces", () => {
+ const bad: string[] = [];
+ for (const yy of [0, 26, 99]) {
+ for (let month = 1; month <= 12; month++) {
+ for (let day = 1; day <= 31; day++) {
+ const text = writeSsimDate(day, month, yy);
+ const f = readSsimDateFields(text);
+ if (f?.day !== day || f.month !== month || f.yy !== yy) {
+ bad.push(text);
+ }
+ }
+ }
+ }
+ expect({ count: bad.length, first: bad.slice(0, 3) }).toEqual({
+ count: 0,
+ first: [],
+ });
+ });
+
+ it("calls no case conversion", () => {
+ const spies = (
+ [
+ "toUpperCase",
+ "toLowerCase",
+ "toLocaleUpperCase",
+ "toLocaleLowerCase",
+ ] as const
+ ).map((name) => vi.spyOn(String.prototype, name));
+ try {
+ for (const v of ["01JAN26", "01jan26", "00XXX00", "", "01JAN26"]) {
+ readSsimDateFields(v);
+ }
+ writeSsimDate(1, 1, 26);
+ writeSsimDate(31, 12, 0);
+ expect(spies.map((s) => s.mock.calls.length)).toEqual([0, 0, 0, 0]);
+ } finally {
+ for (const s of spies) s.mockRestore();
+ }
+ });
+});
diff --git a/packages/gmt/src/internal/ssimDate.ts b/packages/gmt/src/internal/ssimDate.ts
new file mode 100644
index 000000000..fe0089a1e
--- /dev/null
+++ b/packages/gmt/src/internal/ssimDate.ts
@@ -0,0 +1,78 @@
+/*
+ * The SSIM date `DDMMMYY` (`01JAN26`): a two-digit day, the first three letters of the English
+ * month name in upper case, and a two-digit year. Private: a value is a date only once its
+ * century is known, so the public check is `isValidSsimDate(value, options)`, never a pattern.
+ *
+ * Sources:
+ * - The day and the month letters: AECFA (Spain), _Quick Guide to Using the IATA SSIM format_,
+ * Chapter 6: "The first two are the day of the month. Shown as 01, 02,….30, 31"; "The last
+ * three are the first three letters of the name of the month in English: JAN, FEB, ……, NOV,
+ * DEC". The guide is no longer online, so it is cited by name only.
+ * - The same day and month letters, upper case: ACL (UK), _An Introductory Guide to SSIM_
+ * (April 2021), a condensed extract of Chapter 6 (`01APR`, `10JAN`),
+ * https://www.acl-uk.org/wp-content/uploads/2021/04/SSIM-Review-Final2.pdf
+ * - The seven-character form with a two-digit year: EUROCONTROL, _CSST Users Guide_ Ed. 8.0
+ * (28-04-2021), §3.2 Figure 1 (`05APR10`, `16DEC09`). Avinor's SSIM description shows a
+ * two-digit year in the validity period.
+ * - IATA SSIM Chapter 7, the schedule-file text itself, was not reached.
+ *
+ * GMT rules:
+ * - The letters are a fixed English code, not a translation: no `Intl`, and no case conversion
+ * (folding case can map other characters onto a month code, `"ſEP".toUpperCase() === "SEP"`,
+ * and is locale-dependent, `"i".toLocaleUpperCase("tr") === "İ"`). Lower and mixed case
+ * are not read.
+ * - Digits are ASCII only: the grammar writes `[0-9]`, not `\d`.
+ * - The reader checks the shape, not the date: day `00` and day `32` come back as fields, and
+ * Temporal rejects them later.
+ */
+
+/** The SSIM month letters, January first: the first three letters of each English month name, upper case. */
+export const SSIM_MONTH_LETTERS = [
+ "JAN",
+ "FEB",
+ "MAR",
+ "APR",
+ "MAY",
+ "JUN",
+ "JUL",
+ "AUG",
+ "SEP",
+ "OCT",
+ "NOV",
+ "DEC",
+] as const;
+
+/** The fields of a `DDMMMYY` value, as numbers: day 0–99, month 1–12, two-digit year 0–99. */
+export interface SsimDateFields {
+ day: number;
+ month: number;
+ yy: number;
+}
+
+// No `i`, `m` or `u` flag: `$` then fails before a trailing newline. Plain literals, so linear time.
+const SSIM_DATE = new RegExp(
+ `^([0-9]{2})(${SSIM_MONTH_LETTERS.join("|")})([0-9]{2})$`,
+);
+
+/** Read the fields of a `DDMMMYY` value, or null when the shape does not match. */
+export function readSsimDateFields(value: string): SsimDateFields | null {
+ const match = SSIM_DATE.exec(value);
+ if (match === null) return null;
+ const [, dd, mmm, yy] = match as unknown as [string, string, string, string];
+ return {
+ day: Number(dd),
+ month:
+ SSIM_MONTH_LETTERS.indexOf(mmm as (typeof SSIM_MONTH_LETTERS)[number]) +
+ 1,
+ yy: Number(yy),
+ };
+}
+
+function pad2(n: number): string {
+ return String(n).padStart(2, "0");
+}
+
+/** Write `DDMMMYY` from a day 1–31, a month 1–12 and a year 0–99. The caller passes valid values. */
+export function writeSsimDate(day: number, month: number, yy: number): string {
+ return pad2(day) + SSIM_MONTH_LETTERS[month - 1] + pad2(yy);
+}
diff --git a/packages/gmt/src/test/ssimDateRows.ts b/packages/gmt/src/test/ssimDateRows.ts
new file mode 100644
index 000000000..7dd33d76c
--- /dev/null
+++ b/packages/gmt/src/test/ssimDateRows.ts
@@ -0,0 +1,112 @@
+/**
+ * The SSIM date rows the parse and validate tests share, written by hand from the grammar
+ * (`DDMMMYY`, upper-case English month letters, the caller's hundred-year window) and never read
+ * from the code under test.
+ */
+
+/** A value that reads as a date, the window it is read in, and the ISO date it reads as. */
+export interface SsimValidRow {
+ readonly value: string;
+ readonly yearWindow: number;
+ readonly expected: string;
+}
+
+/** A value that reads as no date, the window it is read in, and why. */
+export interface SsimSentinelRow {
+ readonly value: string;
+ readonly yearWindow: number;
+ readonly reason: string;
+}
+
+export const SSIM_VALID_ROWS: readonly SsimValidRow[] = [
+ { value: "01JAN26", yearWindow: 2000, expected: "2026-01-01" },
+ { value: "25OCT26", yearWindow: 2000, expected: "2026-10-25" },
+ { value: "29FEB24", yearWindow: 2000, expected: "2024-02-29" },
+ { value: "29FEB00", yearWindow: 2000, expected: "2000-02-29" },
+ { value: "29FEB00", yearWindow: 1901, expected: "2000-02-29" },
+ { value: "01JAN00", yearWindow: 2000, expected: "2000-01-01" },
+ { value: "31DEC99", yearWindow: 2000, expected: "2099-12-31" },
+ { value: "01JAN49", yearWindow: 1950, expected: "2049-01-01" },
+ { value: "31DEC49", yearWindow: 1950, expected: "2049-12-31" },
+ { value: "01JAN50", yearWindow: 1950, expected: "1950-01-01" },
+ { value: "05APR10", yearWindow: 1950, expected: "2010-04-05" },
+ { value: "16DEC09", yearWindow: 1950, expected: "2009-12-16" },
+ { value: "01JAN00", yearWindow: 0, expected: "0000-01-01" },
+ { value: "31DEC99", yearWindow: 0, expected: "0099-12-31" },
+ { value: "01JAN05", yearWindow: 9900, expected: "9905-01-01" },
+ { value: "31DEC99", yearWindow: 9900, expected: "9999-12-31" },
+ { value: "15JAN26", yearWindow: 2000, expected: "2026-01-15" },
+ { value: "15FEB26", yearWindow: 2000, expected: "2026-02-15" },
+ { value: "15MAR26", yearWindow: 2000, expected: "2026-03-15" },
+ { value: "15APR26", yearWindow: 2000, expected: "2026-04-15" },
+ { value: "15MAY26", yearWindow: 2000, expected: "2026-05-15" },
+ { value: "15JUN26", yearWindow: 2000, expected: "2026-06-15" },
+ { value: "15JUL26", yearWindow: 2000, expected: "2026-07-15" },
+ { value: "15AUG26", yearWindow: 2000, expected: "2026-08-15" },
+ { value: "15SEP26", yearWindow: 2000, expected: "2026-09-15" },
+ { value: "15OCT26", yearWindow: 2000, expected: "2026-10-15" },
+ { value: "15NOV26", yearWindow: 2000, expected: "2026-11-15" },
+ { value: "15DEC26", yearWindow: 2000, expected: "2026-12-15" },
+ { value: "31JAN26", yearWindow: 2000, expected: "2026-01-31" },
+ { value: "31MAR26", yearWindow: 2000, expected: "2026-03-31" },
+ { value: "31MAY26", yearWindow: 2000, expected: "2026-05-31" },
+ { value: "31JUL26", yearWindow: 2000, expected: "2026-07-31" },
+ { value: "31AUG26", yearWindow: 2000, expected: "2026-08-31" },
+ { value: "31OCT26", yearWindow: 2000, expected: "2026-10-31" },
+ { value: "31DEC26", yearWindow: 2000, expected: "2026-12-31" },
+];
+
+export const SSIM_SENTINEL_ROWS: readonly SsimSentinelRow[] = [
+ { value: "29FEB25", yearWindow: 2000, reason: "2025 is not a leap year" },
+ { value: "31APR26", yearWindow: 2000, reason: "April has 30 days" },
+ { value: "31JUN26", yearWindow: 2000, reason: "June has 30 days" },
+ { value: "31SEP26", yearWindow: 2000, reason: "September has 30 days" },
+ { value: "31NOV26", yearWindow: 2000, reason: "November has 30 days" },
+ { value: "30FEB24", yearWindow: 2000, reason: "February never has 30 days" },
+ { value: "00JAN26", yearWindow: 2000, reason: "there is no day 0" },
+ { value: "32JAN26", yearWindow: 2000, reason: "January has 31 days" },
+ { value: "29FEB00", yearWindow: 1900, reason: "1900 is not a leap year" },
+ {
+ value: "29FEB00",
+ yearWindow: 2001,
+ reason: "00 reads as 2100, which is not a leap year",
+ },
+ { value: "01jan26", yearWindow: 2000, reason: "lower case is not read" },
+ { value: "01Jan26", yearWindow: 2000, reason: "mixed case is not read" },
+ {
+ value: "01jAN26",
+ yearWindow: 2000,
+ reason: "mixed case is not read (j lower)",
+ },
+ {
+ value: "01JAn26",
+ yearWindow: 2000,
+ reason:
+ "no letter is ever case-converted: folding would turn n into N, and ſ into S",
+ },
+ { value: "01JANV26", yearWindow: 2000, reason: "French month abbreviation" },
+ { value: "01ENE26", yearWindow: 2000, reason: "Spanish month abbreviation" },
+ { value: "01MRZ26", yearWindow: 2000, reason: "German month abbreviation" },
+ { value: "01OCA26", yearWindow: 2000, reason: "Turkish month abbreviation" },
+ {
+ value: "01SEPT26",
+ yearWindow: 2000,
+ reason: "en-GB CLDR short form is four letters",
+ },
+ { value: "1JAN26", yearWindow: 2000, reason: "one-digit day" },
+ { value: "01JAN6", yearWindow: 2000, reason: "one-digit year" },
+ { value: "01JAN2026", yearWindow: 2000, reason: "four-digit year" },
+ { value: "01JAN", yearWindow: 2000, reason: "no year" },
+ { value: "", yearWindow: 2000, reason: "empty" },
+ { value: " 01JAN26", yearWindow: 2000, reason: "leading space" },
+ { value: "01JAN26 ", yearWindow: 2000, reason: "trailing space" },
+ { value: "01JAN26\n", yearWindow: 2000, reason: "trailing newline" },
+ { value: "01-JAN-26", yearWindow: 2000, reason: "hyphenated" },
+ { value: "2026-01-01", yearWindow: 2000, reason: "an ISO date" },
+ { value: "01JAN26", yearWindow: 2000, reason: "full-width digits" },
+ { value: "٠١JAN26", yearWindow: 2000, reason: "Arabic-Indic digits" },
+ { value: "00XXX00", yearWindow: 2000, reason: "XXX is not a month" },
+ { value: "01JAN٢٦", yearWindow: 2000, reason: "Arabic-Indic year digits" },
+ { value: "01JAN26X", yearWindow: 2000, reason: "a trailing letter" },
+ { value: "X01JAN26", yearWindow: 2000, reason: "a leading letter" },
+];