[Xfce4-commits] <xfce4-weather-plugin:master> Unit conversion: Convert wind speed.
Harald Judt
noreply at xfce.org
Wed Jul 4 18:30:07 CEST 2012
Updating branch refs/heads/master
to 22d07eca6de609a5c1f062787431806456f1233f (commit)
from e95ef85f242c6ce778e698b8cf60587daf1bf9ba (commit)
commit 22d07eca6de609a5c1f062787431806456f1233f
Author: Harald Judt <h.judt at gmx.at>
Date: Wed Jul 4 18:14:12 2012 +0200
Unit conversion: Convert wind speed.
Convert meter per second into kilometer per hour (metric system)
or miles per hour (imperial system).
panel-plugin/weather-data.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index f8ebe66..a162c59 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -70,7 +70,12 @@ get_data (xml_time *timeslice, units unit, datas type)
case PRESSURE:
return LOCALE_DOUBLE(loc->pressure_value, "%.1f");
case WIND_SPEED:
- return LOCALE_DOUBLE(loc->wind_speed_mps, "%.1f");
+ val = g_ascii_strtod(loc->wind_speed_mps, NULL);
+ if (unit == IMPERIAL)
+ val *= 2.2369362920544;
+ else if (unit == METRIC)
+ val *= 3.6;
+ return g_strdup_printf("%.1f", val);
case WIND_BEAUFORT:
return CHK_NULL(loc->wind_speed_beaufort);
case WIND_DIRECTION:
@@ -115,7 +120,7 @@ get_unit (xml_time *timeslice, units unit, datas type)
case PRESSURE:
return (loc->pressure_unit) ? loc->pressure_unit : "";
case WIND_SPEED:
- return "m/s";
+ return (unit == IMPERIAL) ? _("mph") : _("km/h");
case WIND_DIRECTION_DEG:
case LATITUDE:
case LONGITUDE:
More information about the Xfce4-commits
mailing list