feat(frontend): render dates via user preferences (IFC-2721)
Depends on #9776 (base branch ple-user-preferences-ui).
What & why (IFC-2721)
Renders user-facing dates/times against the user's date_format + timezone preferences, app-wide, through one mechanism — replacing scattered ad-hoc format(...)/toLocaleString(...) calls so date rendering is consistent and preference-driven.
Foundation
useFormatDate()(shared/context/date-preferences-context.tsx) — the single entry point:formatDate(date, variant?)withdatetime(default) /date/relativevariants.DatePreferencesContextlives inshared(no dependency onentities/);DatePreferencesProvider(entities/preferences) fills it fromuseEffectivePreferences()and is mounted inapp.tsx. No provider /source: "default"→ browser locale + zone fallback (never a hardcoded pattern).DateDisplay— historic look preserved (relative "x ago" for recent, compact otherwise); tooltip now shows the preferred full datetime + timezone; newvariant="datetime"for inline full timestamps;dateFormatexplicit escape hatch retained.- Timezone via first-party
@date-fns/tz(TZDate);patternForKeyexported fromdate-format-presets.ts.
Migration
Every user-facing raw date render routed through DateDisplay/useFormatDate at its original granularity — global-event, time-selector, search-nodes, duration-display, active-filter-tags, meta-details-tooltips, node-metadata-popover, refresh-button, relationship-properties, account-token-item, diff-empty.
Kept as-is (machine/serialized or intentionally browser-default): form inputs / date-pickers, toISOString() API/keys, chart ticks, tests, getDateDisplay, and the "browser default" hint in the preferences card.
Docs
- Spec
dev/specs/2026-04-user-preferences.md— DateDisplay section updated to the implemented design. - New
dev/knowledge/frontend/date-rendering.md— the one mechanism, layering, variants, and what not to route through it.
Tests / gate
- 21 new foundation tests (pure
date.tsformatter across timezones, the hook/variants,DateDisplay) — establishes the date-rendering test pattern (fake timers + fixed instant). - Local: biome clean; tsc adds no new errors (pre-existing
search-nodes/branches/differrors are unrelated); Playwright suites green (90 tests across foundation + migrated + preferences areas).
🤖 Generated with Claude Code
Summary by cubic
Render all user-facing dates and times against the user’s date_format and timezone via one mechanism for consistent display. DateTime data attributes now show the full preferred datetime inline; activity/metadata timestamps keep the relative/compact style, with browser locale/zone fallback when no preference is set (IFC-2721).
-
New Features
- App-wide date rendering via
useFormatDate()and<DateDisplay>, powered byDatePreferencesContext; resolves semanticdate_formatviapatternForKeyand applies the user’s timezone. Supportsdatetime(default),date(derived from the full pattern), andrelative. DatePreferencesProvider(mounted inapp.tsx) fills the context fromuseEffectivePreferences(); whensource: "default"or no provider is mounted, it falls back to browser locale and zone.<DateDisplay>keeps the relative/compact default; tooltip shows the preferred full datetime + timezone; addsvariant="datetime"for inline full timestamps;dateFormatescape hatch retained.- New pure
formatDate({ pattern, timezone })using@date-fns/tz; docs added; tests cover the formatter, hook, and component.
- App-wide date rendering via
-
Migration
- Routed ad-hoc renders through
DateDisplay/useFormatDatein events, time selector, search, duration tooltip, active filter tags, metadata tooltips, node metadata popover, refresh button, relationships, tokens, diff empty. - For DateTime data attributes (object details, table cells), use
<DateDisplay variant="datetime">to render the full preferred format inline. - Left as-is: form inputs/date‑pickers,
toISOString()usage, chart ticks, and tests.
- Routed ad-hoc renders through