From 7c3675c9e1eb51e15fdd9b3be0f86eda10c0b9f4 Mon Sep 17 00:00:00 2001 From: "drewski3420@gmail.com" Date: Tue, 29 Dec 2020 21:07:14 -0500 Subject: [PATCH 1/5] This change prevents returning '-0' (negative zero) when roundTemp is true. --- modules/default/currentweather/currentweather.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 0a43b23e..18a65855 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -587,6 +587,6 @@ Module.register("currentweather", { */ roundValue: function (temperature) { var decimals = this.config.roundTemp ? 0 : 1; - return parseFloat(temperature).toFixed(decimals); + return parseFloat(Math.abs(temperature) < 0.5 && this.config.roundTemp ? 0 : temperature).toFixed(decimals); } }); From e80a65a3cd6edba0e198b4ef4a9722f27cc45bdb Mon Sep 17 00:00:00 2001 From: "drewski3420@gmail.com" Date: Wed, 30 Dec 2020 08:51:07 -0500 Subject: [PATCH 2/5] This change prevents returning '-0' (negative zero) when roundTemp is true --- modules/default/weatherforecast/weatherforecast.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 4ecc18aa..09431966 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -463,7 +463,7 @@ Module.register("weatherforecast", { */ roundValue: function (temperature) { var decimals = this.config.roundTemp ? 0 : 1; - return parseFloat(temperature).toFixed(decimals); + return parseFloat(Math.abs(temperature) < 0.5 && this.config.roundTemp ? 0 : temperature).toFixed(decimals); }, /* processRain(forecast, allForecasts) From e51f6597ed8a068b147bdb8d1055de6d80a87a94 Mon Sep 17 00:00:00 2001 From: "drewski3420@gmail.com" Date: Wed, 30 Dec 2020 09:03:19 -0500 Subject: [PATCH 3/5] This change prevents returning '-0' (negative zero) when roundTemp is true. --- modules/default/weather/weather.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/default/weather/weather.js b/modules/default/weather/weather.js index b5a68a52..51f80ff1 100644 --- a/modules/default/weather/weather.js +++ b/modules/default/weather/weather.js @@ -181,7 +181,7 @@ Module.register("weather", { roundValue: function (temperature) { var decimals = this.config.roundTemp ? 0 : 1; - return parseFloat(temperature).toFixed(decimals); + return parseFloat(Math.abs(temperature) < 0.5 && this.config.roundTemp ? 0 : temperature).toFixed(decimals); }, addFilters() { From 7b36bb025a67fbbc5b625b834ba4437e5940a521 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Thu, 7 Jan 2021 11:51:10 +0100 Subject: [PATCH 4/5] 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) From 39bb2eb9b0ef9727ff811813bd33d84a13ea6df4 Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Thu, 7 Jan 2021 11:53:21 +0100 Subject: [PATCH 5/5] Add Changelog. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4cae705..d20d4818 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ Special thanks to the following contributors: @bryanzzhu, @bugsounet, @chamakura - Cleaned up clock tests. - Move lodash into devDependencies, update other dependencies. - Switch from ical to node-ical library. +- Convert `-0` to `0` when displaying temperature. ### Fixed