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
This commit is contained in:
Mark IJbema
2026-02-23 14:25:10 +01:00
parent 226583caf2
commit 08cb48aa2e
+16 -4
View File
@@ -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}`)
}