Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix: adding date to the analog clock if showDate is true #3101

1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 7 additions & 2 deletions modules/default/clock/clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion tests/configs/modules/clock/clock_analog.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ let config = {
position: "middle_center",
config: {
displayType: "analog",
analogFace: "face-006"
analogFace: "face-006",
showDate: false
}
}
]
Expand Down
25 changes: 25 additions & 0 deletions tests/configs/modules/clock/clock_showDateAnalog.js
Original file line number Diff line number Diff line change
@@ -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;
}
14 changes: 14 additions & 0 deletions tests/e2e/modules/clock_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
});