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

#570 Measures: typed quantities on moments and durations, totalled in every summary

–

  • github
  • github/openchronology/timeline-app
  • github/openchronology/timeline-app#570
  • issue
  • state:open

Moments and durations carry **measures**: named, typed quantities that add up. Every summary then keeps the **total** of each measure beneath it, beside the count it keeps today. For example, a moment for an invoice carries `cost: 1250` (cents), and a cluster of 40 invoices shows its count and its total, `$1,234.56`. ## Types: mpz and mpq only The summary trees keep each subtree's total and rebuild it from its children after inserts and rotations. A rotation regroups a sum, `(a+b)+c` becomes `a+(b+c)`, so addition has to be a **monoid**: associative, with zero for an empty subtree. Commutativity isn't needed, because order by time is fixed. | Type | Values | Why | | --- | --- | --- | | `mpz` | unbounded integers | exact and associative | | `mpq` | unbounded rationals | exact and associative | Left out: - **f32 and f64:** not associative. Totals would depend on the tree's rotation history and differ between engines. - **Machine integers:** checked or saturating overflow depends on grouping. Wrapping is associative, but it's useless on an unbounded timeline. Every engine already has exact rational addition (pgmp's `mpq`, GMP in `sqlite-rational`, `Q` in the browser), so totals are stored as `mpq`. An `mpz` total is just an integral `mpq`. ## Declaring measures A timeline declares its measures in its settings, beside its presentation: ```json "measures": { "cost": { "type": "mpz", "presentation": { "mode": "fixed", "scale": "1/100", "decimals": 2, "prefix": "$" } }, "hours": { "type": "mpq", "presentation": { "mode": "decimal", "significantDigits": 4, "unit": "h" } } } ``` - **Names:** like metadata keys, from a limited set of characters, up to a few dozen per timeline. - **Values:** a moment or duration gives values under `metadata.measures`, as canonical text: `{"cost": "1250"}` for an `mpz`, `{"hours": "3/2"}` for an `mpq`. **No entry is zero.** Values are exact. An `mpz` value must be an integer. - **Validation:** in the core (`validateDocument`), the server and the native store, like times, with size limits like a time's (digits, and the server's own limit). - **Changes to a declaration:** - **Renaming:** rewrites the values in place. - **Widening `mpz` to `mpq`:** always allowed. - **Narrowing `mpq` to `mpz`:** only when every value is an integer. - **Removing a measure:** removes its values (or leaves them as plain metadata, to be decided). - **Index:** each of these rebuilds that measure's totals. - **Display settings save like the time display's:** in place, as a settings change. ## Presentation and parsing, per measure This is the analogue of the [time presentation](docs/time-presentation.md) system. Each measure has its own **printer and parser**: how a value or a total is shown, and how what someone types becomes a stored value. They're exact, and never pass through binary floating point. | Mode | Stored | Shown and typed | Example | | --- | --- | --- | --- | | Exact | `mpz`/`mpq` | the fraction | `3/2` | | Fixed decimals | `mpz` × scale | a fixed number of decimals, with a prefix or suffix | `cost = 123456`, scale `1/100` → `$1,234.56` | | Decimal / scientific | `mpq` | significant digits, like numeric times | `1.5 h` | | SI prefixes | `mpq` | `1.5 kWh` | | | Units | either | `displayed = stored × scale`, label | hours stored as seconds | | Custom | either | a plugin's printer and parser, as custom time code is | | - **Fixed decimals:** the currency case. `$12.34` parses to `1234` with scale `1/100`. `$12.345` is refused rather than rounded, and the parser says why. - **Totals:** use the same printer as values, so a cluster's total reads as money. - **Unchanged text keeps its exact value:** as with times, editing a label that was rounded for display doesn't change what's stored. - **Context:** the printer gets a purpose (value, total, input, tooltip, axis), like `PresentationContext`, so totals can be abbreviated (`$1.2M`) where space is short. - **Where it applies:** the moment and duratio……

Related

Open #570 Measures: typed quantities on moments and durations, totalled in every summary in the timeline

#570 Measures: typed quantities on moments and durations…