From df85b6b228a06f7065b9a4dd5db11f81a4fdbb17 Mon Sep 17 00:00:00 2001 From: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com> Date: Wed, 28 Oct 2026 17:21:33 +0000 Subject: [PATCH 1/3] Preserve the day of the month when scand matches weekday names Keep ddd and dddd from overwriting the calendar date and cover printd/scand round trips for every weekday in either token order. --- src/scripting_api/util.js | 9 +++------ test/unit/scripting_spec.js | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/scripting_api/util.js b/src/scripting_api/util.js index 1b6b72db9ce8d..d393fa53f26c0 100644 --- a/src/scripting_api/util.js +++ b/src/scripting_api/util.js @@ -474,17 +474,14 @@ class Util { data.month = parseInt(value) - 1; }, }, + // Weekday names are matched but must not set the day of the month. dddd: { pattern: `(${days.join("|")})`, - action: (value, data) => { - data.day = days.indexOf(value); - }, + action: () => {}, }, ddd: { pattern: `(${days.map(day => day.substring(0, 3)).join("|")})`, - action: (value, data) => { - data.day = days.findIndex(day => day.substring(0, 3) === value); - }, + action: () => {}, }, dd: { pattern: "(\\d{2})", diff --git a/test/unit/scripting_spec.js b/test/unit/scripting_spec.js index d401003ef3b89..b872451beed54 100644 --- a/test/unit/scripting_spec.js +++ b/test/unit/scripting_spec.js @@ -1398,6 +1398,23 @@ describe("Scripting", function () { expect(value).toEqual([15, 16, 21]); }); + for (const format of [ + "yyyy-mm-dd ddd", + "yyyy-mm-dd dddd", + "ddd yyyy-mm-dd", + "dddd yyyy-mm-dd", + ]) { + it(`should preserve the day of the month in ${format}`, async () => { + for (let day = 25; day <= 31; day++) { + const time = new Date(2026, 9, day).getTime(); + const value = await myeval( + `util.scand("${format}", util.printd("${format}", new Date(${time}))).getTime()` + ); + expect(value).toEqual(time); + } + }); + } + it("should handle a format with repeated specifiers", async () => { const cFormat = "Hm".repeat(40); const cDate = `${"1".repeat(84)}x`; From 3024ccf159a1839a36231fb431198920351c2de7 Mon Sep 17 00:00:00 2001 From: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com> Date: Wed, 28 Oct 2026 17:39:47 +0000 Subject: [PATCH 2/3] Use one explicit weekday parsing regression test --- test/unit/scripting_spec.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/unit/scripting_spec.js b/test/unit/scripting_spec.js index b872451beed54..6bc512873f200 100644 --- a/test/unit/scripting_spec.js +++ b/test/unit/scripting_spec.js @@ -1398,13 +1398,13 @@ describe("Scripting", function () { expect(value).toEqual([15, 16, 21]); }); - for (const format of [ - "yyyy-mm-dd ddd", - "yyyy-mm-dd dddd", - "ddd yyyy-mm-dd", - "dddd yyyy-mm-dd", - ]) { - it(`should preserve the day of the month in ${format}`, async () => { + it("should preserve the day of the month when matching weekday names", async () => { + for (const format of [ + "yyyy-mm-dd ddd", + "yyyy-mm-dd dddd", + "ddd yyyy-mm-dd", + "dddd yyyy-mm-dd", + ]) { for (let day = 25; day <= 31; day++) { const time = new Date(2026, 9, day).getTime(); const value = await myeval( @@ -1412,8 +1412,8 @@ describe("Scripting", function () { ); expect(value).toEqual(time); } - }); - } + } + }); it("should handle a format with repeated specifiers", async () => { const cFormat = "Hm".repeat(40); From cc85226c2e825fd6a15f5ad26b37bcf8cdf1f7fc Mon Sep 17 00:00:00 2001 From: NUAAwqy <146524024+NUAAwqy@users.noreply.github.com> Date: Thu, 29 Oct 2026 12:47:45 +0000 Subject: [PATCH 3/3] Write the weekday scand cases out explicitly Generating the expectations in a loop hides which format/value pair a failure refers to, so list the six calls and the one result array. --- test/unit/scripting_spec.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/test/unit/scripting_spec.js b/test/unit/scripting_spec.js index 6bc512873f200..22d11789a28e1 100644 --- a/test/unit/scripting_spec.js +++ b/test/unit/scripting_spec.js @@ -1399,20 +1399,15 @@ describe("Scripting", function () { }); it("should preserve the day of the month when matching weekday names", async () => { - for (const format of [ - "yyyy-mm-dd ddd", - "yyyy-mm-dd dddd", - "ddd yyyy-mm-dd", - "dddd yyyy-mm-dd", - ]) { - for (let day = 25; day <= 31; day++) { - const time = new Date(2026, 9, day).getTime(); - const value = await myeval( - `util.scand("${format}", util.printd("${format}", new Date(${time}))).getTime()` - ); - expect(value).toEqual(time); - } - } + const value = await myeval(`[ + util.scand("yyyy-mm-dd ddd", "2026-10-25 Sun").getDate(), + util.scand("yyyy-mm-dd dddd", "2026-10-25 Sunday").getDate(), + util.scand("ddd yyyy-mm-dd", "Sun 2026-10-25").getDate(), + util.scand("dddd yyyy-mm-dd", "Sunday 2026-10-25").getDate(), + util.scand("yyyy-mm-dd ddd", "2026-10-31 Sat").getDate(), + util.scand("ddd yyyy-mm-dd", "Sat 2026-10-31").getDate(), + ]`); + expect(value).toEqual([25, 25, 25, 25, 31, 31]); }); it("should handle a format with repeated specifiers", async () => {