Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .changeset/aviation-ssim-dates.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.

Expand Down
1 change: 1 addition & 0 deletions apps/dox/scripts/contrast-measure.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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/",
Expand Down
5 changes: 5 additions & 0 deletions apps/dox/scripts/grow-measure.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,11 @@ const PAGES = [
preset: PRESET,
drag: null,
},
{
slug: "ssim-date-reader",
preset: PRESET,
drag: null,
},
{
slug: "holiday-rule-builder",
preset: PRESET,
Expand Down
4 changes: 4 additions & 0 deletions apps/dox/scripts/html-diff.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions apps/dox/scripts/readout-still.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
*
Expand Down
1 change: 1 addition & 0 deletions apps/dox/scripts/visual-snapshot.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
45 changes: 45 additions & 0 deletions apps/dox/src/components/SsimDateReader.astro
Original file line number Diff line number Diff line change
@@ -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 ? (
<div data-tools-fullbleed set:html={html} />
) : (
<Fragment set:html={html} />
)
}

<script>
import { mountSsimDateReader } from "../lib/ssim-date-reader-mount";
import { showUnavailable } from "../lib/widget-mount";
import { seedFromLocation } from "../lib/widget-permalink";

if (typeof window !== "undefined") {
const seed = seedFromLocation("ssim");
document
.querySelectorAll<HTMLElement>('[data-widget="ssim-date-reader"]')
.forEach((el) => {
mountSsimDateReader(el, seed, new AbortController().signal).catch(
(error) => showUnavailable(el, error),
);
});
}
</script>
2 changes: 2 additions & 0 deletions apps/dox/src/components/ask/widget-graph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
34 changes: 34 additions & 0 deletions apps/dox/src/components/ask/widget-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -128,6 +129,7 @@ import {
showDatabaseTimestampReaderInput,
showTai64nLogReaderInput,
showFixTimestampReaderInput,
showSsimDateReaderInput,
showTerrestrialTimeStackInput,
showDwellLedgerInput,
showEtaDriftInput,
Expand Down Expand Up @@ -969,6 +971,37 @@ const fixTimestampEntry = defineWidget<FixTimestampReaderArgs>({
})),
});

const ssimEntry = defineWidget<SsimDateReaderArgs>({
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<TerrestrialTimeStackArgs>({
title: "Terrestrial Time Stack",
kind: "ttstack",
Expand Down Expand Up @@ -1385,6 +1418,7 @@ export const WIDGET_REGISTRY: Record<string, AnyWidgetEntry | undefined> = {
showDatabaseTimestampReader: databaseReaderEntry,
showTai64nLogReader: tai64nEntry,
showFixTimestampReader: fixTimestampEntry,
showSsimDateReader: ssimEntry,
showTerrestrialTimeStack: ttStackEntry,
};

Expand Down
2 changes: 1 addition & 1 deletion apps/dox/src/content/docs/guides/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading
Loading