aboutsummaryrefslogtreecommitdiffstats
path: root/my-evolution/metar.c
diff options
context:
space:
mode:
authorIain Holmes <iain@src.gnome.org>2001-06-30 02:34:53 +0800
committerIain Holmes <iain@src.gnome.org>2001-06-30 02:34:53 +0800
commitc470087c9b5663a64c338fadee3594d261ab65f3 (patch)
tree39f601455981886c8c21bfcc2fed03ac56bd7624 /my-evolution/metar.c
parente64a02be08f27b9a403de2bdf147626b8c8f2523 (diff)
downloadgsoc2013-evolution-c470087c9b5663a64c338fadee3594d261ab65f3.tar
gsoc2013-evolution-c470087c9b5663a64c338fadee3594d261ab65f3.tar.gz
gsoc2013-evolution-c470087c9b5663a64c338fadee3594d261ab65f3.tar.bz2
gsoc2013-evolution-c470087c9b5663a64c338fadee3594d261ab65f3.tar.lz
gsoc2013-evolution-c470087c9b5663a64c338fadee3594d261ab65f3.tar.xz
gsoc2013-evolution-c470087c9b5663a64c338fadee3594d261ab65f3.tar.zst
gsoc2013-evolution-c470087c9b5663a64c338fadee3594d261ab65f3.zip
Configure My Evolution
svn path=/trunk/; revision=10604
Diffstat (limited to 'my-evolution/metar.c')
-rw-r--r--my-evolution/metar.c63
1 files changed, 43 insertions, 20 deletions
diff --git a/my-evolution/metar.c b/my-evolution/metar.c
index 353593da79..ee99816e00 100644
--- a/my-evolution/metar.c
+++ b/my-evolution/metar.c
@@ -142,8 +142,15 @@ char *
weather_temp_string (Weather *w)
{
char *temp;
+ ESummaryWeatherUnits units;
- temp = g_strdup_printf ("%.1f%s", w->temp, TEMP_UNIT_STR (w->units));
+ if (w->summary->preferences == NULL) {
+ units = UNITS_METRIC;
+ } else {
+ units = w->summary->preferences->units;
+ }
+
+ temp = g_strdup_printf ("%.1f%s", w->temp, TEMP_UNIT_STR (units));
return temp;
}
@@ -437,12 +444,15 @@ metar_tok_pres (gchar *tokp,
static inline gint
calc_humidity(gdouble temp,
- gdouble dewp)
+ gdouble dewp,
+ ESummaryWeatherUnits units)
{
gdouble esat, esurf;
- temp = TEMP_F_TO_C(temp);
- dewp = TEMP_F_TO_C(dewp);
+ if (units == UNITS_IMPERIAL) {
+ temp = TEMP_F_TO_C(temp);
+ dewp = TEMP_F_TO_C(dewp);
+ }
esat = 6.11 * pow(10.0, (7.5 * temp) / (237.7 + temp));
esurf = 6.11 * pow(10.0, (7.5 * dewp) / (237.7 + dewp));
@@ -454,22 +464,35 @@ gboolean
metar_tok_temp (gchar *tokp,
Weather *w)
{
- gchar *ptemp, *pdew, *psep;
-
- if (regexec(&metar_re[TEMP_RE], tokp, 0, NULL, 0) == REG_NOMATCH)
- return FALSE;
-
- psep = strchr(tokp, '/');
- *psep = 0;
- ptemp = tokp;
- pdew = psep + 1;
-
- w->temp = (*ptemp == 'M') ? TEMP_C_TO_F(-atoi(ptemp+1)) :
- TEMP_C_TO_F(atoi(ptemp));
- w->dew = (*pdew == 'M') ? TEMP_C_TO_F(-atoi(pdew+1)) :
- TEMP_C_TO_F(atoi(pdew));
- w->humidity = calc_humidity(w->temp, w->dew);
- return TRUE;
+ ESummaryWeatherUnits units;
+ gchar *ptemp, *pdew, *psep;
+
+ if (regexec(&metar_re[TEMP_RE], tokp, 0, NULL, 0) == REG_NOMATCH)
+ return FALSE;
+
+ if (w->summary->preferences == NULL) {
+ units = UNITS_METRIC;
+ } else {
+ units = w->summary->preferences->units;
+ }
+
+ psep = strchr(tokp, '/');
+ *psep = 0;
+ ptemp = tokp;
+ pdew = psep + 1;
+
+ if (units == UNITS_IMPERIAL) {
+ w->temp = (*ptemp == 'M') ? TEMP_C_TO_F(-atoi(ptemp+1)) :
+ TEMP_C_TO_F(atoi(ptemp));
+ w->dew = (*pdew == 'M') ? TEMP_C_TO_F(-atoi(pdew+1)) :
+ TEMP_C_TO_F(atoi(pdew));
+ } else {
+ w->temp = (*ptemp == 'M') ? -atoi(ptemp+1) : atoi(ptemp);
+ w->dew = (*pdew == 'M') ? -atoi(pdew+1) : atoi (pdew);
+ }
+
+ w->humidity = calc_humidity(w->temp, w->dew, units);
+ return TRUE;
}
gboolean