Skip to content

Commit 1b48d16

Browse files
author
王璨
committed
feat(ui): display session timestamps in local time instead of UTC
Replace toISOString() slicing with fmtLocalDate/fmtLocalTime/fmtLocalDateTime helpers so /sessions and /session commands show human-readable local times.
1 parent 0965853 commit 1b48d16

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

src/ui/commands.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ import type { UiBackend } from "./backend.js";
55
import { saveUserConfig, maskApiKey, PROVIDER_ENV_VARS } from "../core/config.js";
66
import { getAllProviders, getAllModels, getVisionModels, getVisionProviders } from "../models/index.js";
77
import { readImageFile, readClipboardImage } from "../utils/image.js";
8+
9+
function fmtLocalDate(ts: number): string {
10+
const d = new Date(ts);
11+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
12+
}
13+
14+
function fmtLocalTime(ts: number): string {
15+
const d = new Date(ts);
16+
return `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`;
17+
}
18+
19+
function fmtLocalDateTime(ts: number): string {
20+
return `${fmtLocalDate(ts)} ${fmtLocalTime(ts)}`;
21+
}
822
import { runEval } from "../eval/index.js";
923

1024

@@ -224,8 +238,8 @@ const COMMANDS: SlashCommandDef[] = [
224238
? "All sessions:"
225239
: `Sessions (project: ${ctx.harness.config.projectPath}):`;
226240
const lines = sessions.slice(0, 30).map((s) => {
227-
const date = new Date(s.updatedAt).toISOString().slice(0, 10);
228-
const time = new Date(s.updatedAt).toISOString().slice(11, 16);
241+
const date = fmtLocalDate(s.updatedAt);
242+
const time = fmtLocalTime(s.updatedAt);
229243
const marker = s.id === currentId ? "*" : " ";
230244
const title = `"${s.title.slice(0, 60)}"`;
231245
return `${marker} ${s.id.slice(0, 8)} ${title} ${s.modelProvider}/${s.modelId} ${date} ${time} ${s.messageCount} msgs`;
@@ -270,8 +284,8 @@ const COMMANDS: SlashCommandDef[] = [
270284
` Title: "${match.title}"`,
271285
` Model: ${match.modelProvider} / ${match.modelId}`,
272286
` Project: ${match.projectPath || "(unscoped)"}`,
273-
` Created: ${new Date(match.createdAt).toISOString().replace("T", " ").slice(0, 16)}`,
274-
` Activity: ${new Date(match.updatedAt).toISOString().replace("T", " ").slice(0, 16)}`,
287+
` Created: ${fmtLocalDateTime(match.createdAt)}`,
288+
` Activity: ${fmtLocalDateTime(match.updatedAt)}`,
275289
` Messages: ${match.messageCount}`,
276290
];
277291
(ctx.ui as any).addInfo(lines.join("\n"));

0 commit comments

Comments
 (0)