Improve readabiliy.

This commit is contained in:
Michael Teeuw 2021-01-07 11:51:10 +01:00
parent e51f6597ed
commit 7b36bb025a
3 changed files with 6 additions and 3 deletions

View File

@ -587,6 +587,7 @@ Module.register("currentweather", {
*/ */
roundValue: function (temperature) { roundValue: function (temperature) {
var decimals = this.config.roundTemp ? 0 : 1; var decimals = this.config.roundTemp ? 0 : 1;
return parseFloat(Math.abs(temperature) < 0.5 && this.config.roundTemp ? 0 : temperature).toFixed(decimals); var roundValue = parseFloat(temperature).toFixed(decimals);
return roundValue === "-0" ? 0 : roundValue;
} }
}); });

View File

@ -181,7 +181,8 @@ Module.register("weather", {
roundValue: function (temperature) { roundValue: function (temperature) {
var decimals = this.config.roundTemp ? 0 : 1; var decimals = this.config.roundTemp ? 0 : 1;
return parseFloat(Math.abs(temperature) < 0.5 && this.config.roundTemp ? 0 : temperature).toFixed(decimals); var roundValue = parseFloat(temperature).toFixed(decimals);
return roundValue === "-0" ? 0 : roundValue;
}, },
addFilters() { addFilters() {

View File

@ -463,7 +463,8 @@ Module.register("weatherforecast", {
*/ */
roundValue: function (temperature) { roundValue: function (temperature) {
var decimals = this.config.roundTemp ? 0 : 1; var decimals = this.config.roundTemp ? 0 : 1;
return parseFloat(Math.abs(temperature) < 0.5 && this.config.roundTemp ? 0 : temperature).toFixed(decimals); var roundValue = parseFloat(temperature).toFixed(decimals);
return roundValue === "-0" ? 0 : roundValue;
}, },
/* processRain(forecast, allForecasts) /* processRain(forecast, allForecasts)