fix(web-ui): display all human-facing timestamps in Asia/Jerusalem (deterministic)
Storage stays UTC (DB TIMESTAMPTZ, API ISO-UTC) — only the display layer is localized, and now deterministically: every timestamp renders pinned to Asia/Jerusalem via a single Intl-based formatter, so SSR (UTC container) and the browser agree on any runtime. No layout/visible-format change — only the tz. - New single date formatter web-ui/src/lib/format-date.ts (G2): formatDate / formatDateShort / formatDateLong / formatDateTime / formatDateTimeFull / formatTime / formatIsoDate + Israel helpers getIsraelYear / israelDayKey / israelMidnightMs / israelParts + formatRelative (long/short/tight wording). - Routed all ad-hoc toLocaleDateString/toLocaleTimeString/toLocaleString + hand-rolled new Date(...).get*() / toISOString().slice(0,10) timestamp call sites (30 files) through it. Number toLocaleString left untouched. - Spec: added INV-UI9 to docs/spec/X6 (UTC storage, Asia/Jerusalem display). Display-only; no layout/design/IA change → Claude Design gate N/A. Invariants: G2 (single date formatter, no parallel ad-hoc formatting), INV-UI9. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -24,32 +24,16 @@ import {
|
||||
import { StatusBadge } from "@/components/cases/status-badge";
|
||||
import { isBlamSubtype } from "@/lib/practice-area";
|
||||
import type { Case } from "@/lib/api/cases";
|
||||
import { formatDate, israelMidnightMs, todayIsraelMidnightMs } from "@/lib/format-date";
|
||||
|
||||
function formatDate(iso?: string) {
|
||||
if (!iso) return "—";
|
||||
try {
|
||||
return new Date(iso).toLocaleDateString("he-IL", {
|
||||
day: "2-digit",
|
||||
month: "2-digit",
|
||||
year: "numeric",
|
||||
});
|
||||
} catch {
|
||||
return iso;
|
||||
}
|
||||
}
|
||||
|
||||
/** Midnight today, in ms — the pivot between an upcoming and a past hearing. */
|
||||
/** Midnight today in Israel time, in ms — pivot between an upcoming and a past hearing. */
|
||||
function startOfToday() {
|
||||
const d = new Date();
|
||||
d.setHours(0, 0, 0, 0);
|
||||
return d.getTime();
|
||||
return todayIsraelMidnightMs();
|
||||
}
|
||||
|
||||
/** Day-precision ms for a hearing date, or null when absent/unparseable. */
|
||||
/** Day-precision ms (Israel time) for a hearing date, or null when absent/unparseable. */
|
||||
function hearingMs(iso?: string | null): number | null {
|
||||
if (!iso) return null;
|
||||
const t = new Date(iso).setHours(0, 0, 0, 0);
|
||||
return Number.isNaN(t) ? null : t;
|
||||
return israelMidnightMs(iso);
|
||||
}
|
||||
|
||||
type HearingClass = "soon" | "upcoming" | "past" | "none";
|
||||
|
||||
Reference in New Issue
Block a user