diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js
index 96c31143..6e70f1e2 100644
--- a/modules/default/clock/clock.js
+++ b/modules/default/clock/clock.js
@@ -179,11 +179,19 @@ Module.register("clock",{
if (this.config.showMoonTimes) {
const moonIllumination = SunCalc.getMoonIllumination(now.toDate());
const moonTimes = SunCalc.getMoonTimes(now, this.config.lat, this.config.lon);
- const isVisible = now.isBetween(moonTimes.rise, moonTimes.set);
- const illuminatedFractionString = moonIllumination.fraction.toLocaleString(undefined, {style: 'percent'});
+ const moonRise = moonTimes.rise;
+ var moonSet;
+ if (moment(moonTimes.set).isAfter(moonTimes.rise)) {
+ moonSet = moonTimes.set;
+ } else {
+ const nextMoonTimes = SunCalc.getMoonTimes(now.clone().add(1, 'day'), this.config.lat, this.config.lon);
+ moonSet = nextMoonTimes.set;
+ }
+ const isVisible = now.isBetween(moonRise, moonSet) || moonTimes.alwaysUp === true;
+ const illuminatedFractionString = moonIllumination.fraction.toFixed(2) * 100 + '%';
moonWrapper.innerHTML = ' ' + illuminatedFractionString + '' +
- ' ' + formatTime(this.config, moonTimes.rise) + ''+
- ' ' + formatTime(this.config, moonTimes.set) + '';
+ ' ' + (moonRise ? formatTime(this.config, moonRise) : '...') + ''+
+ ' ' + (moonSet ? formatTime(this.config, moonSet) : '...') + '';
}
/****************************************************************