Skip to content

koyomi

.cal — dates: closing and payment days, business days, legal periods.

koyomi writes a date as a contract or a law says it: thirty days after the invoice, moved to the next business day. koyomi check computes it on every day of the declared range and checks each claim on every one of them; only a file that passes compiles, into TypeScript, Python, Go, Rust and SQL, and into a Wasm module that any host calls with one JSON object.

koyomi's documents are in the repository: README, the reference, the generated code, the codes of its diagnostics.

Where an input's value comes from

Hand-written code often carries an input from somewhere else: a date of another file, a field of a contract. fed by at the end of the input's line says where, in the form the toolchain names everything, and ritsu check asks the other file what it can come to:

$ cd crates/koyomi/examples
$ ritsu check late_fee.cal net30.cal
late_fee.cal: ok — 2 claims hold on all 1,062 days of due_on (2026-02-02..2028-12-29)
net30.cal: ok — 3 claims hold on all 1,064 days of invoice_date (2026-01-01..2028-11-29)
ritsu check: 2 files (koyomi 2): all pass; borders between the languages: 1 checked, 0 undecided

Narrow due_on by a day, to <=2028-12-28, and it stops with E207: koyomi "net30.cal" date due comes to 2028-12-29 at invoice_date = 2028-11-29.

The days are what is checked. Nothing checks that the hand-written code really carries that value, and the page says so (the reference has the rest).

Comparing two versions

koyomi diff compares the answers of two versions: of a calendar on every day both know, of a dates file on every input both take. Here an office's calendar closes on its founding day, renames a bank holiday, knows 2027 too and takes an offset:

$ cd crates/koyomi/tests/diff
$ koyomi diff office.cal office_v2.cal
koyomi diff: calendar office v1 → v2
  old: office.cal
  new: office_v2.cal

compared: 2026-01-01..2026-12-31 (365 days, the days both versions know)

open or closed changed (1 interval, 1 day):
  2026-06-10: open → closed (Founding day)

closed in both, for other reasons (1 interval, 1 day):
  2026-05-04: Early May bank holiday → May Day

the days known: 2026-01-01..2026-12-31 → 2026-01-01..2027-12-31
offset: none → +01:00

every other day of 2026-01-01..2026-12-31 gets the same answer.

Each side is a path, a path at a git revision (calendars/office.cal@origin/main, the file as it is on that branch), a file of a dependency at the version the lock pins (@calendars/office.cal), or a file of another version of that dependency in the store (@calendars@1.0.0/office.cal). The exit code is 0 when nothing differs, 1 when something does, and 2 when the two cannot be compared: a calendar beside a dates file, or a side that does not pass koyomi check. --format markdown writes the same in Markdown, and --format json gives every interval.