Skip to content

Commit 40ea553

Browse files
claudegary149
authored andcommitted
Use local timezone for ISO date to avoid midnight inconsistency
toISOString() returns UTC which can differ from the local date near midnight, causing contradictory dates in the same prompt (e.g. the human-readable date says "February 25" while the ISO date says "2026-02-26"). Build the ISO string from local date components instead so all date values in the tool preprompt stay consistent. https://claude.ai/code/session_01DmqK4Lmm7Uv41oHV3HqWpT
1 parent e443724 commit 40ea553

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/lib/server/textGeneration/utils/toolPrompt.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function buildToolPreprompt(tools: OpenAiTool[]): string {
1212
month: "long",
1313
day: "numeric",
1414
});
15-
const isoDate = now.toISOString().split("T")[0];
15+
const isoDate = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, "0")}-${String(now.getDate()).padStart(2, "0")}`;
1616
return [
1717
`You have access to these tools: ${names.join(", ")}.`,
1818
`Today's date: ${currentDate} (${isoDate}).`,

0 commit comments

Comments
 (0)