From f468f7c23825a98707e8b91e7e346b719663ee3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Thu, 16 Apr 2026 22:56:54 -0400 Subject: [PATCH] fix(prompt): use UTC day-of-week to match UTC date/time stamp P2-24: now.getDay() returns local time weekday but the stamp reads 'UTC', producing off-by-one-day errors near UTC midnight. Switch to now.getUTCDay(). --- src/main/prompt-builder/system-prompt.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/prompt-builder/system-prompt.ts b/src/main/prompt-builder/system-prompt.ts index f0400cbf..13682956 100644 --- a/src/main/prompt-builder/system-prompt.ts +++ b/src/main/prompt-builder/system-prompt.ts @@ -76,7 +76,8 @@ export function buildSystemPrompt(ctx: PromptContext): string { const now = new Date(); const dateStr = now.toISOString().split("T")[0]; const timeStr = now.toISOString().split("T")[1]?.slice(0, 5) ?? "00:00"; - const dayOfWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][now.getDay()]; + // Use UTC day-of-week to stay consistent with the UTC date/time stamp below. + const dayOfWeek = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][now.getUTCDay()]; sections.push(`# Current Date & Time Today is ${dayOfWeek}, ${dateStr} at ${timeStr} UTC.