Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(shared): say each weekday once, in weekday order
lhy-dcf12935993acb5
diff --git a/packages/phone-protocol/src/plain-time-zone.ts b/packages/phone-protocol/src/plain-time-zone.tsindex ffabea839f..7aa56f126e 100644--- a/packages/phone-protocol/src/plain-time-zone.ts+++ b/packages/phone-protocol/src/plain-time-zone.ts@@ -34,6 +34,9 @@ const WEEKDAYS = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Frida/** Local weekdays (Sunday = 0) as people say them: "every day", "weekdays", "Monday, Wednesday". */export function plainWeekdays(weekdays: readonly number[]): string {- const days = [...weekdays].sort((a, b) => a - b).join(",");- return days === "0,1,2,3,4,5,6" ? "every day" : days === "1,2,3,4,5" ? "weekdays" : weekdays.map((day) => WEEKDAYS[day]).join(", ");+ // One day each, in weekday order: a schedule stores its weekdays in whatever order it was built in, so a+ // shuffled list read back in that order names its two days the wrong way round, and a repeated one twice.+ const days = [...new Set(weekdays)].sort((a, b) => a - b);+ const joined = days.join(",");+ return joined === "0,1,2,3,4,5,6" ? "every day" : joined === "1,2,3,4,5" ? "weekdays" : days.map((day) => WEEKDAYS[day]).join(", ");}diff --git a/shared/plain-time-zone.test.ts b/shared/plain-time-zone.test.tsindex 2237b70e88..3c1b334edc 100644--- a/shared/plain-time-zone.test.ts+++ b/shared/plain-time-zone.test.ts@@ -46,3 +46,16 @@ describe("time zones in plain words", () => {expect(plainClock("00:15")).toBe("0:15");});});++describe("weekdays in the order they were given", () => {+ it("prints them Monday first whatever order the caller kept", () => {+ expect(plainWeekdays([3, 1])).toBe("Monday, Wednesday");+ expect(plainWeekdays([6, 0, 3])).toBe("Sunday, Wednesday, Saturday");+ });++ it("says a day once when the list repeats it", () => {+ expect(plainWeekdays([1, 1, 2])).toBe("Monday, Tuesday");+ expect(plainWeekdays([5, 5, 1, 2, 3, 4])).toBe("weekdays");+ expect(plainWeekdays([0, 1, 2, 3, 4, 5, 6, 0])).toBe("every day");+ });+});