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);

View File

@@ -2,6 +2,7 @@
import { useEffect, useRef, useState } from "react";
import { useSaveChairPosition } from "@/lib/api/research";
import { formatTime } from "@/lib/format-date";
/*
* Chair-position editor for a single threshold claim or issue.
@@ -87,10 +88,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

@@ -5,15 +5,7 @@ import type { ReactNode } from "react";
import { Badge } from "@/components/ui/badge";
import { practiceAreaLabel } from "@/components/precedents/practice-area";
import type { Digest } from "@/lib/api/digests";
function formatDate(iso: string | null) {
if (!iso) return "—";
try {
return new Date(iso).toLocaleDateString("he-IL");
} catch {
return iso;
}
}
import { formatDateShort as formatDate } from "@/lib/format-date";
/**
* Presentational card for a single digest ("כל יום" radar entry).

View File

@@ -26,6 +26,7 @@ import {
} from "@/components/ui/select";
import type { GraphFacets } from "@/lib/api/graph";
import type { ColorBy, SizeBy } from "@/components/graph/graph-canvas";
import { getIsraelYear } from "@/lib/format-date";
export type GraphControls = {
practiceArea: string;
@@ -51,7 +52,7 @@ const ALL = "__all__";
// Floor covers the oldest dated precedent in the corpus (currently ע"א 725/81 →
// 1982); ceiling tracks the current year so the range never ages out.
const YEAR_FLOOR = 1980;
const CURRENT_YEAR = new Date().getFullYear();
const CURRENT_YEAR = getIsraelYear(new Date()) ?? new Date().getFullYear();
const YEARS = Array.from(
{ length: CURRENT_YEAR - YEAR_FLOOR + 1 },
(_, i) => CURRENT_YEAR - i,

View File

@@ -20,15 +20,7 @@ import {
type MissingPrecedentStatus,
} from "@/lib/api/missing-precedents";
import { MissingPrecedentDetailDrawer } from "./missing-precedent-detail-drawer";
function formatDate(iso: string | null) {
if (!iso) return "—";
try {
return new Date(iso).toLocaleDateString("he-IL");
} catch {
return iso;
}
}
import { formatDateShort as formatDate } from "@/lib/format-date";
/** Status chip — mockup 09 tones (open=warn, uploaded=info, closed=success,
* irrelevant=muted). Pill-shaped, whitespace-nowrap. */

View File

@@ -14,6 +14,7 @@ import { Card, CardContent } from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Skeleton } from "@/components/ui/skeleton";
import { useDiagnostics, type DiagDoc } from "@/lib/api/system";
import { formatDateShort, formatRelative } from "@/lib/format-date";
const TABLE_LABELS: Record<string, string> = {
cases: "תיקים",
@@ -25,16 +26,10 @@ const TABLE_LABELS: Record<string, string> = {
function formatRelativeTime(iso: string | null) {
if (!iso) return "—";
const then = new Date(iso);
const diffMs = Date.now() - then.getTime();
const min = Math.floor(diffMs / 60000);
if (min < 1) return "עכשיו";
if (min < 60) return `לפני ${min} דקות`;
const hr = Math.floor(min / 60);
if (hr < 24) return `לפני ${hr} שעות`;
const days = Math.floor(hr / 24);
if (days < 30) return `לפני ${days} ימים`;
return then.toLocaleDateString("he-IL");
const min = Math.floor((Date.now() - new Date(iso).getTime()) / 60000);
// Past 30 days, fall back to an absolute Israel-time date.
if (min >= 30 * 24 * 60) return formatDateShort(iso);
return formatRelative(iso, { units: "long" });
}
function DocRow({ doc, tone }: { doc: DiagDoc; tone: "danger" | "warn" }) {

View File

@@ -15,6 +15,7 @@ import {
type Halacha, type CanonicalInstance,
} from "@/lib/api/precedent-library";
import { AuthorityBadge, ruleTypeLabel } from "./halacha-meta";
import { formatDateShort as formatDate } from "@/lib/format-date";
/** #81 strict-rubric flags — why an item was held back from auto-approval. */
const QUALITY_FLAG_LABELS: Record<string, string> = {
@@ -28,15 +29,6 @@ const QUALITY_FLAG_LABELS: Record<string, string> = {
nevo_preamble_leak: "דליפת רציו נבו",
};
function formatDate(iso: string | null | undefined) {
if (!iso) return "—";
try {
return new Date(iso).toLocaleDateString("he-IL");
} catch {
return iso;
}
}
/* Strip Unicode bidi marks that render as zero-width but shift visual position. */
function cleanCitation(s: string | null | undefined): string {
if (!s) return "—";

View File

@@ -31,15 +31,7 @@ import {
FormattedCitation,
CitationCopyButton,
} from "./formatted-citation";
function formatDate(iso: string | null) {
if (!iso) return "—";
try {
return new Date(iso).toLocaleDateString("he-IL");
} catch {
return iso;
}
}
import { formatDateShort as formatDate } from "@/lib/format-date";
function cleanCitation(s: string | null | undefined): string {
if (!s) return "—";

View File

@@ -14,15 +14,7 @@ import {
} from "@/lib/api/precedent-library";
import { PRACTICE_AREAS, PRECEDENT_LEVELS } from "./practice-area";
import { AuthorityBadge } from "./halacha-meta";
function formatDate(iso: string | null) {
if (!iso) return "—";
try {
return new Date(iso).toLocaleDateString("he-IL");
} catch {
return iso;
}
}
import { formatDateShort as formatDate } from "@/lib/format-date";
/** Score chip — boxed, gold-deep, tabular (mockup 07 `.score`). Sits at the
* end of the meta row via `ms-auto`. White fill on gold-wash halacha cards. */

View File

@@ -23,6 +23,7 @@ import {
} from "@/lib/api/precedent-library";
import { ApiError } from "@/lib/api/client";
import { useProgress } from "@/lib/api/documents";
import { formatDateShort } from "@/lib/format-date";
import {
PRACTICE_AREAS, PRECEDENT_LEVELS, SOURCE_TYPES,
} from "./practice-area";
@@ -192,7 +193,7 @@ export function PrecedentUploadSheet({ open, onOpenChange }: Props) {
{conflict.citation}
{conflict.case_name && `${conflict.case_name}`}
{conflict.court && ` · ${conflict.court}`}
{conflict.date && ` · ${new Date(conflict.date).toLocaleDateString("he-IL")}`}
{conflict.date && ` · ${formatDateShort(conflict.date)}`}
</p>
{conflict.halacha_extraction_status && (
<p className="text-danger/60 text-[0.72rem]">

View File

@@ -41,6 +41,7 @@ import {
useDeleteChat,
type ChatMessage,
} from "@/lib/api/training";
import { formatDateShort } from "@/lib/format-date";
import { useQueryClient } from "@tanstack/react-query";
export function ChatPanel() {
@@ -200,7 +201,7 @@ function ConversationsSidebar({
<span className="tabular-nums">{c.message_count}</span>
<MessageSquare className="w-3 h-3" />
<span className="grow text-end">
{new Date(c.last_message_at).toLocaleDateString("he-IL")}
{formatDateShort(c.last_message_at)}
</span>
<button
onClick={(e) => { e.stopPropagation(); onDelete(c.id); }}

View File

@@ -11,6 +11,7 @@ import { Badge } from "@/components/ui/badge";
import { Skeleton } from "@/components/ui/skeleton";
import { useCorpus, useDeleteCorpusEntry, type CorpusDecision } from "@/lib/api/training";
import { CorpusDetailDrawer } from "./corpus-detail-drawer";
import { formatDateShort as formatDate } from "@/lib/format-date";
/*
* Corpus tab: table of all decisions currently in the style corpus.
@@ -30,15 +31,6 @@ function formatChars(n: number) {
return `${(n / 1000).toFixed(1)}K`;
}
function formatDate(iso: string) {
if (!iso) return "—";
try {
return new Date(iso).toLocaleDateString("he-IL");
} catch {
return iso;
}
}
function Row({
item, onOpen,
}: { item: CorpusDecision; onOpen: () => void }) {

View File

@@ -32,6 +32,7 @@ import { Skeleton } from "@/components/ui/skeleton";
import { ScrollArea } from "@/components/ui/scroll-area";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { Markdown } from "@/components/ui/markdown";
import { formatDateShort, formatDateTimeFull } from "@/lib/format-date";
import {
useCuratorPrompt,
useCuratorStats,
@@ -256,7 +257,7 @@ function RecentFindings() {
)}
<span className="grow text-ink-muted text-end">
<Clock className="w-3 h-3 inline me-1" />
{new Date(f.created_at).toLocaleDateString("he-IL")}
{formatDateShort(f.created_at)}
</span>
</div>
<p className="text-sm text-ink leading-relaxed">{f.lesson_text}</p>
@@ -291,7 +292,7 @@ function CuratorPromptCard() {
<h3 className="text-navy font-semibold">{data.filename}</h3>
<p className="text-[0.72rem] text-ink-muted">
{data.bytes.toLocaleString("he-IL")} בייטים ·
עודכן: {new Date(data.last_modified * 1000).toLocaleString("he-IL")}
עודכן: {formatDateTimeFull(data.last_modified * 1000)}
</p>
</div>
<Button asChild variant="outline" size="sm">

View File

@@ -9,6 +9,7 @@ import {
useReconciliationLedger, useStyleDistance, usePairDetail, usePromoteLearning,
type DraftFinalPair,
} from "@/lib/api/learning";
import { formatDateShort as fmtDate } from "@/lib/format-date";
/**
* /training "למידה" tab (T6/T13) — the reconciliation ledger (INV-LRN4): every
@@ -28,11 +29,6 @@ const STATUS_CLASS: Record<string, string> = {
lessons_folded: "bg-emerald-50 text-emerald-800 border-emerald-300/60",
};
function fmtDate(iso: string | null) {
if (!iso) return "—";
try { return new Date(iso).toLocaleDateString("he-IL"); } catch { return iso; }
}
function StyleDistanceDetail({ caseNumber }: { caseNumber: string }) {
const { data, isPending, error } = useStyleDistance(caseNumber);
if (isPending) return <Loader2 className="w-4 h-4 animate-spin text-ink-muted" />;

View File

@@ -37,6 +37,7 @@ import {
usePatchLesson,
type DecisionLesson,
} from "@/lib/api/training";
import { formatDateShort } from "@/lib/format-date";
const CATEGORIES = [
{ value: "general", label: "כללי" },
@@ -224,7 +225,7 @@ function LessonItem({
{reviewBadge.label}
</Badge>
<span className="grow text-ink-muted tabular-nums">
{new Date(lesson.created_at).toLocaleDateString("he-IL")}
{formatDateShort(lesson.created_at)}
</span>
</div>