fix: trim timezone suffix from pretty logs

This commit is contained in:
Peter Steinberger
2026-04-12 18:58:22 +01:00
parent d660ea70ab
commit 4df9772b6e
2 changed files with 3 additions and 7 deletions

View File

@@ -29,7 +29,7 @@ describe("formatConsoleTimestamp", () => {
return `${year}-${month}-${day}T${h}:${m}:${s}.${ms}${tzSign}${tzHours}:${tzMinutes}`;
}
it("pretty style returns local HH:MM:SS with timezone offset", () => {
it("pretty style returns local HH:MM:SS without timezone suffix", () => {
vi.useFakeTimers();
vi.setSystemTime(new Date("2026-01-17T18:01:02.345Z"));
@@ -38,11 +38,7 @@ describe("formatConsoleTimestamp", () => {
const h = pad2(now.getHours());
const m = pad2(now.getMinutes());
const s = pad2(now.getSeconds());
const tzOffset = now.getTimezoneOffset();
const tzSign = tzOffset <= 0 ? "+" : "-";
const tzHours = pad2(Math.floor(Math.abs(tzOffset) / 60));
const tzMinutes = pad2(Math.abs(tzOffset) % 60);
expect(result).toBe(`${h}:${m}:${s}${tzSign}${tzHours}:${tzMinutes}`);
expect(result).toBe(`${h}:${m}:${s}`);
});
it("compact style returns local ISO-like timestamp with timezone offset", () => {

View File

@@ -176,7 +176,7 @@ function isEpipeError(err: unknown): boolean {
export function formatConsoleTimestamp(style: ConsoleStyle): string {
const now = new Date();
if (style === "pretty") {
return formatTimestamp(now, { style: "short" });
return formatTimestamp(now, { style: "short" }).replace(/[+-]\d{2}:\d{2}$/, "");
}
return formatLocalIsoWithOffset(now);
}