From 7b36bb025a67fbbc5b625b834ba4437e5940a521 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Thu, 7 Jan 2021 11:51:10 +0100 Subject: [PATCH] Improve readabiliy. --- modules/default/currentweather/currentweather.js | 3 ++- modules/default/weather/weather.js | 3 ++- modules/default/weatherforecast/weatherforecast.js | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 18a65855..815b0653 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -587,6 +587,7 @@ Module.register("currentweather", { */ roundValue: function (temperature) { 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; } }); diff --git a/modules/default/weather/weather.js b/modules/default/weather/weather.js index 51f80ff1..c045804c 100644 --- a/modules/default/weather/weather.js +++ b/modules/default/weather/weather.js @@ -181,7 +181,8 @@ Module.register("weather", { roundValue: function (temperature) { 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() { diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 09431966..1d0e16f3 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -463,7 +463,8 @@ Module.register("weatherforecast", { */ roundValue: function (temperature) { 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)