fix: respect time format preference in UI

Add shared time formatting helpers that apply the Appearance time format preference consistently. Update visible time labels across chat, quota usage, scheduled tasks, tunnels, context details, git views, PR metadata, and passkey settings to use the selected 12-hour, 24-hour, or automatic format. Leave date-only and non-UI formatting untouched so unrelated behavior does not change.
This commit is contained in:
Bohdan Triapitsyn
2026-06-03 18:20:35 +03:00
parent 297663c2d7
commit 874dc15263
14 changed files with 143 additions and 55 deletions
+6 -5
View File
@@ -1,3 +1,6 @@
import { formatDateTimeForPreference, formatTimeForPreference } from '@/lib/timeFormat';
import type { TimeFormatPreference } from '@/stores/useUIStore';
export const clampPercent = (value: number | null): number | null => {
if (typeof value !== 'number' || !Number.isFinite(value)) {
return null;
@@ -22,6 +25,7 @@ export const formatQuotaValueLabel = (
export const formatQuotaResetLabel = (
resetAt: number | null,
fallback?: string | null,
timeFormatPreference: TimeFormatPreference = 'auto',
): string => {
if (!resetAt) {
return fallback ?? '';
@@ -37,13 +41,10 @@ export const formatQuotaResetLabel = (
const isToday = resetDate.toDateString() === now.toDateString();
if (isToday) {
return resetDate.toLocaleTimeString(undefined, {
hour: 'numeric',
minute: '2-digit',
});
return formatTimeForPreference(resetDate, timeFormatPreference, { fallback: fallback ?? '' });
}
return resetDate.toLocaleString(undefined, {
return formatDateTimeForPreference(resetDate, timeFormatPreference, {
month: 'short',
day: 'numeric',
weekday: 'short',