#358 · The reader writes dates in full, whatever the view (#344)
- timeline-app
- pull request
Closes #344 The reader wrote a moment's time with `presented(time, 'event')`, the same call that draws moment labels on the chart, so it was relative to the view. From a view starting in the moment's year the year was dropped ("09-09", "07-09 00h"), and a year-dated moment opened from a narrow view read "0091-01-01 BCE". The **Related to** rows used the same call, which is why they read "12-08 12h". **Fix:** presenters gain `alone(time)`, a time written on its own, independent of any view: - **Gregorian:** the full date with its era, at the time's own precision. The start of a year is that year (`91 BCE`, or an age in deep time such as `3 mya`). The start of a month is its year and month (`1781-09 CE`). Midnight is its date (`1781-09-09 CE`, with no `00h`). Any other time adds its clock and zone, to the minute, the second or exactly (`1781-09-09 CE 14:30 UTC`). Precision is read from the coordinate in the display's offset. - **Other displays:** written as `print` writes them without a context, so never as a `Δ` offset from the view's edge. Custom code is called as for an input. The reader (a moment's time, a duration's start → end) and the related rows, in the reader and in the details panel, use it. The chart's labels, hover cards and ruler keep their compact view-relative form. - `src/calendar-presentation.ts`: `printCalendarAlone`. - `src/presentation.ts`: `TimePresenter.alone`. - `src/app.ts`: `presentedAlone`, used by the reader and `renderRelated`. - `docs/time-presentation.md`, `docs/guide.md`. **Tests** - `test/context.test.mjs`: each precision (year, BCE year, month, date, BCE date, hour, second, exact fraction, deep time); a date the chart abbreviates to `11-09` in a view starting that year, written alone in full; local midnight in a fixed offset; float displays (no `Δ`) and custom code. - `test/view-mode-browser.mjs`: a Gregorian timeline in View mode, as in the issue. From a view starting in 1781 the reader reads `1781-09-09 CE`, and from a one-day view a year-dated moment reads `91 BCE`. Each one's related row gives the other's date in the same form. Before the fix this fails with `'09-09'`. - `npm test` (335 pass), `npm run typecheck`, prettier on the changed files, and the full chromium browser suite (`test/browser.mjs`): all pass. **Overlap:** #340 (ruler BCE ticks, in progress in another PR) is likely to change `src/calendar-presentation.ts` too. This PR only adds a function there, next to `printCalendar`, and leaves the chart's and ruler's labels alone. `test/view-mode-browser.mjs` is also changed by my PRs for #341 and #345, in other parts of the file.
Sources
Open #358 · The reader writes dates in full, whatever the view (#344) in the timeline