Make the wall display and Proxmox dates follow the date and time settings

The wall clock, date line and 'Updated' footer used the browser locale, and the
Proxmox backup tasks and PBS page used toLocaleString. They now use the display
settings via new formatDate/formatTime helpers.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
bobbanandClaude Sonnet 5.5 committed 2026-10-16 21:02:41 +02:00
1 parent bff0c2169e
commit 3945c60681
4 files changed
+23 -21

No files matched your search

+2 -1
View File
@@ -10,6 +10,7 @@ import {
} from "../api/client"; } from "../api/client";
import { useSortable } from "../hooks/useSortable"; import { useSortable } from "../hooks/useSortable";
import SortableTh from "../components/SortableTh"; import SortableTh from "../components/SortableTh";
import { formatDateTime } from "../utils/date";
import { downloadCsv } from "../utils/csv"; import { downloadCsv } from "../utils/csv";
import IntegrationPageTitle from "../components/IntegrationPageTitle"; import IntegrationPageTitle from "../components/IntegrationPageTitle";
import { ErrorNotice } from "../components/Notice"; import { ErrorNotice } from "../components/Notice";
@@ -28,7 +29,7 @@ function formatBytes(bytes: number | null): string {
function formatDate(unixSeconds: number | null): string { function formatDate(unixSeconds: number | null): string {
if (unixSeconds === null) return "—"; if (unixSeconds === null) return "—";
return new Date(unixSeconds * 1000).toLocaleString(); return formatDateTime(new Date(unixSeconds * 1000));
} }
function formatUptime(seconds: number | null): string { function formatUptime(seconds: number | null): string {
+2 -1
View File
@@ -23,6 +23,7 @@ import { SearchBox } from "../components/TableToolbar";
import { useTableSearch } from "../hooks/useTableSearch"; import { useTableSearch } from "../hooks/useTableSearch";
import DetailDrawer, { ObjectDetails } from "../components/DetailDrawer"; import DetailDrawer, { ObjectDetails } from "../components/DetailDrawer";
import { useRowDetail } from "../hooks/useRowDetail"; import { useRowDetail } from "../hooks/useRowDetail";
import { formatDateTime } from "../utils/date";
function proxmoxStatusBadge(status: string) { function proxmoxStatusBadge(status: string) {
return status === "running" ? ( return status === "running" ? (
@@ -460,7 +461,7 @@ export default function Proxmox({ user }: { user: CurrentUser }) {
<td className="text-secondary">{t.node}</td> <td className="text-secondary">{t.node}</td>
<td>{t.guestId ?? "—"}</td> <td>{t.guestId ?? "—"}</td>
<td>{backupStatusBadge(t)}</td> <td>{backupStatusBadge(t)}</td>
<td className="text-secondary">{new Date(t.startTime).toLocaleString()}</td> <td className="text-secondary">{formatDateTime(new Date(t.startTime))}</td>
<td className="text-secondary">{formatDuration(t.startTime, t.endTime)}</td> <td className="text-secondary">{formatDuration(t.startTime, t.endTime)}</td>
</tr> </tr>
))} ))}
+4 -3
View File
@@ -4,6 +4,7 @@ import { api, type IntegrationSummary, type MaintenanceWindow, type ServerSummar
import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport"; import { alertBadge, useAlertsReport } from "../hooks/useAlertsReport";
import { useEnvironment } from "../utils/environment"; import { useEnvironment } from "../utils/environment";
import { formatRemaining } from "../utils/duration"; import { formatRemaining } from "../utils/duration";
import { formatDate, formatTime } from "../utils/date";
const REFRESH_MS = 30_000; const REFRESH_MS = 30_000;
@@ -133,8 +134,8 @@ export default function Wall() {
<img src="/logo.webp" alt="Homelab Manager" width={901} height={460} className="wall-logo" /> <img src="/logo.webp" alt="Homelab Manager" width={901} height={460} className="wall-logo" />
{environment?.name && <span className="badge env-badge">{environment.name}</span>} {environment?.name && <span className="badge env-badge">{environment.name}</span>}
<div className="wall-clock" aria-label="Time"> <div className="wall-clock" aria-label="Time">
<div className="wall-time">{now.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })}</div> <div className="wall-time">{formatTime(now, false)}</div>
<div className="wall-date">{now.toLocaleDateString([], { weekday: "long", day: "numeric", month: "long" })}</div> <div className="wall-date">{now.toLocaleDateString([], { weekday: "long" })} {formatDate(now)}</div>
</div> </div>
</header> </header>
@@ -223,7 +224,7 @@ export default function Wall() {
<footer className="wall-footer"> <footer className="wall-footer">
<span> <span>
{updatedAt ? `Updated ${updatedAt.toLocaleTimeString()}` : "Loading…"} · refreshes every {REFRESH_MS / 1000} s {updatedAt ? `Updated ${formatTime(updatedAt)}` : "Loading…"} · refreshes every {REFRESH_MS / 1000} s
</span> </span>
<span className="wall-footer-actions"> <span className="wall-footer-actions">
<button type="button" className="wall-link" onClick={() => void document.documentElement.requestFullscreen?.().catch(() => {})}> <button type="button" className="wall-link" onClick={() => void document.documentElement.requestFullscreen?.().catch(() => {})}>
+15 -16
View File
@@ -30,37 +30,36 @@ function pad(n: number): string {
return String(n).padStart(2, "0"); return String(n).padStart(2, "0");
} }
/** Formats a date using the app-wide date/time display settings (defaults to "YYYY-MM-DD HH:mm:ss" on a 24-hour clock). */ /** The date part alone, in the chosen date format ("2026-10-16", "16/10/2026" or "10/16/2026"). */
export function formatDateTime(date: Date): string { export function formatDate(date: Date): string {
const year = date.getFullYear(); const year = date.getFullYear();
const month = pad(date.getMonth() + 1); const month = pad(date.getMonth() + 1);
const day = pad(date.getDate()); const day = pad(date.getDate());
let datePart: string;
switch (current.dateFormat) { switch (current.dateFormat) {
case "dmy": case "dmy":
datePart = `${day}/${month}/${year}`; return `${day}/${month}/${year}`;
break;
case "mdy": case "mdy":
datePart = `${month}/${day}/${year}`; return `${month}/${day}/${year}`;
break;
case "ymd": case "ymd":
default: default:
datePart = `${year}-${month}-${day}`; return `${year}-${month}-${day}`;
break; }
} }
/** The time part alone, on the chosen 12- or 24-hour clock; seconds are left out when `withSeconds` is false (a wall clock, say). */
export function formatTime(date: Date, withSeconds = true): string {
const minutes = pad(date.getMinutes()); const minutes = pad(date.getMinutes());
const seconds = pad(date.getSeconds()); const seconds = withSeconds ? `:${pad(date.getSeconds())}` : "";
let timePart: string;
if (current.timeFormat === "12h") { if (current.timeFormat === "12h") {
const hour24 = date.getHours(); const hour24 = date.getHours();
const period = hour24 >= 12 ? "PM" : "AM"; const period = hour24 >= 12 ? "PM" : "AM";
const hour12 = hour24 % 12 || 12; return `${hour24 % 12 || 12}:${minutes}${seconds} ${period}`;
timePart = `${hour12}:${minutes}:${seconds} ${period}`; }
} else { return `${pad(date.getHours())}:${minutes}${seconds}`;
timePart = `${pad(date.getHours())}:${minutes}:${seconds}`;
} }
return `${datePart} ${timePart}`; /** Formats a date using the app-wide date/time display settings (defaults to "YYYY-MM-DD HH:mm:ss" on a 24-hour clock). */
export function formatDateTime(date: Date): string {
return `${formatDate(date)} ${formatTime(date)}`;
} }