Merge pull request #1939 from dtreskunov/dtreskunov/fix-moon-illumination-percent-calc

fix floating point bug in moon illumination calc
This commit is contained in:
Michael Teeuw 2020-02-27 16:35:38 +01:00 committed by GitHub
commit ef7720ff06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -188,7 +188,7 @@ Module.register("clock",{
moonSet = nextMoonTimes.set;
}
const isVisible = now.isBetween(moonRise, moonSet) || moonTimes.alwaysUp === true;
const illuminatedFractionString = moonIllumination.fraction.toFixed(2) * 100 + '%';
const illuminatedFractionString = Math.round(moonIllumination.fraction * 100) + '%';
moonWrapper.innerHTML = '<span class="' + (isVisible ? 'bright' : '') + '"><i class="fa fa-moon-o" aria-hidden="true"></i> ' + illuminatedFractionString + '</span>' +
'<span><i class="fa fa-arrow-up" aria-hidden="true"></i> ' + (moonRise ? formatTime(this.config, moonRise) : '...') + '</span>'+
'<span><i class="fa fa-arrow-down" aria-hidden="true"></i> ' + (moonSet ? formatTime(this.config, moonSet) : '...') + '</span>';