Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor: route every inline toLocaleDateString/TimeString through the canonical formatters (#3870)
[._.]/ Adam Eivy418c6d77d5db
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 6287d52853..412f366922 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -47,3 +47,4 @@- The Pipeline's Reverse Outline map now keeps the selected scene in the URL (`?scene=<id>`) instead of component state, so the open scene detail survives a reload and can be linked to or shared. A stale id — after regenerating the outline, say — falls back to the "click a marker" placeholder rather than a blank card, and regenerating clears the selection outright.- The six "file too large" toasts — album covers, artist portraits, tracks, author headshots, reference audio and OpenClaw attachments — now render their size cap through the shared `formatBytes` helper instead of each dividing by 1024 twice and gluing on "MB". The rendered text gains a space before the unit (`12 MB` rather than `12MB`), which is what the rest of PortOS already shows and what the reference-audio toast already read. The OpenClaw combined-attachment message picked up the same treatment for its decoded-size estimate, so the two limits it can report no longer print their units two different ways.- The post-restart agent-recovery path is now its own function instead of a 65-line branch inlined at the top of `handleAgentCompletion`, so a change to either it or the live in-memory completion path no longer means reading past the other. The pause guard that path sits behind — the one keeping a stray completion event from cleaning the worktree out from under a later resume — is now pinned by tests that call the real function rather than by a source-text assertion that broke the moment the code moved.+- Every inline `new Date(x).toLocaleDateString()` / `.toLocaleTimeString()` in the client — roughly seventy across fifty components, from the calendar views and CyberCity HUD to the CoS tabs, goals, media queue and app-update panels — now routes through `client/src/utils/formatters.js`, so a change to how PortOS renders a date is one edit rather than fifty. The helper set grew to cover the shapes that were being spelled out by hand (`formatDateNumeric`, `formatTimeOfDaySeconds`, `formatMonthDay`, `formatMonthYear`, `formatWeekdayShort`, `formatWeekdayDate`, `formatWeekdayTime`), and `formatClockTime` gained `seconds` / `hour12` options instead of a second copy of itself. Two long-standing paper cuts go with it: a bare `YYYY-MM-DD` is now anchored at local midnight everywhere (a plain `new Date('2026-03-05')` is UTC midnight and renders as the 4th anywhere west of Greenwich — call sites used to fix this by hand, and the ones that forgot showed the wrong day), and a missing or malformed timestamp renders a caller-chosen fallback instead of the literal text "Invalid Date".diff --git a/client/src/components/agents/tabs/WorldTab.jsx b/client/src/components/agents/tabs/WorldTab.jsxindex 80ba3ae0a4..7e217c0780 100644--- a/client/src/components/agents/tabs/WorldTab.jsx+++ b/client/src/components/agents/tabs/WorldTab.jsx@@ -6,7 +6,7 @@ import BrailleSpinner from '../../BrailleSpinner';import socket from '../../../services/socket';import useMoltworldWs from '../../../hooks/useMoltworldWs';import { useCooldownTick } from '../../../hooks/useCooldownTick';-import { timeAgo, formatCooldown } from '../../../utils/formatters';+import { timeAgo, formatCooldown, formatClockTime } from '../../../utils/formatters';const EVENT_ICONS = {status: '🔌',@@ -59,7 +59,7 @@ const QUEUE_STATUS_STYLES = {function formatEventTime(ts) {const d = new Date(ts);- return d.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' });+ return formatClockTime(d);}function summarizeParams(action, params) {diff --git a/client/src/components/apps/tabs/GitTab.jsx b/client/src/components/apps/tabs/GitTab.jsxindex faa1af55b4..854090c905 100644--- a/client/src/components/apps/tabs/GitTab.jsx+++ b/client/src/components/apps/tabs/GitTab.jsx@@ -4,6 +4,7 @@ import toast from '../../ui/Toast';import Modal from '../../ui/Modal';import BrailleSpinner from '../../BrailleSpinner';import * as api from '../../../services/api';+import { formatDateNumeric } from '../../../utils/formatters';function buildReleasePrompt({ repoPath, appName, comparison, baseBranch, devBranch, hasChangelog }) {const commitList = comparison.commits@@ -544,7 +545,7 @@ export default function GitTab({ appId: _appId, appName, repoPath }) {<span className="text-sm text-white truncate">{commit.message}</span></div><div className="text-xs text-gray-500 mt-1">- {commit.author} • {new Date(commit.date).toLocaleDateString()}+ {commit.author} • {formatDateNumeric(commit.date)}</div></div>))}@@ -784,7 +785,7 @@ export default function GitTab({ appId: _appId, appName, repoPath }) {<div className="flex items-center gap-2 shrink-0">{rb.lastCommitDate && (<span className="text-xs text-gray-500 hidden sm:inline">- {new Date(rb.lastCommitDate).toLocaleDateString()}+ {formatDateNumeric(rb.lastCommitDate)}</span>)}{!rb.hasLocal && (diff --git a/client/src/components/apps/tabs/UpdateTab.jsx b/client/src/components/apps/tabs/UpdateTab.jsxindex 4647f27786..fa27a54a72 100644--- a/client/src/components/apps/tabs/UpdateTab.jsx+++ b/client/src/components/apps/tabs/UpdateTab.jsx@@ -6,7 +6,7 @@ import MarkdownOutput from '../../cos/MarkdownOutput';import Banner from '../../ui/Banner';import * as api from '../../../services/api';import socket from '../../../services/socket';-import { formatDateTime } from '../../../utils/formatters';+import { formatDateTime, formatDateNumeric, formatTimeOfDaySeconds } from '../../../utils/formatters';import { useAutoRefetch } from '../../../hooks/useAutoRefetch';import useMounted from '../../../hooks/useMounted';@@ -438,7 +438,7 @@ export default function UpdateTab() {<div>Updates pull from your fork's <span className="font-mono">main</span>. Sync it from <span className="font-mono">{upstreamName}</span> before updating, or apply upstream changes onto a working branch first to preserve customizations.</div><div>Tip: PR shareable fixes upstream; keep private changes on a separate branch and rebase that branch onto <span className="font-mono">main</span> after each sync.</div>{forkSyncFresh && (- <div className="text-port-success">✓ Fork synced {new Date(lastForkSync.syncedAt).toLocaleTimeString()} — ready to update.</div>+ <div className="text-port-success">✓ Fork synced {formatTimeOfDaySeconds(lastForkSync.syncedAt)} — ready to update.</div>)}</div>)}@@ -541,7 +541,7 @@ export default function UpdateTab() {</div>{release.publishedAt && (<div className="text-xs text-gray-500 mb-2">- Released {new Date(release.publishedAt).toLocaleDateString()}+ Released {formatDateNumeric(release.publishedAt)}</div>)}{release.body && (diff --git a/client/src/components/brain/tabs/BrainGraph.jsx b/client/src/components/brain/tabs/BrainGraph.jsxindex d199c9b89d..fb767f3ad2 100644--- a/client/src/components/brain/tabs/BrainGraph.jsx+++ b/client/src/components/brain/tabs/BrainGraph.jsx@@ -11,6 +11,7 @@ import { pushFocus, popFocus, currentFocusId } from '../../../lib/brainGraphFocuimport EntityCombobox from '../../EntityCombobox';import InlineConfirmRow from '../../ui/InlineConfirmRow';import BrailleSpinner from '../../BrailleSpinner';+import { formatDateNumeric } from '../../../utils/formatters';const EDGE_COLORS = {similar: '#3b82f6',@@ -708,7 +709,7 @@ export default function BrainGraph() {</div>)}<div className="text-xs text-gray-500 flex flex-wrap gap-3">- {fullRecord.createdAt && <span>Created: {new Date(fullRecord.createdAt).toLocaleDateString()}</span>}+ {fullRecord.createdAt && <span>Created: {formatDateNumeric(fullRecord.createdAt)}</span>}{fullRecord.nextAction && <span>Next: {fullRecord.nextAction}</span>}{fullRecord.horizon && <span>Horizon: {fullRecord.horizon}</span>}{fullRecord.targetDate && <span>Target: {fullRecord.targetDate}</span>}diff --git a/client/src/components/brain/tabs/DailyLogTab.jsx b/client/src/components/brain/tabs/DailyLogTab.jsxindex 53c8fd2a3a..ba13488506 100644--- a/client/src/components/brain/tabs/DailyLogTab.jsx+++ b/client/src/components/brain/tabs/DailyLogTab.jsx@@ -11,6 +11,7 @@ import { onVoiceEvent, sendText, setDictation as setVoiceDictation } from '../..import BrailleSpinner from '../../BrailleSpinner';import useMounted from '../../../hooks/useMounted';import { useVisibilityEvent } from '../../../hooks/useVisibilityEvent';+import { formatDateFull } from '../../../utils/formatters';// Autosave cadence. The debounce keeps us from PUTting on every keystroke;// the max-wait ceiling exists because a pure debounce never fires at all@@ -573,13 +574,9 @@ export default function DailyLogTab() {: dirty ? 'Unsaved…': entry ? 'Saved' : '';- const dateLabel = useMemo(() => {- try {- return new Date(`${date}T00:00:00`).toLocaleDateString(undefined, {- weekday: 'long', year: 'numeric', month: 'long', day: 'numeric'- });- } catch { return date; }- }, [date]);+ // formatDateFull anchors a bare YYYY-MM-DD at LOCAL midnight and falls back+ // to '' on an unparseable value, so a malformed route param still renders.+ const dateLabel = useMemo(() => formatDateFull(date) || date, [date]);// AI policy: the surface that can trigger LLM work names the provider, so the// overflow menu item and the sm+ button share one title string.diff --git a/client/src/components/brain/tabs/MemoryTab.jsx b/client/src/components/brain/tabs/MemoryTab.jsxindex 67445b7ad6..1a418a4877 100644--- a/client/src/components/brain/tabs/MemoryTab.jsx+++ b/client/src/components/brain/tabs/MemoryTab.jsx@@ -22,7 +22,7 @@ import {IDEA_STATUS_COLORS,ADMIN_STATUS_COLORS} from '../constants';-import { timeAgo } from '../../../utils/formatters';+import { timeAgo, formatDateNumeric } from '../../../utils/formatters';import BrailleSpinner from '../../BrailleSpinner';import InlineConfirmRow from '../../ui/InlineConfirmRow';import CopyableId from '../../ui/CopyableId';@@ -567,7 +567,7 @@ export default function MemoryTab({ onRefresh }) {</div>{record.dueDate && (<p className="text-sm text-port-warning mt-1">- Due: {new Date(record.dueDate).toLocaleDateString()}+ Due: {formatDateNumeric(record.dueDate)}</p>)}{record.nextAction && <p className="text-sm text-gray-400 mt-1">Next: {record.nextAction}</p>}diff --git a/client/src/components/calendar/AgendaTab.jsx b/client/src/components/calendar/AgendaTab.jsxindex 67c5aeef99..6237342749 100644--- a/client/src/components/calendar/AgendaTab.jsx+++ b/client/src/components/calendar/AgendaTab.jsx@@ -4,7 +4,7 @@ import toast from '../ui/Toast';import * as api from '../../services/api';import socket from '../../services/socket';import EventDetail from './EventDetail';-import { formatTimeOfDay as formatTime } from '../../utils/formatters';+import { formatTimeOfDay as formatTime, formatWeekdayDate } from '../../utils/formatters';import BrailleSpinner from '../BrailleSpinner';const RSVP_STYLES = {@@ -22,7 +22,7 @@ function formatDayHeader(dateStr) {if (date.toDateString() === today.toDateString()) return 'Today';if (date.toDateString() === tomorrow.toDateString()) return 'Tomorrow';- return date.toLocaleDateString([], { weekday: 'long', month: 'short', day: 'numeric' });+ return formatWeekdayDate(date);}function groupEventsByDay(events) {diff --git a/client/src/components/calendar/ConfigTab.jsx b/client/src/components/calendar/ConfigTab.jsxindex 15a2146726..08dc28473b 100644--- a/client/src/components/calendar/ConfigTab.jsx+++ b/client/src/components/calendar/ConfigTab.jsx@@ -3,7 +3,7 @@ import { useSearchParams } from 'react-router';import { Plus, Trash2, RefreshCw, Globe, Calendar, Eye, EyeOff, ChevronDown, ChevronRight, Search, Key, ExternalLink, Wand2, Monitor } from 'lucide-react';import toast from '../ui/Toast';import * as api from '../../services/api';-import { formatDateTime } from '../../utils/formatters';+import { formatDateTime, formatDateNumeric } from '../../utils/formatters';import FeatureProviderPicker from '../FeatureProviderPicker';import InlineConfirmRow from '../ui/InlineConfirmRow';import { FormField } from '../ui/FormField';@@ -387,7 +387,7 @@ export default function ConfigTab({ accounts, setAccounts }) {<span>Google API authenticated</span>{googleAuth.expiryDate && (<span className="text-gray-600">- (expires {new Date(googleAuth.expiryDate).toLocaleDateString()})+ (expires {formatDateNumeric(googleAuth.expiryDate)})</span>)}</div>diff --git a/client/src/components/calendar/MonthView.jsx b/client/src/components/calendar/MonthView.jsxindex f1e3f23ad3..a44e5d6658 100644--- a/client/src/components/calendar/MonthView.jsx+++ b/client/src/components/calendar/MonthView.jsx@@ -5,6 +5,7 @@ import socket from '../../services/socket';import EventDetail from './EventDetail';import { buildSubcalendarColorMap } from './calendarUtils';import BrailleSpinner from '../BrailleSpinner';+import { formatMonthYear, formatTimeOfDay } from '../../utils/formatters';function getMonthGrid(year, month) {const firstDay = new Date(year, month, 1);@@ -41,7 +42,7 @@ export default function MonthView({ accounts }) {const [selectedEvent, setSelectedEvent] = useState(null);const cells = getMonthGrid(year, month);- const monthLabel = new Date(year, month).toLocaleDateString([], { month: 'long', year: 'numeric' });+ const monthLabel = formatMonthYear(new Date(year, month));const fetchEvents = useCallback(async () => {const grid = getMonthGrid(year, month);@@ -154,7 +155,7 @@ export default function MonthView({ accounts }) {>{!event.isAllDay && (<span className="text-gray-500 mr-1">- {new Date(event.startTime).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' })}+ {formatTimeOfDay(event.startTime)}</span>)}{event.title}diff --git a/client/src/components/calendar/WeekView.jsx b/client/src/components/calendar/WeekView.jsxindex 512cca23cc..4e15ff0114 100644--- a/client/src/components/calendar/WeekView.jsx+++ b/client/src/components/calendar/WeekView.jsx@@ -6,6 +6,7 @@ import EventDetail from './EventDetail';import ChronotypeOverlay from './ChronotypeOverlay';import { buildSubcalendarColorMap } from './calendarUtils';import BrailleSpinner from '../BrailleSpinner';+import { formatMonthDay, formatWeekdayShort, formatDateShort } from '../../utils/formatters';const START_HOUR = 6;const END_HOUR = 23;@@ -173,7 +174,7 @@ export default function WeekView({ accounts }) {const nowMinutes = now.getHours() * 60 + now.getMinutes();const nowTop = ((nowMinutes - START_MINUTES) / 60) * PX_PER_HOUR;- const weekLabel = `${weekDays[0].toLocaleDateString([], { month: 'short', day: 'numeric' })} - ${weekDays[6].toLocaleDateString([], { month: 'short', day: 'numeric', year: 'numeric' })}`;+ const weekLabel = `${formatMonthDay(weekDays[0])} - ${formatDateShort(weekDays[6])}`;return (<div className="space-y-4">@@ -209,7 +210,7 @@ export default function WeekView({ accounts }) {key={i}className={`flex-1 text-center py-2 text-xs font-medium border-l border-port-border ${isToday ? 'text-port-accent' : 'text-gray-400'}`}>- <div>{day.toLocaleDateString([], { weekday: 'short' })}</div>+ <div>{formatWeekdayShort(day)}</div><div className={`text-lg ${isToday ? 'bg-port-accent text-white rounded-full w-8 h-8 flex items-center justify-center mx-auto' : ''}`}>{day.getDate()}</div>diff --git a/client/src/components/city/CityHud.jsx b/client/src/components/city/CityHud.jsxindex 68303397f4..5d9f8be151 100644--- a/client/src/components/city/CityHud.jsx+++ b/client/src/components/city/CityHud.jsx@@ -10,6 +10,7 @@ import CityVitalsList from './CityVitalsList';import CityHudCompact from './CityHudCompact';import { HudCorner, HealthBar, getHealthSentinel } from './cityHudBits';import useCityViewport from '../../hooks/useCityViewport';+import { formatClockTime } from '../../utils/formatters';// WASD controls hint shown briefly on first exploration entryfunction ControlsHint({ visible }) {@@ -150,7 +151,7 @@ export default function CityHud({ cosStatus, cosAgents, agentMap, eventLogs, con<HudCorner position="br" /><div className="font-pixel text-cyan-400 text-xl tracking-wider" style={{ textShadow: '0 0 10px rgba(6,182,212,0.6)' }}>- {time.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit' })}+ {formatClockTime(time)}</div><div className="font-pixel text-[11px] text-cyan-500 tracking-wide mt-0.5">{activeApps}/{totalApps} SYSTEMS ONLINEdiff --git a/client/src/components/city/CityHudCompact.jsx b/client/src/components/city/CityHudCompact.jsxindex c4699d8bca..3826725b3f 100644--- a/client/src/components/city/CityHudCompact.jsx+++ b/client/src/components/city/CityHudCompact.jsx@@ -9,6 +9,7 @@ import CityFilterBar from './CityFilterBar';import CityFocusPanel from './CityFocusPanel';import { CITY_PANE_IDS, CITY_INTEL_PANE_IDS, CITY_PANE_LABELS } from './cityPanes';import { birthDateCta } from '../../utils/characterXp';+import { formatClockTime } from '../../utils/formatters';// A 44×44 dock control. `active`/`aria-pressed` mark a toggled disclosure launcher;// omit `active` for one-shot actions (photo, history) that just fire a callback.@@ -159,7 +160,7 @@ export default function CityHudCompact({><span className={`w-2 h-2 rounded-full ${vitals.sentinel.dot} shadow-[0_0_4px_currentColor]`} /><span className="font-pixel text-cyan-400 text-sm tracking-wider" style={{ textShadow: '0 0 8px rgba(6,182,212,0.5)' }}>- {time.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}+ {formatClockTime(time, { seconds: false })}</span><span className="font-pixel text-[9px] text-cyan-500 tracking-wide">{vitals.activeApps}/{vitals.totalApps}</span></button>diff --git a/client/src/components/city/CityVitalsList.jsx b/client/src/components/city/CityVitalsList.jsxindex c3514e7fac..ec53daca4e 100644--- a/client/src/components/city/CityVitalsList.jsx+++ b/client/src/components/city/CityVitalsList.jsx@@ -1,5 +1,5 @@import { useNavigate } from 'react-router';-import { formatDurationMs } from '../../utils/formatters';+import { formatDurationMs, formatMonthDay } from '../../utils/formatters';import { StatButton, metricColor } from './cityHudBits';// The System Vitals rows (uptime, health CPU/MEM/DISK, agents, stopped, archived,@@ -121,7 +121,7 @@ export default function CityVitalsList({<div className="flex items-center justify-between"><span className="font-pixel text-[9px] text-cyan-500/40 tracking-widest">SYS.OK</span><span className="font-pixel text-[9px] text-cyan-500/40 tracking-widest">- {new Date().toLocaleDateString('en-US', { month: 'short', day: 'numeric' }).toUpperCase()}+ {formatMonthDay(new Date()).toUpperCase()}</span></div></div>diff --git a/client/src/components/cos/EventLog.jsx b/client/src/components/cos/EventLog.jsxindex a5eaf42a14..4edfdddc70 100644--- a/client/src/components/cos/EventLog.jsx+++ b/client/src/components/cos/EventLog.jsx@@ -1,3 +1,5 @@+import { formatTimeOfDaySeconds } from '../../utils/formatters';+const levelColors = {info: 'text-port-accent',warn: 'text-port-warning',@@ -24,7 +26,7 @@ export default function EventLog({ logs }) {{logs.slice(-25).reverse().map((log, i) => (<div key={i} className={`text-xs font-mono py-0.5 break-all ${levelColors[log.level] || 'text-gray-400'}`}><span className="mr-1">[{levelIcons[log.level] || '*'}]</span>- <span className="text-gray-500">{new Date(log.timestamp).toLocaleTimeString()}</span>+ <span className="text-gray-500">{formatTimeOfDaySeconds(log.timestamp)}</span>{' '}<span>{log.message}</span></div>diff --git a/client/src/components/cos/TerminalCoSPanel.jsx b/client/src/components/cos/TerminalCoSPanel.jsxindex 33270bf11a..8526b92f6b 100644--- a/client/src/components/cos/TerminalCoSPanel.jsx+++ b/client/src/components/cos/TerminalCoSPanel.jsx@@ -1,5 +1,6 @@import { Play, Square } from 'lucide-react';import { AGENT_STATES } from './constants';+import { formatClockTime } from '../../utils/formatters';export default function TerminalCoSPanel({ state, speaking, statusMessage, eventLogs, running, onStart, onStop, stats }) {const stateConfig = AGENT_STATES[state] || AGENT_STATES.sleeping;@@ -204,7 +205,7 @@ export default function TerminalCoSPanel({ state, speaking, statusMessage, event) : (eventLogs.slice(-20).reverse().map((log, i) => (<div key={i} className={`text-xs break-all ${levelColors[log.level] || termTextDim} leading-relaxed`}>- <span className={termTextFaint}>{new Date(log.timestamp).toLocaleTimeString('en-US', { hour12: false })}</span>+ <span className={termTextFaint}>{formatClockTime(log.timestamp, { hour12: false })}</span>{' '}<span className={levelColors[log.level]}>{levelPrefixes[log.level] || '[LOG]'}</span>{' '}diff --git a/client/src/components/cos/tabs/AgentCard.jsx b/client/src/components/cos/tabs/AgentCard.jsxindex bdc36c34db..77ec9b773e 100644--- a/client/src/components/cos/tabs/AgentCard.jsx+++ b/client/src/components/cos/tabs/AgentCard.jsx@@ -32,7 +32,7 @@ import toast from '../../ui/Toast';import { copyToClipboard } from '../../../lib/clipboard';import { extractCosTaskType } from '../../../lib/cosTaskType';import { DEFAULT_REVIEWER, normalizeReviewers } from '../constants';-import { formatBytes, formatDurationMs, formatDateTime } from '../../../utils/formatters';+import { formatBytes, formatDurationMs, formatDateTime, formatMonthDay, formatTimeOfDay } from '../../../utils/formatters';import { useAutoRefetch } from '../../../hooks/useAutoRefetch';import ConfirmButtonPair from '../../ui/ConfirmButtonPair';import { useConfirmDelete } from '../../../hooks/useConfirmDelete';@@ -557,8 +557,8 @@ export default function AgentCard({ agent, onPause, onKill, onDelete, onResume,<><span className="text-gray-600">|</span><span className="text-gray-500 whitespace-nowrap" title={formatDateTime(agent.completedAt)}>- {new Date(agent.completedAt).toLocaleDateString(undefined, { month: 'short', day: 'numeric' })}{' '}- {new Date(agent.completedAt).toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })}+ {formatMonthDay(agent.completedAt)}{' '}+ {formatTimeOfDay(agent.completedAt)}</span></>)}@@ -710,7 +710,7 @@ export default function AgentCard({ agent, onPause, onKill, onDelete, onResume,<div className="min-w-0"><span className="text-yellow-400">BTW:</span>{' '}<span className="text-gray-300">{btw.message}</span>- <span className="text-gray-600 ml-2">{new Date(btw.timestamp).toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' })}</span>+ <span className="text-gray-600 ml-2">{formatTimeOfDay(btw.timestamp)}</span></div></div>))}diff --git a/client/src/components/cos/tabs/BriefingTab.jsx b/client/src/components/cos/tabs/BriefingTab.jsxindex 9d27154b4f..379af81278 100644--- a/client/src/components/cos/tabs/BriefingTab.jsx+++ b/client/src/components/cos/tabs/BriefingTab.jsx@@ -15,6 +15,7 @@ import {import * as api from '../../../services/api';import { RapidReaderTrigger } from '../../RapidReader';import BrailleSpinner from '../../BrailleSpinner';+import { formatWeekdayDate } from '../../../utils/formatters';const SECTION_ICONS = {'Task Queue': CheckCircle,@@ -224,12 +225,7 @@ export default function BriefingTab() {>{briefings.map(b => (<option key={b.date} value={b.date}>- {new Date(b.date + 'T12:00:00').toLocaleDateString('en-US', {- weekday: 'short',- month: 'short',- day: 'numeric',- year: 'numeric'- })}+ {formatWeekdayDate(b.date, { weekday: 'short', year: true })}</option>))}</select>diff --git a/client/src/components/cos/tabs/DigestTab.jsx b/client/src/components/cos/tabs/DigestTab.jsxindex 4f37ec4fd1..0a1a68067c 100644--- a/client/src/components/cos/tabs/DigestTab.jsx+++ b/client/src/components/cos/tabs/DigestTab.jsx@@ -18,6 +18,7 @@ import {import * as api from '../../../services/api';import BrailleSpinner from '../../BrailleSpinner';import Banner from '../../ui/Banner';+import { formatDateNumeric } from '../../../utils/formatters';export default function DigestTab() {const [currentDigest, setCurrentDigest] = useState(null);@@ -405,7 +406,7 @@ export default function DigestTab() {{/* Meta info */}<div className="text-xs text-gray-600 text-center pt-4 border-t border-port-border">Week: {currentDigest.weekId}- ({new Date(currentDigest.weekStart).toLocaleDateString()} - {new Date(currentDigest.weekEnd).toLocaleDateString()})+ ({formatDateNumeric(currentDigest.weekStart)} - {formatDateNumeric(currentDigest.weekEnd)}){currentDigest.previousWeekId && (<span className="ml-2">| Compared to {currentDigest.previousWeekId}</span>)}diff --git a/client/src/components/cos/tabs/JobsTab.jsx b/client/src/components/cos/tabs/JobsTab.jsxindex b3b52efe5c..14b673bb8a 100644--- a/client/src/components/cos/tabs/JobsTab.jsx+++ b/client/src/components/cos/tabs/JobsTab.jsx@@ -2,7 +2,7 @@ import { useState, useEffect, useCallback } from 'react';import { Plus, RefreshCw, Play, Trash2, ChevronDown, ChevronUp, Clock, ToggleLeft, ToggleRight, Edit3, Save, X, Terminal } from 'lucide-react';import toast from '../../ui/Toast';import * as api from '../../../services/api';-import { timeAgo, formatDateTime } from '../../../utils/formatters';+import { timeAgo, formatDateTime, formatDateNumeric } from '../../../utils/formatters';import { CRON_PRESETS, DEFAULT_CRON, describeCron } from '../../../utils/cronHelpers';import WeekdayTimePicker from '../../WeekdayTimePicker';import { effectiveModelFor, effortAwareModelOptions } from '../../../utils/providers';@@ -587,7 +587,7 @@ function JobCard({ job, apps, providers, onToggle, onTrigger, onDelete, onUpdate<span>AI: <span className="text-gray-300">{providers.find(p => p.id === job.providerId)?.name || job.providerId}{job.model ? ` / ${job.model}` : ''}{job.effort ? ` · ${job.effort}` : ''}</span></span>)}{isShell && <span>Action: <span className="text-gray-300">{job.triggerAction || 'log-only'}</span></span>}- <span>Created: <span className="text-gray-300">{job.createdAt ? new Date(job.createdAt).toLocaleDateString() : '—'}</span></span>+ <span>Created: <span className="text-gray-300">{formatDateNumeric(job.createdAt, '—')}</span></span></div>{job.config && BRIEFING_CONFIG_OPTIONS.some(o => job.config[o.key]) && (<div className="flex flex-wrap gap-2 text-xs">diff --git a/client/src/components/cos/tabs/LearningTab.jsx b/client/src/components/cos/tabs/LearningTab.jsxindex 6eb1088a4a..daeef82a40 100644--- a/client/src/components/cos/tabs/LearningTab.jsx+++ b/client/src/components/cos/tabs/LearningTab.jsx@@ -31,7 +31,7 @@ import {import toast from '../../ui/Toast';import * as api from '../../../services/api';import BrailleSpinner from '../../BrailleSpinner';-import { formatDurationMin, formatDateTime } from '../../../utils/formatters';+import { formatDurationMin, formatDateTime, formatDateNumeric } from '../../../utils/formatters';// Evidence pairing (issue #2617): when the server classified a task type on// its recency-windowed rate, label the percentage with the WINDOW's sample@@ -859,7 +859,7 @@ export default function LearningTab() {<div key={idx} className="p-3"><div className="flex items-center justify-between mb-1"><span className="text-xs text-gray-500 font-mono">{err.taskType}</span>- <span className="text-xs text-gray-600">{new Date(err.recordedAt).toLocaleDateString()}</span>+ <span className="text-xs text-gray-600">{formatDateNumeric(err.recordedAt)}</span></div><div className="text-sm text-gray-300 font-mono break-all">{err.message || 'No message'}</div>{err.details && (diff --git a/client/src/components/cos/tabs/MemoryGraph.jsx b/client/src/components/cos/tabs/MemoryGraph.jsxindex 0ec32e8138..6eec3a5c7f 100644--- a/client/src/components/cos/tabs/MemoryGraph.jsx+++ b/client/src/components/cos/tabs/MemoryGraph.jsx@@ -6,6 +6,7 @@ import * as api from '../../../services/api';import { MEMORY_TYPES, MEMORY_TYPE_COLORS } from '../constants';import { buildGraph } from '../../../lib/graphSimulation';import BrailleSpinner from '../../BrailleSpinner';+import { formatDateNumeric } from '../../../utils/formatters';const TYPE_HEX = {fact: '#3b82f6',@@ -302,7 +303,7 @@ export default function MemoryGraph() {</div>)}<div className="text-xs text-gray-500 flex flex-wrap gap-3">- <span>Created: {new Date(fullMemory.createdAt).toLocaleDateString()}</span>+ <span>Created: {formatDateNumeric(fullMemory.createdAt)}</span>{fullMemory.accessCount > 0 && <span>Accessed: {fullMemory.accessCount}x</span>}{fullMemory.confidence != null && <span>Confidence: {(fullMemory.confidence * 100).toFixed(0)}%</span>}</div>diff --git a/client/src/components/cos/tabs/MemoryTab.jsx b/client/src/components/cos/tabs/MemoryTab.jsxindex 90b9c624bd..03277ac210 100644--- a/client/src/components/cos/tabs/MemoryTab.jsx+++ b/client/src/components/cos/tabs/MemoryTab.jsx@@ -5,7 +5,7 @@ import toast from '../../ui/Toast';import Banner from '../../ui/Banner';import * as api from '../../../services/api';import { MEMORY_TYPES, MEMORY_TYPE_COLORS } from '../constants';-import { getAppName } from '../../../utils/formatters';+import { getAppName, formatDateNumeric } from '../../../utils/formatters';import MemoryTimeline from './MemoryTimeline';// Lazy: MemoryGraph pulls the three.js stack; load it only when rendered.const MemoryGraph = lazy(() => import('./MemoryGraph'));@@ -285,7 +285,7 @@ export default function MemoryTab({ apps = [] }) {</div>)}<div className="text-xs text-gray-500 mt-2 flex flex-wrap gap-2">- <span>{new Date(memory.createdAt).toLocaleDateString()}</span>+ <span>{formatDateNumeric(memory.createdAt)}</span>{getAppName(memory.sourceAppId, apps) && (<><span>*</span>@@ -426,7 +426,7 @@ export default function MemoryTab({ apps = [] }) {</div>)}<div className="text-xs text-gray-500 mt-2 flex flex-wrap items-center gap-2">- <span>{new Date(memory.createdAt).toLocaleDateString()}</span>+ <span>{formatDateNumeric(memory.createdAt)}</span><span>*</span><span>importance: {((memory.importance || 0.5) * 100).toFixed(0)}%</span>{getAppName(memory.sourceAppId, apps) && (diff --git a/client/src/components/cos/tabs/MemoryTimeline.jsx b/client/src/components/cos/tabs/MemoryTimeline.jsxindex 6ebeb16432..ce1082a05e 100644--- a/client/src/components/cos/tabs/MemoryTimeline.jsx+++ b/client/src/components/cos/tabs/MemoryTimeline.jsx@@ -1,3 +1,5 @@+import { formatWeekdayDate } from '../../../utils/formatters';+export default function MemoryTimeline({ memories }) {const grouped = memories.reduce((acc, m) => {const date = m.createdAt?.split('T')[0] || 'Unknown';@@ -13,7 +15,7 @@ export default function MemoryTimeline({ memories }) {{dates.map(date => (<div key={date}><div className="text-sm font-medium text-gray-400 mb-2 sticky top-0 bg-port-bg py-1">- {new Date(date).toLocaleDateString('en-US', { weekday: 'long', month: 'short', day: 'numeric' })}+ {formatWeekdayDate(date)}</div><div className="border-l border-port-border pl-4 space-y-3">{grouped[date].map(m => (diff --git a/client/src/components/cos/tabs/ProductivityTab.jsx b/client/src/components/cos/tabs/ProductivityTab.jsxindex b884c7e9e6..bbf7ff24e0 100644--- a/client/src/components/cos/tabs/ProductivityTab.jsx+++ b/client/src/components/cos/tabs/ProductivityTab.jsx@@ -16,7 +16,7 @@ import {Award} from 'lucide-react';import BrailleSpinner from '../../BrailleSpinner';-import { formatDateTime } from '../../../utils/formatters';+import { formatDateTime, formatDateNumeric } from '../../../utils/formatters';import * as api from '../../../services/api';import DailyTrendsChart from '../DailyTrendsChart';@@ -389,7 +389,7 @@ export default function ProductivityTab() {<div className="text-sm font-medium text-white">{m.description}</div>{m.achievedAt && (<div className="text-xs text-gray-500 mt-1">- {new Date(m.achievedAt).toLocaleDateString()}+ {formatDateNumeric(m.achievedAt)}</div>)}</div>diff --git a/client/src/components/cos/tabs/ScheduleTab.jsx b/client/src/components/cos/tabs/ScheduleTab.jsxindex fbaada24ed..ffb777caff 100644--- a/client/src/components/cos/tabs/ScheduleTab.jsx+++ b/client/src/components/cos/tabs/ScheduleTab.jsx@@ -3,7 +3,7 @@ import { useSearchParams } from 'react-router';import { AlertCircle, RefreshCw } from 'lucide-react';import toast from '../../ui/Toast';import * as api from '../../../services/api';-import { formatDateTime } from '../../../utils/formatters';+import { formatDateTime, formatTimeOfDaySeconds } from '../../../utils/formatters';import Banner from '../../ui/Banner';import { CodeReviewDefaultsProvider } from '../../../hooks/useCodeReviewDefaults';import { useAppOverrideActions } from '../../../hooks/useAppOverrideActions';@@ -147,7 +147,7 @@ export default function ScheduleTab({ apps, providers, activeProviderId }) {<div className="space-y-1 mt-2">{schedule.onDemandRequests.map(req => (<div key={req.id} className="text-sm text-gray-300">- {req.taskType}{req.appId ? ` (${req.appId})` : ''} - requested {new Date(req.requestedAt).toLocaleTimeString()}+ {req.taskType}{req.appId ? ` (${req.appId})` : ''} - requested {formatTimeOfDaySeconds(req.requestedAt)}</div>))}</div>diff --git a/client/src/components/cos/tabs/WorkflowTab.jsx b/client/src/components/cos/tabs/WorkflowTab.jsxindex 27e9da2e95..f1ed278adb 100644--- a/client/src/components/cos/tabs/WorkflowTab.jsx+++ b/client/src/components/cos/tabs/WorkflowTab.jsx@@ -6,6 +6,7 @@ import { useAppOverrideActions } from '../../../hooks/useAppOverrideActions';import { describeCron } from '../../../utils/cronHelpers';import ScheduleEditor from './workflow/ScheduleEditor';import PerAppOverrideList from './schedule/PerAppOverrideList';+import { formatWeekdayShort, formatWeekdayTime, formatTimeOfDay } from '../../../utils/formatters';const TRACK_COLORS = {cron: { marker: 'bg-purple-400', text: 'text-purple-300', wash: 'bg-purple-500/10' },@@ -38,11 +39,9 @@ function describeSchedule(node) {}function formatPoint(iso, hours, timezone) {- const date = new Date(iso);- const options = { hour: 'numeric', minute: '2-digit', timeZone: timezone };return hours === 168- ? date.toLocaleString([], { ...options, weekday: 'short' })- : date.toLocaleTimeString([], options);+ ? formatWeekdayTime(iso, { timeZone: timezone })+ : formatTimeOfDay(iso, { timeZone: timezone });}function relativeTime(iso) {@@ -61,7 +60,7 @@ function dueNowMeta(occurrence, node, timezone) {const reason = occurrence.reason || '';if (reason.startsWith('cron-catch-up')) {const slot = occurrence.missedSlot- ? new Date(occurrence.missedSlot).toLocaleString([], { weekday: 'short', hour: 'numeric', minute: '2-digit', timeZone: timezone })+ ? formatWeekdayTime(occurrence.missedSlot, { timeZone: timezone }): null;return { badge: 'catch-up', detail: slot ? `Catch-up for the missed ${slot} slot` : 'Catch-up for a missed slot' };}@@ -87,7 +86,7 @@ function Axis({ timeline, hours, timezone }) {const at = new Date(start + ((end - start) * index) / divisions);return (<div key={index} className="absolute bottom-1 -translate-x-1/2 whitespace-nowrap" style={{ left: `${(index / divisions) * 100}%` }}>- {index === 0 ? 'Now' : hours === 168 ? at.toLocaleDateString([], { weekday: 'short', timeZone: timezone }) : `+${index * 3}h`}+ {index === 0 ? 'Now' : hours === 168 ? formatWeekdayShort(at, { timeZone: timezone }) : `+${index * 3}h`}</div>);})}diff --git a/client/src/components/digital-twin/ObservedTasteEvidence.jsx b/client/src/components/digital-twin/ObservedTasteEvidence.jsxindex a7abac6228..e606de09c1 100644--- a/client/src/components/digital-twin/ObservedTasteEvidence.jsx+++ b/client/src/components/digital-twin/ObservedTasteEvidence.jsx@@ -4,6 +4,7 @@ import * as api from '../../services/api';import toast from '../ui/Toast';import BrailleSpinner from '../BrailleSpinner';import MarkdownOutput from '../cos/MarkdownOutput';+import { formatDateTime } from '../../utils/formatters';// Divergence badge: divergence is SIGNAL, not error — stated and observed// chronotypes differing is a legitimate insight, so we frame it neutrally.@@ -273,7 +274,7 @@ export default function ObservedTasteEvidence() {<div className="text-xs text-gray-500 mt-2">{interpretation.providerName || interpretation.provider}{interpretation.model ? ` · ${interpretation.model}` : ''}- {interpretation.generatedAt ? ` · ${new Date(interpretation.generatedAt).toLocaleString()}` : ''}+ {interpretation.generatedAt ? ` · ${formatDateTime(interpretation.generatedAt)}` : ''}</div></div>)}diff --git a/client/src/components/digital-twin/PersonalityMap.jsx b/client/src/components/digital-twin/PersonalityMap.jsxindex af3d5c8bb9..09cc14afa9 100644--- a/client/src/components/digital-twin/PersonalityMap.jsx+++ b/client/src/components/digital-twin/PersonalityMap.jsx@@ -3,6 +3,7 @@ import { Brain, RefreshCw, AlertCircle } from 'lucide-react';import * as api from '../../services/api';import toast from '../ui/Toast';import { filterSelectableModels } from '../../utils/providers';+import { formatDateNumeric } from '../../utils/formatters';const BIG_FIVE_LABELS = {O: { name: 'Openness', low: 'Practical', high: 'Curious' },@@ -290,7 +291,7 @@ export default function PersonalityMap({ traits, confidence, providers, onAnalyz<span className="text-sm text-gray-400">Last analyzed</span><span className="text-sm text-white">{traits.lastAnalyzed- ? new Date(traits.lastAnalyzed).toLocaleDateString()+ ? formatDateNumeric(traits.lastAnalyzed): 'Never'}</span></div>diff --git a/client/src/components/digital-twin/tabs/AutobiographyTab.jsx b/client/src/components/digital-twin/tabs/AutobiographyTab.jsxindex 8af00b7ab2..b84b65c6cc 100644--- a/client/src/components/digital-twin/tabs/AutobiographyTab.jsx+++ b/client/src/components/digital-twin/tabs/AutobiographyTab.jsx@@ -21,7 +21,7 @@ import * as api from '../../../services/api';import { copyToClipboard } from '../../../lib/clipboard';import toast from '../../ui/Toast';import { useConfirmDelete } from '../../../hooks/useConfirmDelete';-import { formatDateTime } from '../../../utils/formatters';+import { formatDateTime, formatDateNumeric } from '../../../utils/formatters';export default function AutobiographyTab({ onRefresh }) {const [searchParams, setSearchParams] = useSearchParams();@@ -479,7 +479,7 @@ export default function AutobiographyTab({ onRefresh }) {)}<span className="text-xs text-gray-500">{story.wordCount} words</span><span className="text-xs text-gray-600">- {new Date(story.createdAt).toLocaleDateString()}+ {formatDateNumeric(story.createdAt)}</span></div><p className="text-sm text-gray-300 truncate">{story.promptText}</p>diff --git a/client/src/components/digital-twin/tabs/EnrichTab.jsx b/client/src/components/digital-twin/tabs/EnrichTab.jsxindex a19265fa47..d69ac1e09e 100644--- a/client/src/components/digital-twin/tabs/EnrichTab.jsx+++ b/client/src/components/digital-twin/tabs/EnrichTab.jsx@@ -18,6 +18,7 @@ import { FormField } from '../../ui/FormField';import { ENRICHMENT_CATEGORIES } from '../constants';import ListEnrichment from '../ListEnrichment';import ScaleInput from '../ScaleInput';+import { formatDateNumeric } from '../../../utils/formatters';export default function EnrichTab({ onRefresh }) {const [searchParams, setSearchParams] = useSearchParams();@@ -450,7 +451,7 @@ export default function EnrichTab({ onRefresh }) {{progress?.lastSession && (<p className="text-sm text-gray-500 mt-3">- Last session: {new Date(progress.lastSession).toLocaleDateString()}+ Last session: {formatDateNumeric(progress.lastSession)}</p>)}</div>diff --git a/client/src/components/digital-twin/tabs/GoalsTab.jsx b/client/src/components/digital-twin/tabs/GoalsTab.jsxindex 8a6dd671d6..e32d4a901e 100644--- a/client/src/components/digital-twin/tabs/GoalsTab.jsx+++ b/client/src/components/digital-twin/tabs/GoalsTab.jsx@@ -7,6 +7,7 @@ import InlineConfirmRow from '../../ui/InlineConfirmRow';import { FormField } from '../../ui/FormField';import * as api from '../../../services/api';import { useConfirmDelete } from '../../../hooks/useConfirmDelete';+import { formatDateNumeric } from '../../../utils/formatters';const CATEGORY_CONFIG = {creative: { label: 'Creative', icon: Lightbulb, color: 'text-purple-400', bg: 'bg-purple-500/20' },@@ -392,7 +393,7 @@ export default function GoalsTab({ onRefresh }) {</span>)}<span className="px-2 py-0.5 rounded bg-gray-700 text-gray-400">- Created {new Date(goal.createdAt).toLocaleDateString()}+ Created {formatDateNumeric(goal.createdAt)}</span></div>@@ -422,7 +423,7 @@ export default function GoalsTab({ onRefresh }) {</span>{ms.targetDate && (<span className="text-xs text-gray-600 ml-auto">- {new Date(ms.targetDate).toLocaleDateString()}+ {formatDateNumeric(ms.targetDate)}</span>)}</div>diff --git a/client/src/components/digital-twin/tabs/TasteTab.jsx b/client/src/components/digital-twin/tabs/TasteTab.jsxindex fe4060e1bd..f59e52c919 100644--- a/client/src/components/digital-twin/tabs/TasteTab.jsx+++ b/client/src/components/digital-twin/tabs/TasteTab.jsx@@ -28,6 +28,7 @@ import Banner from '../../ui/Banner';import MarkdownOutput from '../../cos/MarkdownOutput';import { isApiProvider } from '../../../utils/providers';import ObservedTasteEvidence from '../ObservedTasteEvidence';+import { formatDateNumeric } from '../../../utils/formatters';const SECTION_ICONS = {movies: Film,@@ -664,7 +665,7 @@ export default function TasteTab({ onRefresh }) {{profile?.lastSessionAt && (<p className="text-sm text-gray-500 mt-3">- Last session: {new Date(profile.lastSessionAt).toLocaleDateString()}+ Last session: {formatDateNumeric(profile.lastSessionAt)}</p>)}</div>diff --git a/client/src/components/goals/GoalCheckIns.jsx b/client/src/components/goals/GoalCheckIns.jsxindex 3bbe472b4a..2607d9592b 100644--- a/client/src/components/goals/GoalCheckIns.jsx+++ b/client/src/components/goals/GoalCheckIns.jsx@@ -1,6 +1,7 @@import { ChevronDown, ChevronRight, ClipboardCheck, Wand2 } from 'lucide-react';import Pill from '../ui/Pill';import { CHECK_IN_STATUS_CONFIG, CHECK_IN_DOT_COLORS } from './goalConstants';+import { formatDateNumeric } from '../../utils/formatters';export default function GoalCheckIns({goal, checkInsOpen, setCheckInsOpen, checkingIn, handleCheckIn@@ -38,7 +39,7 @@ export default function GoalCheckIns({return (<div key={ci.id} className="p-2 rounded bg-port-bg border border-port-border space-y-1"><div className="flex items-center justify-between">- <span className="text-[10px] text-gray-500">{new Date(ci.date + 'T00:00:00').toLocaleDateString()}</span>+ <span className="text-[10px] text-gray-500">{formatDateNumeric(ci.date)}</span><Pill tone="bare" size="xs" bordered={false} className={`${sc.bg} ${sc.color}`}>{sc.label}</Pill></div><div className="text-[10px] text-gray-500">diff --git a/client/src/components/goals/GoalDetailPanel.jsx b/client/src/components/goals/GoalDetailPanel.jsxindex 200e12bb88..e5d37921f6 100644--- a/client/src/components/goals/GoalDetailPanel.jsx+++ b/client/src/components/goals/GoalDetailPanel.jsx@@ -16,6 +16,7 @@ import GoalCheckIns from './GoalCheckIns';import GoalProgressLog from './GoalProgressLog';import GoalLinkedActivities from './GoalLinkedActivities';import GoalLinkedCalendars from './GoalLinkedCalendars';+import { formatDateNumeric } from '../../utils/formatters';// Re-exported for backward compatibility — GoalsListView/GoalsTreeView/GoalProgressWidget// import these from GoalDetailPanel. Source of truth is ./goalConstants.@@ -201,7 +202,7 @@ export default function GoalDetailPanel({ goal, allGoals, onClose, onRefresh }){goal.targetDate && (<div className="flex items-center gap-1.5 text-xs text-gray-400"><Calendar className="w-3.5 h-3.5" />- <span>Target: {new Date(goal.targetDate + 'T00:00:00').toLocaleDateString()}</span>+ <span>Target: {formatDateNumeric(goal.targetDate)}</span></div>)}diff --git a/client/src/components/goals/GoalMilestones.jsx b/client/src/components/goals/GoalMilestones.jsxindex 2957cdc142..798fefcf8a 100644--- a/client/src/components/goals/GoalMilestones.jsx+++ b/client/src/components/goals/GoalMilestones.jsx@@ -1,5 +1,6 @@import { Milestone, Check, Calendar } from 'lucide-react';import { PRIORITY_BADGE } from './goalConstants';+import { formatDateNumeric } from '../../utils/formatters';export default function GoalMilestones({goal, newMilestone, setNewMilestone, handleAddMilestone, handleCompleteMilestone,@@ -35,7 +36,7 @@ export default function GoalMilestones({{ms.targetDate && (<span className="text-xs text-gray-600 ml-auto flex items-center gap-1"><Calendar className="w-3 h-3" />- {new Date(ms.targetDate).toLocaleDateString()}+ {formatDateNumeric(ms.targetDate)}</span>)}</div>diff --git a/client/src/components/goals/GoalProgressLog.jsx b/client/src/components/goals/GoalProgressLog.jsxindex 4ccfa6bb1d..28e12bdbee 100644--- a/client/src/components/goals/GoalProgressLog.jsx+++ b/client/src/components/goals/GoalProgressLog.jsx@@ -1,5 +1,5 @@import { NotebookPen, Plus, Clock, Trash2 } from 'lucide-react';-import { formatDurationMin } from '../../utils/formatters';+import { formatDurationMin, formatDateNumeric } from '../../utils/formatters';import InlineConfirmRow from '../ui/InlineConfirmRow';import { useConfirmDelete } from '../../hooks/useConfirmDelete';@@ -81,7 +81,7 @@ export default function GoalProgressLog({<div className="flex items-start gap-2 text-xs group"><div className="flex-1 min-w-0"><div className="flex items-center gap-1.5 text-gray-500">- <span>{new Date(entry.date + 'T00:00:00').toLocaleDateString()}</span>+ <span>{formatDateNumeric(entry.date)}</span>{entry.durationMinutes && (<span className="flex items-center gap-0.5"><Clock className="w-3 h-3" />diff --git a/client/src/components/goals/ProgressSlider.jsx b/client/src/components/goals/ProgressSlider.jsxindex b474a05294..64cc7b05f6 100644--- a/client/src/components/goals/ProgressSlider.jsx+++ b/client/src/components/goals/ProgressSlider.jsx@@ -1,6 +1,6 @@import { useState, useEffect, useRef } from 'react';import { TrendingUp, TrendingDown, Minus, Clock } from 'lucide-react';-import { formatDurationMin } from '../../utils/formatters';+import { formatDurationMin, formatDateNumeric } from '../../utils/formatters';export default function ProgressSlider({ goal, onCommit }) {const stored = goal.progress ?? 0;@@ -104,7 +104,7 @@ export default function ProgressSlider({ goal, onCommit }) {</div>{goal.velocity.projectedCompletion && (<span className="text-gray-600">- ETA {new Date(goal.velocity.projectedCompletion + 'T00:00:00').toLocaleDateString()}+ ETA {formatDateNumeric(goal.velocity.projectedCompletion)}</span>)}</div>diff --git a/client/src/components/meatspace/tabs/GenomeTab.jsx b/client/src/components/meatspace/tabs/GenomeTab.jsxindex 922599aa60..20bdaa6a0f 100644--- a/client/src/components/meatspace/tabs/GenomeTab.jsx+++ b/client/src/components/meatspace/tabs/GenomeTab.jsx@@ -56,7 +56,7 @@ async function parseZipText(arrayBuffer, ext = '.txt') {}import * as api from '../../../services/api';import { ATTACHMENT_MAX_FILE_SIZE } from '../../../utils/fileUpload';-import { formatBytes } from '../../../utils/formatters';+import { formatBytes, formatDateNumeric } from '../../../utils/formatters';import GenomeCategoryCard from '../GenomeCategoryCard';import EpigeneticTracker from '../EpigeneticTracker';import ProvenanceChip from '../../ui/ProvenanceChip';@@ -688,7 +688,7 @@ export default function GenomeTab() {<><span className="text-xs text-gray-500">{clinvarStatus.variantCount?.toLocaleString()} variants indexed- {clinvarStatus.syncedAt && ` (synced ${new Date(clinvarStatus.syncedAt).toLocaleDateString()})`}+ {clinvarStatus.syncedAt && ` (synced ${formatDateNumeric(clinvarStatus.syncedAt)})`}</span><buttononClick={handleClinvarScan}diff --git a/client/src/components/meatspace/tabs/OverviewTab.jsx b/client/src/components/meatspace/tabs/OverviewTab.jsxindex 0c2b5df72b..fd18211a1b 100644--- a/client/src/components/meatspace/tabs/OverviewTab.jsx+++ b/client/src/components/meatspace/tabs/OverviewTab.jsx@@ -7,7 +7,7 @@ import DeathClockCountdown from '../../DeathClockCountdown';import ProvenanceChip from '../../ui/ProvenanceChip';import { useAutoRefetch } from '../../../hooks/useAutoRefetch';import { clickableProps } from '../../../lib/a11yKeyboard.js';-import { formatWeight, formatPercent } from '../../../utils/formatters.js';+import { formatWeight, formatPercent, formatDateShort } from '../../../utils/formatters';function HealthTile({ icon: Icon, iconColor, label, metrics, onClick }) {return (@@ -49,7 +49,7 @@ function CompactCountdown({ deathDate, lifeExpectancy, percentComplete, lev }) {whatWouldChange="New genome, lifestyle, or body-metric data shifts the projection; the actuarial baseline updates with your age."/><span className="text-xs text-gray-500">- ({new Date(deathDate).toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })})+ ({formatDateShort(deathDate)}){lev?.onTrack && <span className="text-port-success font-medium"> +LEV</span>}</span></div>diff --git a/client/src/components/meatspace/tabs/calendar/lifeGridMath.js b/client/src/components/meatspace/tabs/calendar/lifeGridMath.jsindex 8e098b42b8..1abc7393e3 100644--- a/client/src/components/meatspace/tabs/calendar/lifeGridMath.js+++ b/client/src/components/meatspace/tabs/calendar/lifeGridMath.js@@ -1,6 +1,8 @@// Pure date/grid computation helpers for the Life Calendar.// No React, no DOM — safe to unit-test in isolation.+import { formatDateNumeric } from '../../../../utils/formatters';+export const MS_PER_DAY = 86400000;export const MONTH_NAMES = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];@@ -194,7 +196,7 @@ export function computeMonthCalendars(birthDate, deathDate, selectedAge) {else if (date <= now && now < dateEnd) status = 'c';else status = 'r';const isBirthday = month === birthMonth && d === birthDay;- days.push({ day: d, status, isBirthday, dow: date.getDay(), label: date.toLocaleDateString() });+ days.push({ day: d, status, isBirthday, dow: date.getDay(), label: formatDateNumeric(date) });}months.push({ year, month, name: `${MONTH_NAMES[month]} ${year}`, firstDow, days });diff --git a/client/src/components/media/MediaJobsQueue.jsx b/client/src/components/media/MediaJobsQueue.jsxindex 8dbe12d29f..f55a28580c 100644--- a/client/src/components/media/MediaJobsQueue.jsx+++ b/client/src/components/media/MediaJobsQueue.jsx@@ -12,6 +12,7 @@ import { lossSparklineGeometry } from '../../lib/lossSparkline';import { useAutoRefetch } from '../../hooks/useAutoRefetch';import { useConfirmDelete } from '../../hooks/useConfirmDelete';import useMounted from '../../hooks/useMounted';+import { formatTimeOfDaySeconds } from '../../utils/formatters';const STATUS_BADGE = {queued: 'bg-port-border text-port-text-muted',@@ -445,9 +446,9 @@ function JobRow({ job, onCancel, onRetry, onRunNow, onDelete }) {<TrainingJobDetail runId={job.params.runId} status={job.status} />)}<div className="text-xs text-port-text-muted mt-1">- {job.queuedAt && `queued ${new Date(job.queuedAt).toLocaleTimeString()}`}- {job.startedAt && ` · started ${new Date(job.startedAt).toLocaleTimeString()}`}- {job.completedAt && ` · finished ${new Date(job.completedAt).toLocaleTimeString()}`}+ {job.queuedAt && `queued ${formatTimeOfDaySeconds(job.queuedAt)}`}+ {job.startedAt && ` · started ${formatTimeOfDaySeconds(job.startedAt)}`}+ {job.completedAt && ` · finished ${formatTimeOfDaySeconds(job.completedAt)}`}</div>{editing && (<EditRetryFormdiff --git a/client/src/components/media/MediaLightbox.jsx b/client/src/components/media/MediaLightbox.jsxindex 18cebd162f..475a1ab17b 100644--- a/client/src/components/media/MediaLightbox.jsx+++ b/client/src/components/media/MediaLightbox.jsx@@ -13,7 +13,7 @@ import { isEditableTarget } from '../../hooks/useKeyboardShortcuts';import useFocusTrap from '../../hooks/useFocusTrap.js';import { copyToClipboard } from '../../lib/clipboard';import { IMAGE_GEN_MODE } from '../../lib/imageGenBackends';-import { formatDateTime } from '../../utils/formatters';+import { formatDateTime, formatDateNumeric } from '../../utils/formatters';// Intentionally NOT migrated to <ui/Modal> or <components/Drawer>. The// prev/next buttons sit as viewport-edge siblings of the card (not children@@ -383,7 +383,7 @@ function PeerNotes({ others }) {{o.starred && <Star className="w-3 h-3 fill-current text-port-warning" />}<span>{o.authorName || 'Unknown'}</span></span>- <span>{o.updatedAt ? new Date(o.updatedAt).toLocaleDateString() : ''}</span>+ <span>{formatDateNumeric(o.updatedAt)}</span></div>{o.note && <p className="text-gray-200 whitespace-pre-wrap text-xs">{o.note}</p>}</li>diff --git a/client/src/components/messages/IMessageTab.jsx b/client/src/components/messages/IMessageTab.jsxindex b13746276f..6f56a5e13e 100644--- a/client/src/components/messages/IMessageTab.jsx+++ b/client/src/components/messages/IMessageTab.jsx@@ -7,7 +7,7 @@ import {import BrailleSpinner from '../BrailleSpinner';import toast from '../ui/Toast';import * as api from '../../services/api';-import { formatClockTime, timeAgo } from '../../utils/formatters';+import { formatClockTime, timeAgo, formatDateNumeric } from '../../utils/formatters';// Comms → Messages → iMessage (#2413). Browse / manage PortOS-side activity// ingested from macOS chat.db. Deletes and blocklists never write Apple's Messages database.@@ -610,7 +610,7 @@ export default function IMessageTab() {</span>{stats?.earliestAt && (<span className="rounded border border-port-border bg-port-card px-2 py-1">- {new Date(stats.earliestAt).toLocaleDateString()} → {stats.latestAt ? new Date(stats.latestAt).toLocaleDateString() : '—'}+ {formatDateNumeric(stats.earliestAt)} → {formatDateNumeric(stats.latestAt, '—')}</span>)}{hasMore && (diff --git a/client/src/components/messages/InboxTab.jsx b/client/src/components/messages/InboxTab.jsxindex 7bed2327d3..5424734257 100644--- a/client/src/components/messages/InboxTab.jsx+++ b/client/src/components/messages/InboxTab.jsx@@ -4,7 +4,7 @@ import { useNavigate, useSearchParams } from 'react-router';import toast from '../ui/Toast';import * as api from '../../services/api';import socket from '../../services/socket';-import { timeAgo } from '../../utils/formatters';+import { timeAgo, formatDateNumeric } from '../../utils/formatters';import MessageDetail from './MessageDetail';const ACTION_CONFIG = {@@ -522,7 +522,7 @@ export default function InboxTab({ accounts }) {{msg.from?.name || msg.from?.email || 'Unknown'}</span><span className="text-xs text-gray-600 shrink-0">- {msg.date ? new Date(msg.date).toLocaleDateString() : ''}+ {formatDateNumeric(msg.date)}</span></div><div className={`text-sm truncate ${msg.isUnread || !msg.isRead ? 'text-gray-300' : 'text-gray-500'}`}>diff --git a/client/src/components/privacy/PrivacyChangesTab.jsx b/client/src/components/privacy/PrivacyChangesTab.jsxindex 017f8b044a..d313fa53d7 100644--- a/client/src/components/privacy/PrivacyChangesTab.jsx+++ b/client/src/components/privacy/PrivacyChangesTab.jsx@@ -10,6 +10,7 @@ import toast from '../ui/Toast';import DeclareChangeDrawer from './DeclareChangeDrawer';import { VAULT_TYPES, CHANGE_KINDS, labelFor } from './constants';import { isHttpUrl } from '../../utils/urlNormalize';+import { formatDateNumeric } from '../../utils/formatters';// A slim progress bar over pending/updated/removed. Done = zero pending.function ProgressBar({ progress }) {@@ -197,7 +198,7 @@ export default function PrivacyChangesTab({ subjectId }) {<span className="text-white truncate">{ev.replacementRecord?.maskedValue ?? 'removed'}</span></div><div className="text-[11px] text-gray-600 mt-0.5">- {labelFor(VAULT_TYPES, ev.oldRecord?.type)} · {ev.declaredAt ? new Date(ev.declaredAt).toLocaleDateString() : ''}+ {labelFor(VAULT_TYPES, ev.oldRecord?.type)} · {formatDateNumeric(ev.declaredAt)}</div></div><ProgressBar progress={ev.progress} />diff --git a/client/src/components/settings/ContactsTab.jsx b/client/src/components/settings/ContactsTab.jsxindex df30bbc45b..a06305c9b3 100644--- a/client/src/components/settings/ContactsTab.jsx+++ b/client/src/components/settings/ContactsTab.jsx@@ -6,6 +6,7 @@ import {} from 'lucide-react';import toast from '../ui/Toast';import BrailleSpinner from '../BrailleSpinner';+import { formatDateTime } from '../../utils/formatters';import {getContactsStatus,checkContactsSetup,@@ -182,7 +183,7 @@ export function ContactsTab() {<div><dt className="text-gray-500 text-xs uppercase">Last synced</dt><dd className="text-gray-200">- {cache?.syncedAt ? new Date(cache.syncedAt).toLocaleString() : 'Never'}+ {formatDateTime(cache?.syncedAt, 'Never')}</dd></div></dl>diff --git a/client/src/components/settings/IMessageTab.jsx b/client/src/components/settings/IMessageTab.jsxindex 84180b42fd..18a7125de5 100644--- a/client/src/components/settings/IMessageTab.jsx+++ b/client/src/components/settings/IMessageTab.jsx@@ -3,6 +3,7 @@ import { Link } from 'react-router';import { Save, Loader2, MessageSquare, ShieldCheck, ShieldAlert, RefreshCw, ExternalLink } from 'lucide-react';import toast from '../ui/Toast';import BrailleSpinner from '../BrailleSpinner';+import { formatDateTime } from '../../utils/formatters';import {getSettings,updateSettings,@@ -201,7 +202,7 @@ export function IMessageTab() {<div><dt className="text-gray-500 text-xs uppercase">Touchpoints</dt><dd className="text-gray-200">{lastResult?.touchpointsCreated ?? '—'}</dd></div><div><dt className="text-gray-500 text-xs uppercase">Scanned</dt><dd className="text-gray-200">{lastResult?.scanned ?? '—'}</dd></div><div><dt className="text-gray-500 text-xs uppercase">Decode skips</dt><dd className="text-gray-200">{lastResult?.decodeFailures ?? '—'}</dd></div>- <div><dt className="text-gray-500 text-xs uppercase">Last run</dt><dd className="text-gray-200">{status?.state?.lastRunAt ? new Date(status.state.lastRunAt).toLocaleString() : '—'}</dd></div>+ <div><dt className="text-gray-500 text-xs uppercase">Last run</dt><dd className="text-gray-200">{formatDateTime(status?.state?.lastRunAt, '—')}</dd></div></dl>{lastResult?.hasMore && (<p className="mt-3 text-xs text-port-warning">diff --git a/client/src/components/settings/LocalLlmTab.jsx b/client/src/components/settings/LocalLlmTab.jsxindex 4923e38167..a97662151c 100644--- a/client/src/components/settings/LocalLlmTab.jsx+++ b/client/src/components/settings/LocalLlmTab.jsx@@ -4,7 +4,7 @@ import { Cpu, Box, ArrowRightLeft, Download, Trash2, RefreshCw, Search, Plus, Eximport toast from '../ui/Toast';import ConfirmButtonPair from '../ui/ConfirmButtonPair';import BrailleSpinner from '../BrailleSpinner';-import { formatBytes, formatContextLength, timeAgo, recommendedRamGb } from '../../utils/formatters';+import { formatBytes, formatContextLength, timeAgo, recommendedRamGb, formatDateNumeric } from '../../utils/formatters';import { localLlmTargetKey } from '../../lib/localLlmTargetKey';import { useConfirmDelete } from '../../hooks/useConfirmDelete';import {@@ -913,7 +913,7 @@ export function LocalLlmTab() {{isHf && <span>{m.downloads?.toLocaleString?.() || 0} downloads</span>}{isHf && Number.isFinite(createdMs) && (<span- title={`Published ${new Date(createdMs).toLocaleDateString()}${Number.isFinite(updatedMs) ? ` · updated ${timeAgo(m.updatedAt)}` : ''}`}+ title={`Published ${formatDateNumeric(createdMs)}${Number.isFinite(updatedMs) ? ` · updated ${timeAgo(m.updatedAt)}` : ''}`}>published {timeAgo(m.createdAt)}</span>diff --git a/client/src/components/settings/SignalTab.jsx b/client/src/components/settings/SignalTab.jsxindex 2494892d20..3a556521b2 100644--- a/client/src/components/settings/SignalTab.jsx+++ b/client/src/components/settings/SignalTab.jsx@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';import { Save, Loader2, Lock, ShieldCheck, ShieldAlert, RefreshCw } from 'lucide-react';import toast from '../ui/Toast';import BrailleSpinner from '../BrailleSpinner';+import { formatDateTime } from '../../utils/formatters';import {getSettings,updateSettings,@@ -191,7 +192,7 @@ export function SignalTab() {<div><dt className="text-gray-500 text-xs uppercase">Touchpoints</dt><dd className="text-gray-200">{lastResult?.touchpointsCreated ?? '—'}</dd></div><div><dt className="text-gray-500 text-xs uppercase">Scanned</dt><dd className="text-gray-200">{lastResult?.scanned ?? '—'}</dd></div><div><dt className="text-gray-500 text-xs uppercase">Key source</dt><dd className="text-gray-200">{lastResult?.keySource ?? '—'}</dd></div>- <div><dt className="text-gray-500 text-xs uppercase">Last run</dt><dd className="text-gray-200">{status?.state?.lastRunAt ? new Date(status.state.lastRunAt).toLocaleString() : '—'}</dd></div>+ <div><dt className="text-gray-500 text-xs uppercase">Last run</dt><dd className="text-gray-200">{formatDateTime(status?.state?.lastRunAt, '—')}</dd></div></dl></div>)}diff --git a/client/src/components/settings/SpotifyTab.jsx b/client/src/components/settings/SpotifyTab.jsxindex 161cc77855..30b56dedbd 100644--- a/client/src/components/settings/SpotifyTab.jsx+++ b/client/src/components/settings/SpotifyTab.jsx@@ -3,6 +3,7 @@ import { useSearchParams } from 'react-router';import { Save, Loader2, Music, Link2, LogOut, RefreshCw, CheckCircle2, AlertCircle } from 'lucide-react';import toast from '../ui/Toast';import BrailleSpinner from '../BrailleSpinner';+import { formatDateTime } from '../../utils/formatters';import {getSettings,updateSettings,@@ -207,7 +208,7 @@ export function SpotifyTab() {) : (<span className="inline-flex items-center gap-1.5 text-gray-400"><AlertCircle size={14} /> Not connected</span>)}- {auth?.expiresAt && <span className="text-gray-500 text-xs">token expires {new Date(auth.expiresAt).toLocaleString()}</span>}+ {auth?.expiresAt && <span className="text-gray-500 text-xs">token expires {formatDateTime(auth.expiresAt)}</span>}</div><div className="flex flex-wrap gap-2"><button@@ -295,7 +296,7 @@ export function SpotifyTab() {<div><dt className="text-gray-500 text-xs uppercase">Listens recorded</dt><dd className="text-gray-200">{lastResult?.recorded ?? '—'}</dd></div><div><dt className="text-gray-500 text-xs uppercase">Scanned</dt><dd className="text-gray-200">{lastResult?.scanned ?? '—'}</dd></div><div><dt className="text-gray-500 text-xs uppercase">More remaining</dt><dd className="text-gray-200">{lastResult?.hasMore ? 'yes' : 'no'}</dd></div>- <div><dt className="text-gray-500 text-xs uppercase">Last run</dt><dd className="text-gray-200">{status?.state?.lastRunAt ? new Date(status.state.lastRunAt).toLocaleString() : '—'}</dd></div>+ <div><dt className="text-gray-500 text-xs uppercase">Last run</dt><dd className="text-gray-200">{formatDateTime(status?.state?.lastRunAt, '—')}</dd></div></dl></div>)}diff --git a/client/src/components/settings/YoutubeTab.jsx b/client/src/components/settings/YoutubeTab.jsxindex 3dde22a8ee..d42aed1c1a 100644--- a/client/src/components/settings/YoutubeTab.jsx+++ b/client/src/components/settings/YoutubeTab.jsx@@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';import { Save, Loader2, MonitorPlay, RefreshCw, CheckCircle2, AlertCircle, ShieldQuestion } from 'lucide-react';import toast from '../ui/Toast';import BrailleSpinner from '../BrailleSpinner';+import { formatDateTime } from '../../utils/formatters';import {getSettings,updateSettings,@@ -192,7 +193,7 @@ export function YoutubeTab() {<div><dt className="text-gray-500 text-xs uppercase">Watches recorded</dt><dd className="text-gray-200">{lastResult?.recorded ?? '—'}</dd></div><div><dt className="text-gray-500 text-xs uppercase">Entries scanned</dt><dd className="text-gray-200">{lastResult?.scanned ?? '—'}</dd></div><div><dt className="text-gray-500 text-xs uppercase">Status</dt><dd className="text-gray-200">{lastResult?.ok ? 'ok' : (lastResult?.error || lastResult?.status || 'error')}</dd></div>- <div><dt className="text-gray-500 text-xs uppercase">Last run</dt><dd className="text-gray-200">{status?.state?.lastRunAt ? new Date(status.state.lastRunAt).toLocaleString() : '—'}</dd></div>+ <div><dt className="text-gray-500 text-xs uppercase">Last run</dt><dd className="text-gray-200">{formatDateTime(status?.state?.lastRunAt, '—')}</dd></div></dl></div>)}diff --git a/client/src/components/sharing/OriginBadge.jsx b/client/src/components/sharing/OriginBadge.jsxindex 25c2f4060a..709bce04e1 100644--- a/client/src/components/sharing/OriginBadge.jsx+++ b/client/src/components/sharing/OriginBadge.jsx@@ -9,13 +9,14 @@*/import { Users } from 'lucide-react';+import { formatDateNumeric } from '../../utils/formatters';export default function OriginBadge({ origin, compact = false, className = '' }) {if (!origin || typeof origin !== 'object') return null;const { source, bucketName, sourceBio, importedAt } = origin;if (!source) return null;- const importedDate = importedAt ? new Date(importedAt).toLocaleDateString() : null;+ const importedDate = importedAt ? formatDateNumeric(importedAt) : null;const title = [`From ${source}`,bucketName ? `via ${bucketName}` : null,diff --git a/client/src/components/timeline/ActivityImportPanel.jsx b/client/src/components/timeline/ActivityImportPanel.jsxindex a558dbd3c7..413fe320fc 100644--- a/client/src/components/timeline/ActivityImportPanel.jsx+++ b/client/src/components/timeline/ActivityImportPanel.jsx@@ -2,6 +2,7 @@ import { useState, useRef, useEffect } from 'react';import { Upload, Loader2, CheckCircle2 } from 'lucide-react';import toast from '../ui/Toast';import FilePickerButton from '../ui/FilePickerButton';+import { formatDateNumeric } from '../../utils/formatters';// Shared bulk-backfill importer panel for the timeline (#2160). Two-step flow:// pick a file → preview (parse-only, no write) → confirm import. The import is@@ -178,7 +179,7 @@ export default function ActivityImportPanel({ icon: Icon, title, noun, help, imp// single date when from === to), or null when either bound is missing.export function dateRangeLabel(from, to) {if (!from || !to) return null;- const f = new Date(from).toLocaleDateString();- const t = new Date(to).toLocaleDateString();+ const f = formatDateNumeric(from);+ const t = formatDateNumeric(to);return f === t ? f : `${f} — ${t}`;}diff --git a/client/src/components/ui/ProcessLogLines.jsx b/client/src/components/ui/ProcessLogLines.jsxindex 5ee4176ad3..0e484668f5 100644--- a/client/src/components/ui/ProcessLogLines.jsx+++ b/client/src/components/ui/ProcessLogLines.jsx@@ -1,3 +1,5 @@+import { formatTimeOfDaySeconds } from '../../utils/formatters';+/*** Renders a PM2 process's log lines (the body of a log pane).*@@ -29,7 +31,7 @@ export default function ProcessLogLines({ logs, subscribed, showTimestamps = fal>{showTimestamps && (<span className={`text-gray-600 ${timestampGap}`}>- {new Date(log.timestamp).toLocaleTimeString()}+ {formatTimeOfDaySeconds(log.timestamp)}</span>)}{log.line}diff --git a/client/src/lib/clinicianReport.js b/client/src/lib/clinicianReport.jsindex 83022daa7e..e0c2dc952a 100644--- a/client/src/lib/clinicianReport.js+++ b/client/src/lib/clinicianReport.js@@ -8,6 +8,7 @@*/import { REFERENCE_RANGES, getBloodValueStatus } from '../components/meatspace/constants.js';+import { formatDateTime } from '../utils/formatters';// Blood-marker category grouping — canonical source for the marker→category map.// BloodTestCard imports getCategoryForKey from here so the on-screen tab grouping@@ -165,7 +166,7 @@ export function reportToMarkdown(report) {const lines = [];lines.push('# Clinician Summary — Blood & Lifestyle');lines.push('');- lines.push(`_Generated ${report.generatedAt.toLocaleString()}_`);+ lines.push(`_Generated ${formatDateTime(report.generatedAt)}_`);lines.push('');lines.push('> Self-tracked data exported from PortOS MeatSpace. Reference ranges are general adult ranges and not a diagnosis.');lines.push('');diff --git a/client/src/pages/DataManager.jsx b/client/src/pages/DataManager.jsxindex 97fdaa0be3..253f5b92d4 100644--- a/client/src/pages/DataManager.jsx+++ b/client/src/pages/DataManager.jsx@@ -1,7 +1,7 @@import { useState, useEffect, useCallback, useRef } from 'react';import { HardDrive, RefreshCw, Archive, Trash2, ChevronDown, ChevronRight, FolderOpen, File, Package } from 'lucide-react';import * as api from '../services/api';-import { formatBytes } from '../utils/formatters';+import { formatBytes, formatDateNumeric } from '../utils/formatters';import BrailleSpinner from '../components/BrailleSpinner';import PageSkeleton from '../components/ui/PageSkeleton';import toast from '../components/ui/Toast';@@ -324,7 +324,7 @@ function BackupsSection({ backups, loading, onDelete }) {<span className="truncate">{b.name}</span></td><td className="p-2 text-right text-gray-400 font-mono">{formatBytes(b.size)}</td>- <td className="p-2 text-right text-gray-500">{b.created ? new Date(b.created).toLocaleDateString() : '—'}</td>+ <td className="p-2 text-right text-gray-500">{formatDateNumeric(b.created, '—')}</td><td className="p-2 pr-3 text-right">{isConfirming(b.name) ? (<ConfirmButtonPairdiff --git a/client/src/pages/Timeline.jsx b/client/src/pages/Timeline.jsxindex cf098a58c8..8e8402e41d 100644--- a/client/src/pages/Timeline.jsx+++ b/client/src/pages/Timeline.jsx@@ -9,7 +9,7 @@ import PageHeader from '../components/PageHeader';import TimelineImportPanels, { IMPORT_SOURCE_COUNT } from '../components/timeline/TimelineImportPanels';import * as api from '../services/api';import toast from '../components/ui/Toast';-import { formatClockTime, formatDurationSec } from '../utils/formatters';+import { formatClockTime, formatDurationSec, formatWeekdayDate } from '../utils/formatters';// Local (browser-tz) YYYY-MM-DD for a Date — matches the server's local-day math// closely enough for defaulting the URL; the server is the source of truth for@@ -183,7 +183,7 @@ export default function Timeline() {const dayLabel = useMemo(() => {const [y, m, d] = date.split('-').map(Number);- return new Date(y, m - 1, d).toLocaleDateString([], { weekday: 'long', month: 'short', day: 'numeric', year: 'numeric' });+ return formatWeekdayDate(new Date(y, m - 1, d), { year: true });}, [date]);return (diff --git a/client/src/pages/X.jsx b/client/src/pages/X.jsxindex 1dc7629c42..b67e508a1a 100644--- a/client/src/pages/X.jsx+++ b/client/src/pages/X.jsx@@ -7,6 +7,7 @@ import PageHeader from '../components/PageHeader';import PageSkeleton from '../components/ui/PageSkeleton';import TabPills from '../components/ui/TabPills';import { useValidTab } from '../hooks/useValidTab';+import { formatDateTime } from '../utils/formatters';const TABS = [{ id: 'health', label: 'Reach & health', icon: BarChart3 },@@ -21,7 +22,7 @@ const secondaryButton = 'rounded border border-port-border px-3 py-2 text-sm texconst sameAccount = (left, right) => JSON.stringify(left) === JSON.stringify(right);const formatCount = (value) => Number.isInteger(value) ? value.toLocaleString() : '—';-const formatDate = (value) => typeof value === 'string' && Number.isFinite(Date.parse(value)) ? new Date(value).toLocaleString() : '—';+const formatDate = (value) => formatDateTime(value, '—');const stateLabel = (state) => ({ draft: 'Draft', pending_review: 'Awaiting review', approved: 'Approved', rejected: 'Rejected', opened: 'Opened in X' }[state] || state);const normalizeHandle = (value) => String(value || '').trim().replace(/^@/, '');diff --git a/client/src/utils/README.md b/client/src/utils/README.mdindex 0975e3575f..5a1f3876d4 100644--- a/client/src/utils/README.md+++ b/client/src/utils/README.md@@ -22,7 +22,7 @@ grep -i "what you want to do" client/src/utils/README.md| Module | Purpose ||---|---|-| `formatters` | Date/time/duration/byte/word formatters (`formatBytes`, `formatCompactCount`, `timeAgo`, `formatTimecode`, `formatDurationMs`, `formatDateShort`, `parseTimeoutMs`, `formatCooldown`, `parseSizeGb`, `recommendedRamGb`, `nameFromImageFilename`, `formatUsd` — one USD renderer (`signed` puts the minus outside the `$`; `trimWhole` drops `.00` on a typed round price) — `formatWeight` / `formatPercent` — round unit-converted floats (`170.35000000000002` → `170.4 lbs`) so raw binary precision never reaches a tile — `middleTruncate` — clip a long string from the MIDDLE so its distinguishing tail survives, where CSS `line-clamp`/`text-overflow` always eats the end — …) plus timeout-input bounds and `getAppName`. Do not re-define formatters inside components. |+| `formatters` | Date/time/duration/byte/word formatters (`formatBytes`, `formatCompactCount`, `timeAgo`, `formatTimecode`, `formatDurationMs`, `formatDateShort`, `parseTimeoutMs`, `formatCooldown`, `parseSizeGb`, `recommendedRamGb`, `nameFromImageFilename`, `formatUsd` — one USD renderer (`signed` puts the minus outside the `$`; `trimWhole` drops `.00` on a typed round price) — `formatWeight` / `formatPercent` — round unit-converted floats (`170.35000000000002` → `170.4 lbs`) so raw binary precision never reaches a tile — `middleTruncate` — clip a long string from the MIDDLE so its distinguishing tail survives, where CSS `line-clamp`/`text-overflow` always eats the end — …) plus timeout-input bounds and `getAppName`. Do not re-define formatters inside components. **Never write `new Date(x).toLocaleDateString()` inline** — pick the helper for the shape you want: `formatDateNumeric` ("3/5/2026", compact cells), `formatDateShort` ("Mar 5, 2026"), `formatDate` ("March 5, 2026"), `formatDateFull` ("Saturday, March 5, 2026"), `formatWeekdayDate` ("Monday, Mar 5", `{ weekday, year }`), `formatMonthDay` ("Mar 5"), `formatMonthYear` ("March 2026"), `formatWeekdayShort` ("Mon"), `formatWeekdayTime` ("Mon, 7:00 AM"), `formatDateWeekday` (noon-anchored heatmap tooltips), `formatTimeOfDay` ("1:30 PM"), `formatTimeOfDaySeconds` ("1:30:45 PM", log/queue rows), `formatClockTime` ("02:30:45 PM"; `{ seconds, hour12, timeZone }`), `formatDateTime`. All of them anchor a bare `YYYY-MM-DD` at LOCAL midnight (a naive `new Date('2026-03-05')` is UTC midnight and renders as the previous day west of Greenwich) and take a fallback instead of rendering the literal "Invalid Date". || `cronHelpers` | Cron preset list, `isCronExpression` detection, and `describeCron` human-readable rendering. || `markdownText` | `markdownToPlainText(md)` — flatten markdown source to one plain-text string for a clamped preview: strips heading/list/blockquote/fence markers, unwraps emphasis, inline code and links, images → `[alt]`, collapses blank-line runs. Use whenever a card previews arbitrary agent-authored markdown — `line-clamp-N` does not clamp a subtree of block elements, and foreign `##` headings would otherwise join the page's heading outline. Underscore emphasis is word-boundary gated and `__…__` needs interior whitespace, so stack frames and user-agent strings (`10_15_7`, `__init__`) are never silently rewritten. `dropsMarkupWhenFlattened(md)` — did the flatten lose actual markup, as opposed to only normalizing whitespace? Gates a "Show more" disclosure so a short-but-lossy body stays reachable without putting a toggle on every body that merely lost a trailing newline. || `timeWindow` | Time-of-day window math (`isInTimeWindow`, `timeStringToMinutes`) and morning-layout auto-switch helpers (`pickActiveLayoutId`, `recordManualLayoutPick`). |diff --git a/client/src/utils/formatters.js b/client/src/utils/formatters.jsindex 313e413fec..9381c0b4b4 100644--- a/client/src/utils/formatters.js+++ b/client/src/utils/formatters.js@@ -18,17 +18,68 @@ export function formatTime(timestamp) {if (diff < 60000) return 'Just now';if (diff < 3600000) return `${Math.floor(diff / 60000)}m ago`;if (diff < 86400000) return `${Math.floor(diff / 3600000)}h ago`;- return date.toLocaleDateString();+ return formatDateNumeric(date);+}++const DATE_ONLY_RE = /^\d{4}-\d{2}-\d{2}$/;++/**+ * Coerce a Date / ISO timestamp / epoch ms into a Date for display.+ *+ * A bare calendar date ("2026-03-05") is parsed by `new Date(...)` as UTC+ * midnight, which renders as the PREVIOUS day everywhere west of Greenwich.+ * Anchor it at LOCAL midnight instead — exactly what the call sites used to+ * do by hand with `new Date(value + 'T00:00:00')`.+ * @param {string|number|Date|null|undefined} value+ * @returns {Date} A Date (possibly Invalid — callers validate)+ */+function toDisplayDate(value) {+ if (value instanceof Date) return value;+ if (typeof value === 'string' && DATE_ONLY_RE.test(value)) return new Date(`${value}T00:00:00`);+ return new Date(value);+}++/**+ * Render `value` through `toLocaleDateString`/`toLocaleTimeString` with the+ * given options, returning `fallback` for missing or unparseable input so a+ * blank record never renders the literal string "Invalid Date".+ * @param {'date'|'time'} kind+ * @param {string|number|Date|null|undefined} value+ * @param {Intl.DateTimeFormatOptions|undefined} options+ * @param {string} fallback+ * @returns {string}+ */+function localized(kind, value, options, fallback) {+ if (value == null || value === '') return fallback;+ const date = toDisplayDate(value);+ if (Number.isNaN(date.getTime())) return fallback;+ return kind === 'date'+ ? date.toLocaleDateString([], options)+ : date.toLocaleTimeString([], options);}/*** Format a timestamp as a localized time-of-day string (e.g., "1:30 PM")* @param {string|Date} dateStr - ISO timestamp or Date object- * @returns {string} Formatted time of day+ * @param {object} [options]+ * @param {string} [options.timeZone] - Render in a specific IANA timezone+ * @returns {string} Formatted time of day, or '' for missing/invalid input+ */+export function formatTimeOfDay(dateStr, { timeZone } = {}) {+ return localized('time', dateStr, { hour: 'numeric', minute: '2-digit', ...(timeZone ? { timeZone } : {}) }, '');+}++/**+ * Format a timestamp as a localized time-of-day string WITH seconds+ * (e.g., "1:30:45 PM") — the shape log/queue rows want, where the second+ * matters for ordering. Pair with `formatTimeOfDay` when seconds are noise+ * and `formatClockTime` when the zero-padded 24h-capable clock shape is wanted.+ * @param {string|number|Date|null} value - ISO timestamp, epoch ms, or Date+ * @param {string} [fallback=''] - Rendered for missing/invalid input+ * @returns {string} Formatted time of day with seconds*/-export function formatTimeOfDay(dateStr) {- if (!dateStr) return '';- return new Date(dateStr).toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });+export function formatTimeOfDaySeconds(value, fallback = '') {+ return localized('time', value, undefined, fallback);}/**@@ -38,27 +89,113 @@ export function formatTimeOfDay(dateStr) {*/export function formatDate(dateStr) {if (!dateStr) return null;- return new Date(dateStr).toLocaleDateString(undefined, { month: 'long', day: 'numeric', year: 'numeric' });+ return localized('date', dateStr, { month: 'long', day: 'numeric', year: 'numeric' }, null);+}++/**+ * Format a date in the browser's short numeric locale form (e.g., "3/5/2026").+ * This is the canonical home for what used to be a bare+ * `new Date(x).toLocaleDateString()` scattered across components — compact+ * list/table cells where a spelled-out month would not fit.+ * @param {string|number|Date|null} value - ISO timestamp, `YYYY-MM-DD`, epoch ms, or Date+ * @param {string} [fallback=''] - Rendered for missing/invalid input+ * @returns {string} Formatted numeric date+ */+export function formatDateNumeric(value, fallback = '') {+ return localized('date', value, undefined, fallback);+}++/**+ * Format a date as month + day only (e.g., "Mar 5"). For dense HUD/badge+ * chrome and week ranges where the year is implied by context.+ * @param {string|number|Date|null} value+ * @param {string} [fallback=''] - Rendered for missing/invalid input+ * @returns {string}+ */+export function formatMonthDay(value, fallback = '') {+ return localized('date', value, { month: 'short', day: 'numeric' }, fallback);+}++/**+ * Format a date as month + year (e.g., "March 2026") — calendar month headers.+ * @param {string|number|Date|null} value+ * @param {string} [fallback=''] - Rendered for missing/invalid input+ * @returns {string}+ */+export function formatMonthYear(value, fallback = '') {+ return localized('date', value, { month: 'long', year: 'numeric' }, fallback);+}++/**+ * Format an abbreviated weekday plus time-of-day (e.g., "Mon, 7:00 AM") — a+ * week-scale schedule timeline, where the day matters but the date does not.+ * @param {string|number|Date|null} value+ * @param {object} [options]+ * @param {string} [options.timeZone] - Render in a specific IANA timezone+ * @returns {string} Formatted weekday + time, or '' for missing/invalid input+ */+export function formatWeekdayTime(value, { timeZone } = {}) {+ if (value == null || value === '') return '';+ const date = toDisplayDate(value);+ if (Number.isNaN(date.getTime())) return '';+ return date.toLocaleString([], { weekday: 'short', hour: 'numeric', minute: '2-digit', ...(timeZone ? { timeZone } : {}) });+}++/**+ * Format a date as an abbreviated weekday only (e.g., "Mon") — calendar+ * column headers and timeline axis ticks.+ * @param {string|number|Date|null} value+ * @param {object} [options]+ * @param {string} [options.timeZone] - Render the weekday in a specific IANA timezone+ * @returns {string} Abbreviated weekday, or '' for missing/invalid input+ */+export function formatWeekdayShort(value, { timeZone } = {}) {+ return localized('date', value, { weekday: 'short', ...(timeZone ? { timeZone } : {}) }, '');+}++/**+ * Format a weekday-led date with a short month (e.g., "Monday, Mar 5", or+ * "Mon, Mar 5, 2026" with `{ weekday: 'short', year: true }`). Distinct from+ * `formatDateFull` (long month, always with year) and `formatDateWeekday`+ * (noon-anchored heatmap tooltips).+ * @param {string|number|Date|null} value+ * @param {object} [options]+ * @param {'long'|'short'} [options.weekday='long'] - Weekday width+ * @param {boolean} [options.year=false] - Append the year+ * @param {string} [options.fallback=''] - Rendered for missing/invalid input+ * @returns {string}+ */+export function formatWeekdayDate(value, { weekday = 'long', year = false, fallback = '' } = {}) {+ return localized('date', value, { weekday, month: 'short', day: 'numeric', ...(year ? { year: 'numeric' } : {}) }, fallback);}/*** Format a date with full detail including weekday (e.g., "Saturday, March 5, 2026")- * @param {Date} date - Date object- * @returns {string} Formatted date string+ * @param {string|number|Date|null} value - Date object, ISO timestamp, or `YYYY-MM-DD`+ * @returns {string} Formatted date string, or '' for missing/invalid input*/-export function formatDateFull(date) {- return date.toLocaleDateString([], { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' });+export function formatDateFull(value) {+ return localized('date', value, { weekday: 'long', month: 'long', day: 'numeric', year: 'numeric' }, '');}/*** Format a Date as a clock time string with seconds (e.g., "02:30:45 PM")- * @param {Date} date - Date object- * @param {object} [options] - { timeZone } — render in a specific IANA timezone+ * @param {string|number|Date|null} date - Date object, ISO timestamp, or epoch ms+ * @param {object} [options]+ * @param {string} [options.timeZone] - Render in a specific IANA timezone* (e.g. the server's configured user timezone) instead of the browser's- * @returns {string} Formatted clock time+ * @param {boolean} [options.seconds=true] - Include seconds ("02:30:45 PM" vs "02:30 PM")+ * @param {boolean} [options.hour12] - Force 12h/24h; omit to follow the locale+ * @returns {string} Formatted clock time, or '' for missing/invalid input*/-export function formatClockTime(date, { timeZone } = {}) {- return date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', second: '2-digit', ...(timeZone ? { timeZone } : {}) });+export function formatClockTime(date, { timeZone, seconds = true, hour12 } = {}) {+ return localized('time', date, {+ hour: '2-digit',+ minute: '2-digit',+ ...(seconds ? { second: '2-digit' } : {}),+ ...(timeZone ? { timeZone } : {}),+ ...(hour12 === undefined ? {} : { hour12 }),+ }, '');}/**@@ -272,10 +409,10 @@ export function formatCountdown(seconds) {*/const _dateTimeFormatter = new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' });-export function formatDateTime(value) {- if (!value) return 'Unknown time';- const date = new Date(value);- if (Number.isNaN(date.getTime())) return 'Unknown time';+export function formatDateTime(value, fallback = 'Unknown time') {+ if (value == null || value === '') return fallback;+ const date = toDisplayDate(value);+ if (Number.isNaN(date.getTime())) return fallback;return _dateTimeFormatter.format(date);}@@ -309,10 +446,7 @@ export function formatTimecode(seconds) {* fallback) depending on the surrounding UI.*/export function formatDateShort(value) {- if (!value) return '—';- const date = new Date(value);- if (Number.isNaN(date.getTime())) return '—';- return date.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });+ return localized('date', value, { year: 'numeric', month: 'short', day: 'numeric' }, '—');}// Per-call LLM timeout bounds. Client-side mirror of the canonicaldiff --git a/client/src/utils/formatters.test.js b/client/src/utils/formatters.test.jsindex f400ffd80b..e61d513109 100644--- a/client/src/utils/formatters.test.js+++ b/client/src/utils/formatters.test.js@@ -3,6 +3,8 @@ import {formatContextLength, formatDurationMin, formatDurationMs, formatEventDateTime, timeAgo,formatCooldown, parseSizeGb, recommendedRamGb, parseTimeoutMs, formatDurationSec, middleTruncate,formatWeight, formatPercent, formatUsd, formatBytes,+ formatDateNumeric, formatTimeOfDaySeconds, formatClockTime, formatWeekdayDate,+ formatMonthDay, formatMonthYear, formatWeekdayShort, formatWeekdayTime, formatDateFull, formatDateShort, formatDateTime,} from './formatters.js';describe('formatBytes', () => {@@ -390,3 +392,137 @@ describe('middleTruncate', () => {expect(middleTruncate('keep me', undefined)).toBe('keep me');});});++describe('canonical date/time formatters (#3870)', () => {+ // The helpers below replaced ~60 inline `new Date(x).toLocaleDateString()`+ // calls across components. These assert the two contracts that inline call+ // sites got wrong or hand-rolled: local-midnight anchoring of a bare+ // calendar date, and a caller-chosen fallback instead of "Invalid Date".++ describe('formatDateNumeric', () => {+ it('anchors a bare YYYY-MM-DD at LOCAL midnight, not UTC', () => {+ // `new Date('2026-03-05')` is UTC midnight, which renders as Mar 4 in any+ // negative-offset zone — the reason call sites appended 'T00:00:00' by hand.+ expect(formatDateNumeric('2026-03-05')).toBe(new Date(2026, 2, 5).toLocaleDateString());+ });++ it('renders a full ISO timestamp and a Date the same way', () => {+ const d = new Date(2026, 2, 5, 13, 30);+ expect(formatDateNumeric(d)).toBe(formatDateNumeric(d.toISOString()));+ });++ it('returns the fallback for missing/blank/unparseable input', () => {+ expect(formatDateNumeric(null)).toBe('');+ expect(formatDateNumeric(undefined)).toBe('');+ expect(formatDateNumeric('')).toBe('');+ expect(formatDateNumeric('not-a-date', '—')).toBe('—');+ expect(formatDateNumeric(null, '—')).toBe('—');+ });+ });++ describe('formatTimeOfDaySeconds', () => {+ it('includes seconds and honors the fallback', () => {+ expect(formatTimeOfDaySeconds(new Date(2026, 2, 5, 14, 30, 45))).toMatch(/\b30\D+45\b/);+ expect(formatTimeOfDaySeconds(null)).toBe('');+ expect(formatTimeOfDaySeconds('garbage', '—')).toBe('—');+ });+ });++ describe('formatClockTime', () => {+ const at = new Date(2026, 2, 5, 14, 30, 45);++ it('includes seconds by default and drops them with seconds:false', () => {+ expect(formatClockTime(at)).toMatch(/\d{2}:\d{2}:\d{2}/);+ expect(formatClockTime(at, { seconds: false })).not.toMatch(/\d{2}:\d{2}:\d{2}/);+ });++ it('forces a 24-hour clock with hour12:false', () => {+ expect(formatClockTime(at, { hour12: false })).toContain('14:30:45');+ });++ it('accepts an ISO string, not just a Date, and falls back on missing input', () => {+ expect(formatClockTime(at.toISOString())).toBe(formatClockTime(at));+ expect(formatClockTime(null)).toBe('');+ });+ });++ describe('formatWeekdayDate', () => {+ const day = new Date(2026, 2, 5);++ it('appends the year only when asked', () => {+ expect(formatWeekdayDate(day, { year: true })).toContain('2026');+ expect(formatWeekdayDate(day)).not.toContain('2026');+ });++ it('shortens the weekday on request', () => {+ const long = formatWeekdayDate(day);+ const short = formatWeekdayDate(day, { weekday: 'short' });+ expect(short.length).toBeLessThan(long.length);+ });++ it('anchors a bare calendar date locally', () => {+ expect(formatWeekdayDate('2026-03-05')).toBe(formatWeekdayDate(day));+ });+ });++ describe('formatMonthDay / formatMonthYear / formatWeekdayShort', () => {+ const day = new Date(2026, 2, 5);++ it('renders the day without a year, and the month without a day', () => {+ expect(formatMonthDay(day)).toContain('5');+ expect(formatMonthDay(day)).not.toContain('2026');+ expect(formatMonthYear(day)).toContain('2026');+ expect(formatMonthYear(day)).not.toContain('5');+ });++ it('renders an abbreviated weekday', () => {+ expect(formatWeekdayShort(day)).toMatch(/^[A-Za-z.]{2,5}$/);+ });++ it('formatWeekdayTime pairs the weekday with a time and drops the date', () => {+ const out = formatWeekdayTime(new Date(2026, 2, 5, 7, 0));+ expect(out).toMatch(/^[A-Za-z.]{2,5}\b/);+ expect(out).toContain('7');+ expect(out).not.toContain('2026');+ expect(formatWeekdayTime(null)).toBe('');+ expect(formatWeekdayTime('nope')).toBe('');+ });++ it('falls back rather than rendering "Invalid Date"', () => {+ expect(formatMonthDay('nope', '—')).toBe('—');+ expect(formatMonthYear(null)).toBe('');+ expect(formatWeekdayShort(null)).toBe('');+ });+ });++ describe('formatDateFull / formatDateShort', () => {+ it('formatDateFull accepts a bare calendar date string', () => {+ expect(formatDateFull('2026-03-05')).toBe(formatDateFull(new Date(2026, 2, 5)));+ expect(formatDateFull('2026-03-05')).toContain('2026');+ });++ it('formatDateFull returns "" instead of throwing on bad input', () => {+ expect(formatDateFull(null)).toBe('');+ expect(formatDateFull('nope')).toBe('');+ });++ it('formatDateShort keeps its em-dash fallback and anchors bare dates locally', () => {+ expect(formatDateShort(null)).toBe('—');+ expect(formatDateShort('nope')).toBe('—');+ expect(formatDateShort('2026-03-05')).toBe(formatDateShort(new Date(2026, 2, 5)));+ });+ });++ describe('formatDateTime', () => {+ it('takes a caller-supplied fallback for missing/invalid input', () => {+ expect(formatDateTime(null)).toBe('Unknown time');+ expect(formatDateTime(null, '—')).toBe('—');+ expect(formatDateTime('', 'Never')).toBe('Never');+ expect(formatDateTime('not-a-date', '—')).toBe('—');+ });++ it('anchors a bare calendar date locally', () => {+ expect(formatDateTime('2026-03-05')).toBe(formatDateTime(new Date(2026, 2, 5)));+ });+ });+});