fix(web-ui): display all human-facing timestamps in Asia/Jerusalem (deterministic)
All checks were successful
G12 Leak-Guard / leak-guard (pull_request) Successful in 3s
Lint — undefined names / undefined-names (pull_request) Successful in 10s

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:
2026-06-30 17:18:09 +00:00
parent c71bbc0df2
commit 67c2c43777
32 changed files with 384 additions and 235 deletions

View File

@@ -17,6 +17,7 @@ import type {
InteractionTask,
PaperclipComment,
} from "@/lib/api/agents";
import { formatRelative } from "@/lib/format-date";
import { toast } from "sonner";
import {
Bot,
@@ -83,15 +84,7 @@ function issueStatusLabel(status: string) {
/* ── Time formatting ─────────────────────────────────────────── */
function timeAgo(iso: string | null): string {
if (!iso) return "";
const diff = Date.now() - new Date(iso).getTime();
const mins = Math.floor(diff / 60_000);
if (mins < 1) return "עכשיו";
if (mins < 60) return `לפני ${mins} דק׳`;
const hours = Math.floor(mins / 60);
if (hours < 24) return `לפני ${hours} שע׳`;
const days = Math.floor(hours / 24);
return `לפני ${days} ימים`;
return formatRelative(iso, { units: "short", fallback: "" });
}
/* ── Issue identifier → find matching identifier ─────────────── */

View File

@@ -4,6 +4,7 @@ import Link from "next/link";
import { Loader2, CheckCircle2, Clock } from "lucide-react";
import { useAgentActivity } from "@/lib/api/agents";
import type { PaperclipIssue } from "@/lib/api/agents";
import { formatRelative } from "@/lib/format-date";
const STATUS_DOT: Record<string, string> = {
in_progress: "bg-gold",
@@ -22,13 +23,7 @@ const STATUS_LABEL: Record<string, string> = {
};
function timeAgo(iso: string | null): string {
if (!iso) return "—";
const diffMs = Date.now() - new Date(iso).getTime();
const m = Math.floor(diffMs / 60_000);
if (m < 60) return `לפני ${m}ד'`;
const h = Math.floor(m / 60);
if (h < 24) return `לפני ${h}ש'`;
return `לפני ${Math.floor(h / 24)} ימים`;
return formatRelative(iso, { units: "tight", fallback: "—" });
}
function IssueRow({ issue }: { issue: PaperclipIssue }) {

View File

@@ -10,21 +10,9 @@ import {
APPEAL_SUBTYPE_LABELS,
isBlamSubtype,
} from "@/lib/practice-area";
import { formatDate } from "@/lib/format-date";
import type { CaseDetail } from "@/lib/api/cases";
function formatDate(iso?: string | null) {
if (!iso) return "—";
try {
return new Date(iso).toLocaleDateString("he-IL", {
day: "2-digit",
month: "2-digit",
year: "numeric",
});
} catch {
return iso ?? "—";
}
}
function partiesLine(data?: CaseDetail): string | null {
const appellant = data?.appellants?.filter(Boolean) ?? [];
const respondent = data?.respondents?.filter(Boolean) ?? [];

View File

@@ -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";

View File

@@ -17,6 +17,7 @@ import {
type BlockStatus,
} from "@/lib/api/decision-blocks";
import { BLOCK_LABELS } from "@/lib/api/feedback";
import { formatTime } from "@/lib/format-date";
import { AlertTriangle, Pencil, FileText } from "lucide-react";
/* ── status badge styling ─────────────────────────────── */
@@ -233,10 +234,7 @@ function SaveIndicator({ state }: { state: SaveState }) {
return <span className="text-[0.72rem] text-ink-muted"> שומר</span>;
}
if (state.kind === "saved") {
const time = state.at.toLocaleTimeString("he-IL", {
hour: "2-digit",
minute: "2-digit",
});
const time = formatTime(state.at);
return <span className="text-[0.72rem] text-success"> נשמר {time}</span>;
}
return <span className="text-[0.72rem] text-danger"> {state.message}</span>;

View File

@@ -24,6 +24,7 @@ import { apiRequest } from "@/lib/api/client";
import { casesKeys } from "@/lib/api/cases";
import type { CaseDetail, CaseDocument } from "@/lib/api/cases";
import { DocumentTypeEditor } from "@/components/cases/document-type-editor";
import { formatDateShort as formatDate } from "@/lib/format-date";
/*
* Document list for the case detail "מסמכים" tab. Uses the real document
@@ -76,15 +77,6 @@ function StatusIcon({ status }: { status: string }) {
}
}
function formatDate(iso: string) {
if (!iso) return "—";
try {
return new Date(iso).toLocaleDateString("he-IL");
} catch {
return iso;
}
}
function filenameFromPath(path: string): string {
const parts = path.split("/");
return parts[parts.length - 1] || path;

View File

@@ -38,6 +38,7 @@ import {
import { useCaseCitations } from "@/lib/api/citations";
import { learningKeys } from "@/lib/api/learning";
import { LearningStatusBadges } from "@/components/cases/learning-status-badges";
import { formatDateTime, formatDateShort } from "@/lib/format-date";
import type { CaseStatus } from "@/lib/api/cases";
import { toast } from "sonner";
import {
@@ -72,13 +73,7 @@ function formatSize(bytes: number): string {
}
function formatDate(epoch: number): string {
return new Date(epoch * 1000).toLocaleDateString("he-IL", {
day: "numeric",
month: "short",
year: "numeric",
hour: "2-digit",
minute: "2-digit",
});
return formatDateTime(epoch * 1000);
}
/* ── Main component ─────────────────────────────────── */
@@ -568,9 +563,7 @@ export function DraftsPanel({
</Badge>
)}
<span className="text-[0.65rem] text-ink-muted me-auto">
{fb.created_at
? new Date(fb.created_at).toLocaleDateString("he-IL")
: ""}
{fb.created_at ? formatDateShort(fb.created_at) : ""}
</span>
</div>
<p className="text-sm leading-relaxed">{fb.feedback_text}</p>

View File

@@ -6,6 +6,7 @@ import { StatusChanger } from "@/components/cases/status-changer";
import { StatusGuide } from "@/components/cases/status-guide";
import { AgentStatusWidget } from "@/components/cases/agent-status-widget";
import { expectedOutcomes } from "@/lib/schemas/case";
import { formatDate } from "@/lib/format-date";
import type { CaseDetail } from "@/lib/api/cases";
/*
@@ -21,19 +22,6 @@ const EXPECTED_OUTCOME_LABELS: Record<string, string> = Object.fromEntries(
expectedOutcomes.map((o) => [o.value, o.label]),
);
function formatDate(iso?: string | null): string {
if (!iso) return "—";
try {
return new Date(iso).toLocaleDateString("he-IL", {
day: "2-digit",
month: "2-digit",
year: "numeric",
});
} catch {
return iso ?? "—";
}
}
function phaseIndexOf(status?: CaseStatus): number {
if (!status) return -1;
return PHASES.findIndex((p) => p.statuses.includes(status));

View File

@@ -2,17 +2,7 @@
import { useGitStatus } from "@/lib/api/cases";
import { CheckCircle2, AlertCircle, Clock, CloudOff } from "lucide-react";
function formatRelative(iso: string): string {
const diff = Date.now() - new Date(iso).getTime();
const mins = Math.floor(diff / 60_000);
if (mins < 1) return "עכשיו";
if (mins < 60) return `לפני ${mins} דק׳`;
const hours = Math.floor(mins / 60);
if (hours < 24) return `לפני ${hours} שע׳`;
const days = Math.floor(hours / 24);
return `לפני ${days} ימים`;
}
import { formatRelative } from "@/lib/format-date";
export function SyncIndicator({ caseNumber }: { caseNumber?: string }) {
const { data, isLoading } = useGitStatus(caseNumber);