[Xfce4-commits] <xfce4-weather-plugin:master> Unit conversion: Convert precipitation.

Harald Judt noreply at xfce.org
Wed Jul 4 18:30:09 CEST 2012


Updating branch refs/heads/master
         to 8f482b8ac315fb9d190a651fca8c3a79c57a1115 (commit)
       from 477b0fbffbe2b4a904712564e7f1de18c0543c2f (commit)

commit 8f482b8ac315fb9d190a651fca8c3a79c57a1115
Author: Harald Judt <h.judt at gmx.at>
Date:   Wed Jul 4 18:20:48 2012 +0200

    Unit conversion: Convert precipitation.
    
    For the imperial system convert precipitation from millimeter to
    inches.

 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 162ec66..18448b5 100644
--- a/panel-plugin/weather-data.c
+++ b/panel-plugin/weather-data.c
@@ -100,7 +100,12 @@ get_data (xml_time *timeslice, units unit, datas type)
 	case FOG:
 		return LOCALE_DOUBLE(loc->fog_percent, "%.1f");
 	case PRECIPITATIONS:
-		return LOCALE_DOUBLE(loc->precipitation_value, "%.1f");
+		if (unit == METRIC)
+			return LOCALE_DOUBLE(loc->precipitation_value, "%.1f");
+		val = g_ascii_strtod(loc->precipitation_value, NULL);
+		if (unit == IMPERIAL)
+			val /= 25.4;
+		return g_strdup_printf("%.3f", val);
 	case SYMBOL:
 		return CHK_NULL(loc->symbol);
 	}
@@ -138,7 +143,7 @@ get_unit (xml_time *timeslice, units unit, datas type)
 	case FOG:
 		return "%";
 	case PRECIPITATIONS:
-		return "mm";
+		return (unit == IMPERIAL) ? _("in") : _("mm");
 	case SYMBOL:
 	case WIND_BEAUFORT:
 	case WIND_DIRECTION:


More information about the Xfce4-commits mailing list