fix terminal system lines to use server time
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { formatTerminalLogTime } from "./logTime";
|
||||
import { formatTerminalLogTime, formatTerminalServerTime } from "./logTime";
|
||||
|
||||
describe("formatTerminalLogTime", () => {
|
||||
it("uses the SCUM log clock instead of the browser timezone", () => {
|
||||
@@ -11,4 +11,9 @@ describe("formatTerminalLogTime", () => {
|
||||
it("falls back to the event timestamp for generic logs", () => {
|
||||
expect(formatTerminalLogTime("not-a-timestamp")).toBe("时间未知");
|
||||
});
|
||||
|
||||
it("does not use the browser clock before the server clock is synchronized", () => {
|
||||
expect(formatTerminalServerTime()).toBe("时间同步中");
|
||||
expect(formatTerminalServerTime("2026-08-14T00:00:00Z")).toBe(formatTerminalLogTime("2026-08-14T00:00:00Z"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -9,3 +9,7 @@ export function formatTerminalLogTime(timestamp: string, line?: string): string
|
||||
const date = new Date(timestamp);
|
||||
return Number.isNaN(date.getTime()) ? "时间未知" : date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", second: "2-digit" });
|
||||
}
|
||||
|
||||
export function formatTerminalServerTime(timestamp?: string): string {
|
||||
return timestamp ? formatTerminalLogTime(timestamp) : "时间同步中";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user