Skip to content

Commit

Permalink
Bug fix: adding date to the analog clock if showDate is true (#3101)
Browse files Browse the repository at this point in the history
Adding date to the clock module when displayType is "analog" and
"showDate" is true. The setting in analogShowDate is respected.

Fixes #3100

---------

Co-authored-by: Michael Teeuw <michael@xonaymedia.nl>
Co-authored-by: Veeck <github@veeck.de>
  • Loading branch information
3 people authored May 19, 2023
1 parent 432d900 commit babd22b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 3 deletions.
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);
});
});
});

0 comments on commit babd22b

Please sign in to comment.