From 08cb48aa2eab7040eb42cda89ed582606147ae5d Mon Sep 17 00:00:00 2001 From: Mark IJbema Date: Mon, 23 Feb 2026 14:25:10 +0100 Subject: [PATCH] fix: use ISO 8601 timestamp with timezone offset in system prompt Replace imprecise toDateString() (e.g. 'Mon Feb 23 2026') with full ISO 8601 UTC timestamp and user timezone with UTC offset when the extension provides it via editorContext.timezone. Before: Today's date: Mon Feb 23 2026 After: Current time: 2026-02-23T12:23:04.159Z User timezone: Europe/Amsterdam, UTC+1:00 --- packages/opencode/src/session/system.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/opencode/src/session/system.ts b/packages/opencode/src/session/system.ts index b29522bc16c..47f47d78666 100644 --- a/packages/opencode/src/session/system.ts +++ b/packages/opencode/src/session/system.ts @@ -36,6 +36,21 @@ export namespace SystemPrompt { return [PROMPT_ANTHROPIC_WITHOUT_TODO] } + // kilocode_change start + function formatTime(timezone?: string): string[] { + const now = new Date() + const lines = [` Current time: ${now.toISOString()}`] + if (timezone) { + const offset = -now.getTimezoneOffset() + const sign = offset >= 0 ? "+" : "-" + const hours = Math.floor(Math.abs(offset) / 60) + const mins = Math.abs(offset) % 60 + lines.push(` User timezone: ${timezone}, UTC${sign}${hours}:${mins.toString().padStart(2, "0")}`) + } + return lines + } + // kilocode_change end + export async function environment( model: Provider.Model, editorContext?: { @@ -51,14 +66,11 @@ export namespace SystemPrompt { ` Working directory: ${Instance.directory}`, ` Is directory a git repo: ${project.vcs === "git" ? "yes" : "no"}`, ` Platform: ${process.platform}`, - ` Today's date: ${new Date().toDateString()}`, + ...formatTime(editorContext?.timezone), // kilocode_change ] if (editorContext?.shell) { envLines.push(` Default shell: ${editorContext.shell}`) } - if (editorContext?.timezone) { - envLines.push(` Timezone: ${editorContext.timezone}`) - } if (editorContext?.activeFile) { envLines.push(` Active file: ${editorContext.activeFile}`) }