From e58e13708d7bf7714fc55c271c0a42b90f01716c Mon Sep 17 00:00:00 2001 From: Tim Krase Date: Wed, 7 Jan 2026 11:02:39 +0100 Subject: [PATCH] Agents: add weekday to user time --- src/agents/pi-embedded-runner.ts | 12 ++++++++++-- src/agents/system-prompt.test.ts | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/agents/pi-embedded-runner.ts b/src/agents/pi-embedded-runner.ts index c0026884c..e05deac2c 100644 --- a/src/agents/pi-embedded-runner.ts +++ b/src/agents/pi-embedded-runner.ts @@ -213,6 +213,7 @@ function formatUserTime(date: Date, timeZone: string): string | undefined { try { const parts = new Intl.DateTimeFormat("en-CA", { timeZone, + weekday: "long", year: "numeric", month: "2-digit", day: "2-digit", @@ -224,10 +225,17 @@ function formatUserTime(date: Date, timeZone: string): string | undefined { for (const part of parts) { if (part.type !== "literal") map[part.type] = part.value; } - if (!map.year || !map.month || !map.day || !map.hour || !map.minute) { + if ( + !map.weekday || + !map.year || + !map.month || + !map.day || + !map.hour || + !map.minute + ) { return undefined; } - return `${map.year}-${map.month}-${map.day} ${map.hour}:${map.minute}`; + return `${map.weekday} ${map.year}-${map.month}-${map.day} ${map.hour}:${map.minute}`; } catch { return undefined; } diff --git a/src/agents/system-prompt.test.ts b/src/agents/system-prompt.test.ts index 942a6f671..268b536f0 100644 --- a/src/agents/system-prompt.test.ts +++ b/src/agents/system-prompt.test.ts @@ -51,12 +51,12 @@ describe("buildAgentSystemPromptAppend", () => { const prompt = buildAgentSystemPromptAppend({ workspaceDir: "/tmp/clawd", userTimezone: "America/Chicago", - userTime: "2026-01-05 15:26", + userTime: "Monday 2026-01-05 15:26", }); expect(prompt).toContain("## Time"); expect(prompt).toContain("User timezone: America/Chicago"); - expect(prompt).toContain("Current user time: 2026-01-05 15:26"); + expect(prompt).toContain("Current user time: Monday 2026-01-05 15:26"); }); it("includes model alias guidance when aliases are provided", () => {