circagraph
Sign inSign up

openchronology/timeline-app on GitHub

The OpenChronology repository on GitHub, mirrored by och-import-github: issues and pull requests as durations (ongoing while open), what happened to them as moments, plus releases, milestones, commits and branches. The Branches view shows the most recently active branches each in a track of its own.

Source: https://github.com/openchronology/timeline-app

3,131 moments · 2026-10-05 CE 20:21:49 UTC – 2026-11-16 CE 12:10:45 UTC · by @athan · @athan

#98 Read comparison offsets in the time display's difference units

–

  • github
  • github/openchronology/timeline-app
  • github/openchronology/timeline-app#98
  • pull request
  • state:merged

Closes #73. Each time display now defines the units it reads **time differences** in (`createDifference(presentation)` in `src/difference.ts`). It returns the units, what a plain number means, and an exact `parse`/`print` in stored coordinates. Comparison offsets are the first use. | Display | Units | Plain number | | --- | --- | --- | | Gregorian | `years`, `months`, `weeks`, `days`, `h`, `min`, `s`, `ms`, `µs`, `ns`, `ps`, `fs`, `as` (plus singular, abbreviated and any-case words) | seconds | | Rational / float / scientific, no unit | none | stored coordinates | | … with a fixed time unit (`s`, `minutes`, `days`, …) | that unit and the other fixed time units | the display's unit | | … with another unit (`million years`) | that unit, read whole | the display's unit | | SI | the unit with every prefix, case-sensitive (`ms` ≠ `Ms`); time units add `weeks`…`min` | the display's unit | | Custom | optional `parseDifference` / `printDifference` functions | stored coordinates | - A difference can combine several amounts (`2 years 3 days`, `-1 h 30 min`, `1.5 weeks`, `1/3 s`). A leading sign applies to the whole difference. - Years and months are the Gregorian mean year (365.2425 days, which 400 years repeat exactly) and a twelfth of it, since an offset must be a fixed length. Differences print in years, days, h, min and s, or in one unit below a second. Months and weeks are read but not printed. - The display's scale applies to every unit, so a Gregorian display of milliseconds reads `1 s` as 1000 coordinates. - Custom source may define `printDifference(difference: Rational, api)` and `parseDifference(text: string, api)`. The server's syntax validation accepts them. - In the comparison panel, the Offset field is read with the comparison display's units. A hint lists those units and follows changes to the display settings. Applying an offset reports it, for example "Shifted earlier by 2 years 3 days." ## Tests - `test/presentation.test.mjs` covers round trips and errors for every display kind, scaled displays, SI case sensitivity, multi-word labels and custom difference functions. - `test/comparison-browser.mjs` checks the units hint, the error for a unit on a display without units, and that an exact rational offset moves the track. - Locally, `npm test` (227 tests) and the Chromium browser suite pass. - Docs: `docs/time-presentation.md#time-differences` and `docs/comparison.md`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/openchronology/timeline-app/pull/98

Related

Open #98 Read comparison offsets in the time display's difference units in the timeline

#98 Read comparison offsets in the time display's…