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:
@@ -18,6 +18,8 @@ import type { LanedCommit } from './gitGraph';
|
||||
import { GitGraphSegment } from './GitGraphSegment';
|
||||
import * as git from '@/lib/gitApi';
|
||||
import { toast } from '@/components/ui/toast';
|
||||
import { formatDateTimeForPreference } from '@/lib/timeFormat';
|
||||
import { useUIStore, type TimeFormatPreference } from '@/stores/useUIStore';
|
||||
|
||||
const HISTORY_DIFF_REQUEST_TIMEOUT_MS = 15000;
|
||||
const HISTORY_DIFF_LARGE_CHANGED_LINES = 500;
|
||||
@@ -77,14 +79,13 @@ interface HistoryCommitRowProps {
|
||||
onActionSuccess?: () => void;
|
||||
}
|
||||
|
||||
function formatCommitDate(date: string) {
|
||||
function formatCommitDate(date: string, timeFormatPreference: TimeFormatPreference) {
|
||||
const value = new Date(date);
|
||||
if (Number.isNaN(value.getTime())) {
|
||||
return date;
|
||||
}
|
||||
|
||||
return value.toLocaleString(undefined, {
|
||||
hour12: false,
|
||||
return formatDateTimeForPreference(value, timeFormatPreference, {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
@@ -146,6 +147,7 @@ export const HistoryCommitRow = React.memo(({
|
||||
onActionSuccess,
|
||||
}: HistoryCommitRowProps) => {
|
||||
const { t } = useI18n();
|
||||
const timeFormatPreference = useUIStore((state) => state.timeFormatPreference);
|
||||
const isGraphMode = mode === 'graph';
|
||||
type PendingAction =
|
||||
| 'checkout' | 'cherryPick' | 'revert'
|
||||
@@ -397,8 +399,8 @@ export const HistoryCommitRow = React.memo(({
|
||||
{entry.author_name}
|
||||
</span>
|
||||
<span className="shrink-0">·</span>
|
||||
<span className="truncate min-w-0" title={formatCommitDate(entry.date)}>
|
||||
{formatCommitDate(entry.date)}
|
||||
<span className="truncate min-w-0" title={formatCommitDate(entry.date, timeFormatPreference)}>
|
||||
{formatCommitDate(entry.date, timeFormatPreference)}
|
||||
</span>
|
||||
</div>
|
||||
<span className="shrink-0">·</span>
|
||||
|
||||
@@ -28,6 +28,7 @@ import { MobileOverlayPanel } from '@/components/ui/MobileOverlayPanel';
|
||||
import { SimpleMarkdownRenderer } from '@/components/chat/MarkdownRenderer';
|
||||
import { Icon } from "@/components/icon/Icon";
|
||||
import { useUIStore } from '@/stores/useUIStore';
|
||||
import { formatDateTimeForPreference } from '@/lib/timeFormat';
|
||||
import { useSessionUIStore } from '@/sync/session-ui-store';
|
||||
import { useSelectionStore } from '@/sync/selection-store';
|
||||
import { useConfigStore } from '@/stores/useConfigStore';
|
||||
@@ -309,6 +310,7 @@ export const PullRequestSection: React.FC<{
|
||||
onGeneratedDescription?: () => void;
|
||||
}> = ({ directory, branch, baseBranch, trackingBranch, remotes = [], remoteBranches = [], onGeneratedDescription }) => {
|
||||
const { t } = useI18n();
|
||||
const timeFormatPreference = useUIStore((state) => state.timeFormatPreference);
|
||||
const { github } = useRuntimeAPIs();
|
||||
const githubAuthStatus = useGitHubAuthStore((state) => state.status);
|
||||
const githubAuthChecked = useGitHubAuthStore((state) => state.hasChecked);
|
||||
@@ -627,8 +629,14 @@ export const PullRequestSection: React.FC<{
|
||||
if (!Number.isFinite(ts)) {
|
||||
return value;
|
||||
}
|
||||
return new Date(ts).toLocaleString();
|
||||
}, []);
|
||||
return formatDateTimeForPreference(ts, timeFormatPreference, {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: 'numeric',
|
||||
minute: '2-digit',
|
||||
});
|
||||
}, [timeFormatPreference]);
|
||||
|
||||
const connectedGitHubLogin = React.useMemo(() => {
|
||||
const login = githubAuthStatus?.user?.login;
|
||||
|
||||
Reference in New Issue
Block a user