diff --git a/CHANGELOG.md b/CHANGELOG.md index 40b18d7023..54e3dc173a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ _This release is scheduled to be released on 2023-07-01._ - Fix electron not running under windows after async changes (#3083) - Fix style issues after eslint-plugin-jsdoc update - Fix don't filter out ongoing full day events (#3095) +- Fix date not shown when clock in analog mode (#3100) ## [2.23.0] - 2023-04-04 diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js index 348e7a4c4d..c063d4dc88 100644 --- a/modules/default/clock/clock.js +++ b/modules/default/clock/clock.js @@ -281,9 +281,14 @@ Module.register("clock", { */ if (this.config.displayType === "analog") { // Display only an analog clock - if (this.config.analogShowDate === "top") { + if (this.config.showDate) { + // Add date to the analog clock + dateWrapper.innerHTML = now.format(this.config.dateFormat); + wrapper.appendChild(dateWrapper); + } + if (this.config.analogShowDate === "bottom") { wrapper.classList.add("clock-grid-bottom"); - } else if (this.config.analogShowDate === "bottom") { + } else if (this.config.analogShowDate === "top") { wrapper.classList.add("clock-grid-top"); } wrapper.appendChild(analogWrapper); diff --git a/tests/configs/modules/clock/clock_analog.js b/tests/configs/modules/clock/clock_analog.js index fdca561562..d303c3f995 100644 --- a/tests/configs/modules/clock/clock_analog.js +++ b/tests/configs/modules/clock/clock_analog.js @@ -9,7 +9,8 @@ let config = { position: "middle_center", config: { displayType: "analog", - analogFace: "face-006" + analogFace: "face-006", + showDate: false } } ] diff --git a/tests/configs/modules/clock/clock_showDateAnalog.js b/tests/configs/modules/clock/clock_showDateAnalog.js new file mode 100644 index 0000000000..e5f5c49b7d --- /dev/null +++ b/tests/configs/modules/clock/clock_showDateAnalog.js @@ -0,0 +1,25 @@ +/* MagicMirror² Test config for default clock module + * + * By Johan Hammar + * MIT Licensed. + */ +let config = { + timeFormat: 12, + + modules: [ + { + module: "clock", + position: "middle_center", + config: { + showTime: true, + showDate: true, + displayType: "analog" + } + } + ] +}; + +/*************** DO NOT EDIT THE LINE BELOW ***************/ +if (typeof module !== "undefined") { + module.exports = config; +} diff --git a/tests/e2e/modules/clock_spec.js b/tests/e2e/modules/clock_spec.js index 1ffa74a1bf..fa8ce28f7a 100644 --- a/tests/e2e/modules/clock_spec.js +++ b/tests/e2e/modules/clock_spec.js @@ -107,4 +107,18 @@ describe("Clock module", () => { expect(elem).not.toBe(null); }); }); + + describe("with analog clock face and date enabled", () => { + beforeAll(async () => { + await helpers.startApplication("tests/configs/modules/clock/clock_showDateAnalog.js"); + await helpers.getDocument(); + }); + + it("should show the analog clock face and the date", async () => { + const elemClock = helpers.waitForElement(".clock-circle"); + await expect(elemClock).not.toBe(null); + const elemDate = helpers.waitForElement(".clock .date"); + await expect(elemDate).not.toBe(null); + }); + }); });