From 0c75a0867129f325b93d35dbb374072e72746256 Mon Sep 17 00:00:00 2001 From: CamelBackNotation Date: Fri, 27 Feb 2015 15:04:18 -0600 Subject: [PATCH 1/2] Fixed the case where -0F would be displayed due to rounding from the conversion specifiers %.0f when round = true --- panel-plugin/weather-data.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c index 3728199..56effb3 100644 --- a/panel-plugin/weather-data.c +++ b/panel-plugin/weather-data.c @@ -343,8 +343,11 @@ get_data(const xml_time *timeslice, case TEMPERATURE: /* source is in °C */ val = string_to_double(loc->temperature_value, 0); - if (units->temperature == FAHRENHEIT) + if (units->temperature == FAHRENHEIT) { val = val * 9.0 / 5.0 + 32.0; + if (round && (val > -0.5 && val < 0)) + val = val + 0.5; + } return g_strdup_printf(ROUND_TO_INT("%.1f"), val); case PRESSURE: /* source is in hectopascals */ -- 2.1.0 From bfc24646a63f736899c885f3adf0a80d2a3b0603 Mon Sep 17 00:00:00 2001 From: CamelBackNotation Date: Fri, 27 Feb 2015 23:19:09 -0600 Subject: [PATCH 2/2] Added fix in all places temperature display is relevant. Added comments for future developers. --- panel-plugin/weather-data.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c index 56effb3..ffde8a0 100644 --- a/panel-plugin/weather-data.c +++ b/panel-plugin/weather-data.c @@ -345,6 +345,7 @@ get_data(const xml_time *timeslice, val = string_to_double(loc->temperature_value, 0); if (units->temperature == FAHRENHEIT) { val = val * 9.0 / 5.0 + 32.0; + /* Prevents the display of -0F */ if (round && (val > -0.5 && val < 0)) val = val + 0.5; } @@ -400,15 +401,23 @@ get_data(const xml_time *timeslice, val = calc_dewpoint(loc); if (val == INVALID_VALUE) return g_strdup(""); - if (units->temperature == FAHRENHEIT) + if (units->temperature == FAHRENHEIT) { val = val * 9.0 / 5.0 + 32.0; + /* Prevents the display of -0F */ + if (round && (val > -0.5 && val < 0)) + val = val + 0.5; + } return g_strdup_printf(ROUND_TO_INT("%.1f"), val); case APPARENT_TEMPERATURE: val = calc_apparent_temperature(loc, units->apparent_temperature, night_time); - if (units->temperature == FAHRENHEIT) + if (units->temperature == FAHRENHEIT) { val = val * 9.0 / 5.0 + 32.0; + /* Prevents the display of -0F */ + if (round && (val > -0.5 && val < 0)) + val = val + 0.5; + } return g_strdup_printf(ROUND_TO_INT("%.1f"), val); case CLOUDS_LOW: -- 2.1.0