This is an automated email from the git hooks/post-receive script. hjudt pushed a commit to branch master in repository panel-plugins/xfce4-weather-plugin.
commit f872ecb906431f3ebd250a59248d536fccfca243 Author: CamelBackNotation <joshuah...@utexas.edu> Date: Fri Mar 6 15:55:24 2015 -0600 Remove negative sign when temperature is rounded to 0 °F (bug #11604) --- panel-plugin/weather-data.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c index 3728199..d54e481 100644 --- a/panel-plugin/weather-data.c +++ b/panel-plugin/weather-data.c @@ -44,6 +44,15 @@ #define ROUND_TO_INT(default_format) (round ? "%.0f" : default_format) +/* Converts temperatures in Celcius to Fahrenheit while preventing + * negative values rounded to zero from being displayed as "-0 °F". */ +#define CALC_FAHRENHEIT(round, temperature) \ +do { \ + temperature = temperature * 9.0 / 5.0 + 32; \ + if (round && temperature > -0.5 && temperature < 0) \ + temperature = 0; \ +} while (0) + #define LOCALE_DOUBLE(value, format) \ (value \ ? g_strdup_printf(format, g_ascii_strtod(value, NULL)) \ @@ -344,7 +353,7 @@ get_data(const xml_time *timeslice, case TEMPERATURE: /* source is in °C */ val = string_to_double(loc->temperature_value, 0); if (units->temperature == FAHRENHEIT) - val = val * 9.0 / 5.0 + 32.0; + CALC_FAHRENHEIT(round, val); return g_strdup_printf(ROUND_TO_INT("%.1f"), val); case PRESSURE: /* source is in hectopascals */ @@ -398,14 +407,14 @@ get_data(const xml_time *timeslice, if (val == INVALID_VALUE) return g_strdup(""); if (units->temperature == FAHRENHEIT) - val = val * 9.0 / 5.0 + 32.0; + CALC_FAHRENHEIT(round, val); 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) - val = val * 9.0 / 5.0 + 32.0; + CALC_FAHRENHEIT(round, val); return g_strdup_printf(ROUND_TO_INT("%.1f"), val); case CLOUDS_LOW: -- To stop receiving notification emails like this one, please contact the administrator of this repository. _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org https://mail.xfce.org/mailman/listinfo/xfce4-commits