diff --git a/CHANGELOG.md b/CHANGELOG.md
index f2db63b8e3..0c357bf41f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -28,6 +28,7 @@ _This release is scheduled to be released on 2024-01-01._
- Update newsfeed: Use `html-to-text` instead of regex for transform description
- Review ESLint config (#3269)
- Updated dependencies
+- Clock module: optionally display current moon phase in addition to rise/set times
### Fixed
diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js
index c063d4dc88..b2c94fbfc5 100644
--- a/modules/default/clock/clock.js
+++ b/modules/default/clock/clock.js
@@ -32,7 +32,7 @@ Module.register("clock", {
secondsColor: "#888888",
showSunTimes: false,
- showMoonTimes: false,
+ showMoonTimes: false, // options: false, 'times' (rise/set), 'percent' (lit percent), 'phase' (current phase), or 'both' (percent & phase)
lat: 47.630539,
lon: -122.344147
},
@@ -208,9 +208,13 @@ Module.register("clock", {
moonSet = nextMoonTimes.set;
}
const isVisible = now.isBetween(moonRise, moonSet) || moonTimes.alwaysUp === true;
+ const showFraction = ["both", "percent"].includes(this.config.showMoonTimes);
+ const showUnicode = ["both", "phase"].includes(this.config.showMoonTimes);
const illuminatedFractionString = `${Math.round(moonIllumination.fraction * 100)}%`;
+ const image = showUnicode ? [..."🌑🌒🌓🌔🌕🌖🌗🌘"][Math.floor(moonIllumination.phase * 8)] : '';
+
moonWrapper.innerHTML =
- ` ${illuminatedFractionString}` +
+ `${image} ${showFraction ? illuminatedFractionString : ""}` +
` ${moonRise ? formatTime(this.config, moonRise) : "..."}` +
` ${moonSet ? formatTime(this.config, moonSet) : "..."}`;
digitalWrapper.appendChild(moonWrapper);