time-formatting · git:20261016.7320d44 · 2026-10-16 · sha256 e24d3f5d277e94a1
time-formatting git:20261016.7320d44A
Immutable. This exact content never changes and is served at /api/v1/blob/e24d3f5d277e94a1.
No tool to install first
claude plugin marketplace add https://markdownregistry.com/mp/a/art_cpbdxrsklv5fcupy/e24d3f5d277e94a1c7fb56bd4dd7839e0d82567aa3de8c83b81ecc3f80a970d5.json
Then /plugin install time-formatting@markdownregistry-cpbdxrsklv5fcupy in Claude Code. It installs this exact version, the one graded A here, pinned to the commit it was graded at, and leaves it there.
---
name: time-formatting
description: How to render time/duration in WitnessWork — always route measured minutes through the `src/lib/minutes.ts` helpers so displays respect the user's timeDisplayFormat. Use whenever rendering hours/minutes in JSX, i18n templates, widgets, or tight UI, or when reviewing a manual `minutes / 60` / hardcoded `h`/`hrs` suffix.
---
# Rendering time
All render-time math goes through `src/lib/minutes.ts` helpers — never hand-roll hours/minutes parsing.
## User-facing displays
User-facing time displays MUST go through `useFormattedMinutes(minutes)` (hook) or `formatMinutes(minutes, format)` (pure):
- Never hand-roll `_.round(minutes / 60, 1)`.
- Never hardcode an `h` / `hrs` suffix in JSX or string templates.
- Never pass a raw hour count into `i18n.t('…', { count })` for display.
Reads must respect the user's `timeDisplayFormat` preference: `'decimal'` → `1.5h`, `'short'` → `1h 30m`.
## i18n templates
Templates that wrap a time value should accept a pre-formatted `{{value}}` (no inline `hrs`/`h`), and the caller supplies `formatMinutes(...).formatted`.
Goal counts the user explicitly entered **in hours** can stay as `${goalHours} ${i18n.t('hours')}` — only _measured/computed_ time needs the formatter.
## Tight UI — the only sanctioned bypass
Calendar squares, contribution-graph tooltips, and widgets use the compact variants instead:
`formatMinutesCompact` / `useCompactFormattedMinutes` / `formatHoursCompact`.
## Digits and other numbers
The helpers above print the app Language's digits (Arabic-Indic in Arabic). Numbers that aren't durations go through `src/lib/numbers.ts`: `formatNumber` (grouped, Format Region separators), `formatPlainNumber` (years and typed values, no grouping). Numbers passed to `i18n.t` placeholders are localized for you. Never `toLocaleString()` without a locale, which follows the device instead of the app. Parse typed numbers with `parseDecimalInput`/`parseIntegerInput` from `src/lib/digits.ts`, which accept ٠-٩ as well as 0-9.
Dates follow one rule: `moment.format` always writes ASCII digits, so use it as is for keys, ids and payloads (`YYYY-MM-DD`, `YYYY-MM`). Anything a user reads goes through `src/lib/dates.ts`, which adds the app Language's digits: `formatDate`/`formatTime`/`formatDateTime`/`formatRelative`/`formatCalendar` and the compact helpers, `formatDisplay(m, 'MMMM YYYY')` for other patterns, and `localizeDisplayDate(text)` for a `fromNow()`, `humanize()` or other string moment built. Never run a display helper's output back into a key or a parser.