feat(dates): render user-facing dates via preferences (IFC-2721)

Merged
PA
4mo ago
+926-118

What

Re-homes the date-rendering slice (IFC-2721) onto the re-split ple-prefs-* stack. App-wide dates render through the user's effective date-format + timezone preferences, falling back to the browser locale when nothing is set.

  • shared/context/date-preferences-context β€” { pattern, timezone } + useFormatDate, no dependency on entities.
  • entities/preferences/ui/date-preferences-provider β€” fills the context from useGetEffectivePreferences.
  • shared/utils/date + shared/components/display/date-display / duration-display and consumers across nodes, diff, navigation, events, metadata.

Stack / relationship to the old PR

Supersedes #9842 (ple-user-preferences-datedisplay), built on the older ple-user-preferences-* lineage. The three date-rendering commits were cherry-picked onto ple-prefs-global-permission and adapted to the refactored preferences layer:

  • patternForKey now exported from domain/rules/date-format (the old domain/date-format-presets.ts is gone).
  • provider reads useGetEffectivePreferences and compares the uppercase PreferenceSource ("DEFAULT").

Base: stacks on #9871 (ple-prefs-global-permission) β†’ #9880 β†’ #9870. Draft until the base PRs land.

Verification

tsc --noEmit clean for all ported files locally. Full unit/e2e run deferred to CI.

πŸ€– Generated with Claude Code


Summary by cubic

Render all user-facing dates through one preference-aware path that honors each user’s effective date_format and timezone, falling back to the browser locale/zone when unset. Meets IFC-2721 with a unified API, app-wide migrations, and removal of per-call-site patterns for consistent display.

  • New Features

    • Added DatePreferencesContext + useFormatDate ("datetime" | "date" | "relative") with browser fallback; exposes timezone for rare explicit-pattern cases.
    • Added DatePreferencesProvider (uses useGetEffectivePreferences + resolveDatePreferences); mounts only when authenticated and treats "DEFAULT" as unset.
    • Updated DateDisplay: recent β†’ relative; older β†’ date; tooltip shows full preferred datetime+timezone; added fullTimestamp for inline full datetime. Migrated events, search, time selector, diffs, metadata/tooltips, node tables/details (DateTime attributes now show full preferred format inline), relationships, tokens, and filter tags. Added pure formatWithPattern({ pattern, timezone }) in shared/utils/date using @date-fns/tz; exported dateFormatPattern and dateOnlyPattern; expanded tests and docs.
  • Refactors

    • Removed the DateDisplay per-call-site dateFormat escape hatch so all dates follow preferences; updated tasks homepage and light proposed-change item to use the default behavior.
    • Compact (>7d) rendering now uses formatDate(date, "date"); invalid dates and unknown IANA timezones degrade to readable fallbacks. DurationDisplay shows "β€”" when endDate is missing. Provider fetch is gated on auth to avoid pre-auth 401s. Pre-bundled @date-fns/tz in Vitest to prevent reload flakes.