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:
@@ -14,6 +14,8 @@ import { toast } from '@/components/ui';
|
||||
import { Icon } from "@/components/icon/Icon";
|
||||
import type { IconName } from "@/components/icon/icons";
|
||||
import { useUIStore } from '@/stores/useUIStore';
|
||||
import { formatTimeForPreference } from '@/lib/timeFormat';
|
||||
import type { TimeFormatPreference } from '@/stores/useUIStore';
|
||||
import { useProjectsStore } from '@/stores/useProjectsStore';
|
||||
import { useDirectoryStore } from '@/stores/useDirectoryStore';
|
||||
import { refreshGlobalSessions } from '@/stores/useGlobalSessionsStore';
|
||||
@@ -100,11 +102,11 @@ const formatSchedule = (task: ScheduledTask, t: ReturnType<typeof useI18n>['t'])
|
||||
return t('sessions.scheduledTasks.dialog.schedule.cron', { cron: task.schedule.cron || '' });
|
||||
};
|
||||
|
||||
const formatClockTime = (value?: number): string => {
|
||||
const formatClockTime = (value: number | undefined, timeFormatPreference: TimeFormatPreference): string => {
|
||||
if (!value || !Number.isFinite(value)) {
|
||||
return '';
|
||||
}
|
||||
return new Date(value).toLocaleTimeString(undefined, { hour: 'numeric', minute: '2-digit' });
|
||||
return formatTimeForPreference(value, timeFormatPreference);
|
||||
};
|
||||
|
||||
const formatRelativeTime = (value: number | undefined, t: ReturnType<typeof useI18n>['t']): string => {
|
||||
@@ -174,6 +176,7 @@ export function ScheduledTasksDialog() {
|
||||
const open = useUIStore((state) => state.isScheduledTasksDialogOpen);
|
||||
const setOpen = useUIStore((state) => state.setScheduledTasksDialogOpen);
|
||||
const isMobile = useUIStore((state) => state.isMobile);
|
||||
const timeFormatPreference = useUIStore((state) => state.timeFormatPreference);
|
||||
const projects = useProjectsStore((state) => state.projects);
|
||||
const activeProject = useProjectsStore((state) => state.getActiveProject());
|
||||
const homeDirectory = useDirectoryStore((state) => state.homeDirectory);
|
||||
@@ -471,7 +474,7 @@ export function ScheduledTasksDialog() {
|
||||
<>
|
||||
<span className="text-foreground">{formatRelativeTime(nextAt, t)}</span>
|
||||
<span className="text-muted-foreground/50">·</span>
|
||||
<span>{formatClockTime(nextAt)}</span>
|
||||
<span>{formatClockTime(nextAt, timeFormatPreference)}</span>
|
||||
</>
|
||||
) : (
|
||||
<span>—</span>
|
||||
|
||||
Reference in New Issue
Block a user