From 593436e4cb5852f396fbaaa9f87ef1a0b518e76d Mon Sep 17 00:00:00 2001 From: jackwener Date: Fri, 20 Mar 2026 17:57:31 +0800 Subject: [PATCH] fix(xiaohongshu): use fixed UTC+8 offset in trend timestamp formatting (CI timezone fix) --- src/clis/xiaohongshu/creator-note-detail.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/clis/xiaohongshu/creator-note-detail.ts b/src/clis/xiaohongshu/creator-note-detail.ts index ec9e511..8e400a6 100644 --- a/src/clis/xiaohongshu/creator-note-detail.ts +++ b/src/clis/xiaohongshu/creator-note-detail.ts @@ -223,12 +223,14 @@ export function appendAudienceRows(rows: CreatorNoteDetailRow[], payload?: NoteD function formatTrendTimestamp(ts: number | undefined, granularity: 'hour' | 'day'): string { if (!ts) return ''; - const date = new Date(ts); + // Use fixed UTC+8 offset to ensure consistent output regardless of CI server timezone. + const CST_OFFSET_MS = 8 * 60 * 60 * 1000; + const cstDate = new Date(ts + CST_OFFSET_MS); const pad = (value: number) => String(value).padStart(2, '0'); if (granularity === 'hour') { - return `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:00`; + return `${pad(cstDate.getUTCMonth() + 1)}-${pad(cstDate.getUTCDate())} ${pad(cstDate.getUTCHours())}:00`; } - return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`; + return `${cstDate.getUTCFullYear()}-${pad(cstDate.getUTCMonth() + 1)}-${pad(cstDate.getUTCDate())}`; } function formatTrendSeries(points: NoteTrendPoint[] | undefined, granularity: 'hour' | 'day'): string {