[Xfce4-commits] <xfce4-weather-plugin:master> Unit conversion: Convert altitude.
Harald Judt
noreply at xfce.org
Wed Jul 4 18:30:10 CEST 2012
Updating branch refs/heads/master
to c91a9b1ae3df6397ff119bc10de7c967499c7521 (commit)
from 8f482b8ac315fb9d190a651fca8c3a79c57a1115 (commit)
commit c91a9b1ae3df6397ff119bc10de7c967499c7521
Author: Harald Judt <h.judt at gmx.at>
Date: Wed Jul 4 18:26:02 2012 +0200
Unit conversion: Convert altitude.
For the imperial system convert altitude from meter to feet.
panel-plugin/weather-data.c | 8 ++++++--
1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/panel-plugin/weather-data.c b/panel-plugin/weather-data.c
index 18448b5..9a9a5eb 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -52,7 +52,11 @@ get_data (xml_time *timeslice, units unit, datas type)
switch(type) {
case ALTITUDE:
- return CHK_NULL(loc->altitude);
+ if (unit == METRIC)
+ return LOCALE_DOUBLE(loc->altitude, "%.0f");
+ val = g_ascii_strtod(loc->altitude, NULL);
+ val /= 0.3048;
+ return g_strdup_printf("%.2f", val);
case LATITUDE:
return LOCALE_DOUBLE(loc->latitude, "%.4f");
case LONGITUDE:
@@ -124,7 +128,7 @@ get_unit (xml_time *timeslice, units unit, datas type)
switch(type) {
case ALTITUDE:
- return "m";
+ return (unit == IMPERIAL) ? _("ft") : _("m");
case TEMPERATURE:
return (unit == IMPERIAL) ? _("°F") : _("°C");
case PRESSURE:
More information about the Xfce4-commits
mailing list