From 071c551876a26ab9c0c4fa2ff4a343a1a5859c57 Mon Sep 17 00:00:00 2001 From: spoukyii <61633921+spoukyii@users.noreply.github.com> Date: Fri, 6 Nov 2026 01:13:03 -0800 Subject: [PATCH 1/2] test(web): access timestamps follow the Time format setting --- .../settings/ConnectionsSettings.logic.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/apps/web/src/components/settings/ConnectionsSettings.logic.test.ts b/apps/web/src/components/settings/ConnectionsSettings.logic.test.ts index ffd59c5439bc8..6670217b4d8ae 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.logic.test.ts +++ b/apps/web/src/components/settings/ConnectionsSettings.logic.test.ts @@ -2,12 +2,30 @@ import { type DesktopWslState, EnvironmentId } from "@t3tools/contracts"; import { describe, expect, it, vi } from "vite-plus/test"; import { applyWslEnableSelection, + formatAccessTimestamp, resolveAccessEnvironmentId, resolveTailscaleServeBaseUrl, selectQrEndpointOption, togglePairingScopeSelection, } from "./ConnectionsSettings.logic"; +describe("formatAccessTimestamp", () => { + const date = new Date(2026, 9, 20, 17, 30); + + it.each([ + ["12-hour", true], + ["24-hour", false], + ] as const)("formats the time with the %s setting", (timestampFormat, hour12) => { + expect(formatAccessTimestamp(date.toISOString(), timestampFormat)).toBe( + new Intl.DateTimeFormat(undefined, { + dateStyle: "medium", + timeStyle: "short", + hour12, + }).format(date), + ); + }); +}); + describe("togglePairingScopeSelection", () => { it.each([ { From 27a949a935633ad4e1094736be2004583fab3350 Mon Sep 17 00:00:00 2001 From: spoukyii <61633921+spoukyii@users.noreply.github.com> Date: Fri, 6 Nov 2026 01:14:47 -0800 Subject: [PATCH 2/2] fix(web): clock times in settings and toasts follow the Time format setting Settings > General > Time format picks 12-hour or 24-hour times, and most surfaces honor it after #4438, #15575 and #22915. Four still formatted with the browser's default clock: the source control sign-in "code expires at" time, the slow-request toast's "Started" time, the Sharing & access pairing-link and last-connected labels, and the T3 Connect mobile clients "Updated" label. With 24-hour selected they kept showing "5:30 PM". They now read the setting and format through timestampFormat.ts. The time-only labels use formatShortTimestamp; the slow-request toast keeps its seconds. The date-and-time labels share a new formatDateTimeTimestamp, which keeps the medium date they showed and adds the setting's clock. Bug: times ignore the Time format setting --- .../SlowRpcRequestToastCoordinator.tsx | 5 +++- .../MobileClientsUserProfilePage.logic.ts | 17 ++++++------ .../clerk/MobileClientsUserProfilePage.tsx | 4 ++- .../settings/AuthorizedClientsSettings.tsx | 9 ++++--- .../settings/ConnectionsSettings.logic.ts | 15 +++-------- .../SourceControlAppSignInSettings.tsx | 10 +++---- apps/web/src/timestampFormat.ts | 26 +++++++++++++++++-- 7 files changed, 54 insertions(+), 32 deletions(-) diff --git a/apps/web/src/components/SlowRpcRequestToastCoordinator.tsx b/apps/web/src/components/SlowRpcRequestToastCoordinator.tsx index 4536987ab3b7d..2212ad5883a6c 100644 --- a/apps/web/src/components/SlowRpcRequestToastCoordinator.tsx +++ b/apps/web/src/components/SlowRpcRequestToastCoordinator.tsx @@ -1,4 +1,6 @@ +import { useClientSettings } from "../hooks/useSettings"; import { type SlowRpcAckRequest, subscribeSlowRpcAckRequests } from "../rpc/requestLatencyState"; +import { formatShortTimestamp } from "../timestampFormat"; import { toastManager } from "./ui/toast"; function describeSlowRequests(requests: ReadonlyArray): string { @@ -11,6 +13,7 @@ function describeSlowRequests(requests: ReadonlyArray): strin } function SlowRequestDetails({ requests }: { requests: ReadonlyArray }) { + const timestampFormat = useClientSettings((settings) => settings.timestampFormat); return (
    {requests.map((request) => ( @@ -20,7 +23,7 @@ function SlowRequestDetails({ requests }: { requests: ReadonlyArray
    {request.tag}
    - Started {new Date(request.startedAt).toLocaleTimeString()} + Started {formatShortTimestamp(request.startedAt, timestampFormat, true)}
    ))} diff --git a/apps/web/src/components/clerk/MobileClientsUserProfilePage.logic.ts b/apps/web/src/components/clerk/MobileClientsUserProfilePage.logic.ts index b52d381f6ddfb..4e7b192cd3598 100644 --- a/apps/web/src/components/clerk/MobileClientsUserProfilePage.logic.ts +++ b/apps/web/src/components/clerk/MobileClientsUserProfilePage.logic.ts @@ -1,9 +1,7 @@ import type { RelayClientDeviceRecord } from "@t3tools/contracts/relay"; +import { type TimestampFormat } from "@t3tools/contracts/settings"; -const mobileClientUpdatedAtFormatter = new Intl.DateTimeFormat(undefined, { - dateStyle: "medium", - timeStyle: "short", -}); +import { formatDateTimeTimestamp } from "../../timestampFormat"; const NOTIFICATION_PREFERENCES = [ ["notifyOnApproval", "approvals"], @@ -37,9 +35,10 @@ export function mobileClientNotificationDetail(device: RelayClientDeviceRecord): : "Push notifications are enabled, but no alert types are selected."; } -export function mobileClientUpdatedAtLabel(updatedAt: string): string { - const date = new Date(updatedAt); - return Number.isNaN(date.getTime()) - ? "Update time unavailable" - : `Updated ${mobileClientUpdatedAtFormatter.format(date)}`; +export function mobileClientUpdatedAtLabel( + updatedAt: string, + timestampFormat: TimestampFormat, +): string { + const label = formatDateTimeTimestamp(updatedAt, timestampFormat); + return label ? `Updated ${label}` : "Update time unavailable"; } diff --git a/apps/web/src/components/clerk/MobileClientsUserProfilePage.tsx b/apps/web/src/components/clerk/MobileClientsUserProfilePage.tsx index 016099805eb2a..fa0f2b2f49c4f 100644 --- a/apps/web/src/components/clerk/MobileClientsUserProfilePage.tsx +++ b/apps/web/src/components/clerk/MobileClientsUserProfilePage.tsx @@ -2,6 +2,7 @@ import type { RelayClientDeviceRecord } from "@t3tools/contracts/relay"; import { SmartphoneIcon } from "lucide-react"; import { useManagedRelayDevices } from "../../cloud/managedRelayState"; +import { useClientSettings } from "../../hooks/useSettings"; import { Badge } from "../ui/badge"; import { Button } from "../ui/button"; import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty"; @@ -34,6 +35,7 @@ function MobileClientStatusBadge({ } function MobileClientRow({ device }: { readonly device: RelayClientDeviceRecord }) { + const timestampFormat = useClientSettings((settings) => settings.timestampFormat); return ( }>
    @@ -46,7 +48,7 @@ function MobileClientRow({ device }: { readonly device: RelayClientDeviceRecord

    - {mobileClientUpdatedAtLabel(device.updatedAt)} + {mobileClientUpdatedAtLabel(device.updatedAt, timestampFormat)}

    diff --git a/apps/web/src/components/settings/AuthorizedClientsSettings.tsx b/apps/web/src/components/settings/AuthorizedClientsSettings.tsx index 75e3c972ee797..bce87e2369e79 100644 --- a/apps/web/src/components/settings/AuthorizedClientsSettings.tsx +++ b/apps/web/src/components/settings/AuthorizedClientsSettings.tsx @@ -21,6 +21,7 @@ import { } from "@t3tools/client-runtime/state/runtime"; import { useCopyToClipboard } from "../../hooks/useCopyToClipboard"; +import { useClientSettings } from "../../hooks/useSettings"; import { cn } from "../../lib/utils"; import { formatElapsedDurationLabel, formatExpiresInLabel } from "../../timestampFormat"; import { resolveDesktopPairingUrl, resolveHostedPairingUrl } from "./pairingUrls"; @@ -150,6 +151,7 @@ const PairingLinkListRow = memo(function PairingLinkListRow({ canRevoke, }: PairingLinkListRowProps) { const nowMs = useNowSecond(); + const timestampFormat = useClientSettings((settings) => settings.timestampFormat); const expiresAtMs = new Date(pairingLink.expiresAt).getTime(); const [isRevealDialogOpen, setIsRevealDialogOpen] = useState(false); const [isQrPanelOpen, setIsQrPanelOpen] = useState(defaultShareOpen); @@ -264,7 +266,7 @@ const PairingLinkListRow = memo(function PairingLinkListRow({ if (credential) copyPairingValue(credential, "code"); }; - const expiresAbsolute = formatAccessTimestamp(pairingLink.expiresAt); + const expiresAbsolute = formatAccessTimestamp(pairingLink.expiresAt, timestampFormat); const primaryLabel = pairingLink.label ?? "Pairing link"; const selectedQrOption = selectQrEndpointOption( @@ -284,7 +286,7 @@ const PairingLinkListRow = memo(function PairingLinkListRow({

    {primaryLabel}

    @@ -506,6 +508,7 @@ const ConnectedClientListRow = memo(function ConnectedClientListRow({ canRevoke, }: ConnectedClientListRowProps) { const nowMs = useNowSecond(); + const timestampFormat = useClientSettings((settings) => settings.timestampFormat); const isLive = clientSession.current || clientSession.connected; const lastConnectedAt = clientSession.lastConnectedAt; const statusTooltip = isLive @@ -513,7 +516,7 @@ const ConnectedClientListRow = memo(function ConnectedClientListRow({ ? `Connected for ${formatElapsedDurationLabel(lastConnectedAt, nowMs)}` : "Connected" : lastConnectedAt - ? `Last connected at ${formatAccessTimestamp(lastConnectedAt)}` + ? `Last connected at ${formatAccessTimestamp(lastConnectedAt, timestampFormat)}` : "Not connected yet."; const deviceInfoBits = [ clientSession.client.deviceType !== "unknown" diff --git a/apps/web/src/components/settings/ConnectionsSettings.logic.ts b/apps/web/src/components/settings/ConnectionsSettings.logic.ts index e219694351b9b..4af181f6dc32d 100644 --- a/apps/web/src/components/settings/ConnectionsSettings.logic.ts +++ b/apps/web/src/components/settings/ConnectionsSettings.logic.ts @@ -21,6 +21,8 @@ import { type DesktopWslState, type EnvironmentId, } from "@t3tools/contracts"; +import { type TimestampFormat } from "@t3tools/contracts/settings"; +import { formatDateTimeTimestamp } from "../../timestampFormat"; import { getDesktopUpdateDownloadedVersion, resolveDesktopUpdateButtonAction, @@ -159,17 +161,8 @@ export async function applyWslEnableSelection(input: { return await bridge.setWslBackendEnabled(true); } -const accessTimestampFormatter = new Intl.DateTimeFormat(undefined, { - dateStyle: "medium", - timeStyle: "short", -}); - -export function formatAccessTimestamp(value: string): string { - const parsed = new Date(value); - if (Number.isNaN(parsed.getTime())) { - return value; - } - return accessTimestampFormatter.format(parsed); +export function formatAccessTimestamp(value: string, timestampFormat: TimestampFormat): string { + return formatDateTimeTimestamp(value, timestampFormat) || value; } export function parseManualDesktopSshTarget(input: { diff --git a/apps/web/src/components/settings/SourceControlAppSignInSettings.tsx b/apps/web/src/components/settings/SourceControlAppSignInSettings.tsx index 54b0018a249c7..8d6422d109c85 100644 --- a/apps/web/src/components/settings/SourceControlAppSignInSettings.tsx +++ b/apps/web/src/components/settings/SourceControlAppSignInSettings.tsx @@ -13,8 +13,9 @@ import { useState, type ReactNode } from "react"; import { MorphIcon } from "~/components/MorphIcon"; import { T3AppIcon } from "~/components/T3AppIcon"; import { useCopyToClipboard } from "~/hooks/useCopyToClipboard"; -import { useEnvironmentSettings } from "../../hooks/useSettings"; +import { useClientSettings, useEnvironmentSettings } from "../../hooks/useSettings"; import { cn } from "../../lib/utils"; +import { formatShortTimestamp } from "../../timestampFormat"; import { serverEnvironment } from "../../state/server"; import { sourceControlEnvironment } from "../../state/sourceControl"; import { useAtomCommand } from "../../state/use-atom-command"; @@ -33,9 +34,6 @@ const failureMessage = (cause: Cause.Cause) => { return error instanceof Error ? error.message : String(error); }; -const expiryTime = (expiresAt: number) => - new Date(expiresAt).toLocaleTimeString(undefined, { hour: "numeric", minute: "2-digit" }); - function ExternalLink(props: { readonly href: string; readonly children: ReactNode }) { return ( }> @@ -100,6 +98,7 @@ export function SourceControlAppSignInSettings({ const { signIns, tokens } = useEnvironmentSettings(environmentId, (settings) => readHostCredentialSettings(settings, definition.kind), ); + const timestampFormat = useClientSettings((settings) => settings.timestampFormat); const signedIn = (signIns[host] ?? "").length > 0; const token = tokens[host]; // A token read from a secret provider overrides the sign-in like a saved one. @@ -250,7 +249,8 @@ export function SourceControlAppSignInSettings({

    - Waiting for approval · code expires at {expiryTime(waiting.expiresAt)} + Waiting for approval · code expires at{" "} + {formatShortTimestamp(new Date(waiting.expiresAt).toISOString(), timestampFormat)}

    diff --git a/apps/web/src/timestampFormat.ts b/apps/web/src/timestampFormat.ts index abad91401ccbe..591af3d3bce48 100644 --- a/apps/web/src/timestampFormat.ts +++ b/apps/web/src/timestampFormat.ts @@ -131,10 +131,32 @@ export function formatChatTimestampTooltip( return `${time}, ${day}${ordinalSuffix(day)} ${month} ${year}`; } -export function formatShortTimestamp(isoDate: string, timestampFormat: TimestampFormat): string { +export function formatShortTimestamp( + isoDate: string, + timestampFormat: TimestampFormat, + includeSeconds = false, +): string { const date = parseTimestampDate(isoDate); if (!date) return ""; - return getTimestampFormatter(timestampFormat, false).format(date); + return getTimestampFormatter(timestampFormat, includeSeconds).format(date); +} + +const dateTimeFormatterCache = new Map(); + +/** A date and time, such as "Oct 20, 2026, 5:30 PM". */ +export function formatDateTimeTimestamp(isoDate: string, timestampFormat: TimestampFormat): string { + const date = parseTimestampDate(isoDate); + if (!date) return ""; + let formatter = dateTimeFormatterCache.get(timestampFormat); + if (!formatter) { + formatter = new Intl.DateTimeFormat(timestampLocale, { + dateStyle: "medium", + timeStyle: "short", + ...(timestampFormat === "locale" ? {} : { hour12: timestampFormat === "12-hour" }), + }); + dateTimeFormatterCache.set(timestampFormat, formatter); + } + return formatter.format(date); } const numericDateOptions: Intl.DateTimeFormatOptions = { month: "numeric", day: "numeric" };