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..22d11789a28e1 100644 --- a/test/unit/scripting_spec.js +++ b/test/unit/scripting_spec.js @@ -1398,6 +1398,18 @@ describe("Scripting", function () { expect(value).toEqual([15, 16, 21]); }); + it("should preserve the day of the month when matching weekday names", async () => { + 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 () => { const cFormat = "Hm".repeat(40); const cDate = `${"1".repeat(84)}x`;