This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository enlightenment-module-forecasts.

View the commit online.

commit 43c2d24635281f155ea398a6228512b8cf1481cc
Author: Alastair Poole <nets...@gmail.com>
AuthorDate: Wed Apr 23 21:25:31 2025 +0100

    bug: Ensure we don't display out of range data.
    
    The question is why is it not valid on some machines.
    
    Will investigate. Sorry for taking so long thrice.
---
 src/e_mod_main.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/src/e_mod_main.c b/src/e_mod_main.c
index c47b36e..dad4607 100644
--- a/src/e_mod_main.c
+++ b/src/e_mod_main.c
@@ -8,6 +8,9 @@ char *strptime(const char *s, const char *format, struct tm *tm);
 #define KM_TO_MI     1.609344
 #define MB_TO_IN     33.864
 
+#define TEMP_MIN_OUT_OF_RANGE -237.15
+#define TEMP_MAX_OUT_OF_RANGE 190.0
+
 #define GOLDEN_RATIO 1.618033989
 
 #define ENABLE_DEBUG 0
@@ -623,8 +626,8 @@ _forecasts_parse(void *data)
 
    for (int i = 0; i < FORECASTS; i++)
      {
-        inst->forecast[i].high = -237.15;
-        inst->forecast[i].low =  190.0;
+        inst->forecast[i].high = TEMP_MIN_OUT_OF_RANGE;
+        inst->forecast[i].low =  TEMP_MAX_OUT_OF_RANGE;
      }
    now = time(NULL);
    tm_local = localtime(&now);
@@ -703,7 +706,7 @@ _forecasts_parse(void *data)
              v *= 3.6;
              inst->details.wind.speed = v;
 
-             if (inst->condition.temp <= 10.0)
+             if (inst->condition.temp <= 10.0 && (inst->condition.temp != TEMP_MIN_OUT_OF_RANGE))
                {
                   double t, vpow;
                   t = inst->condition.temp;
@@ -843,11 +846,17 @@ _forecasts_display_set(Instance *inst, int ok EINA_UNUSED)
              edje_object_part_text_set(inst->forecasts->forecasts_obj, name, inst->forecast[i].desc);
 
              snprintf(name, sizeof(name), "e.text.day%d.high", i);
-             snprintf(buf, sizeof(buf), "%d°%c", inst->forecast[i].high, inst->units.temp);
+             if (inst->forecast[i].high != TEMP_MAX_OUT_OF_RANGE)
+               snprintf(buf, sizeof(buf), "%d°%c", inst->forecast[i].high, inst->units.temp);
+             else
+               snprintf(buf, sizeof(buf), "N/A");
              edje_object_part_text_set(inst->forecasts->forecasts_obj, name, buf);
 
              snprintf(name, sizeof(name), "e.text.day%d.low", i);
-             snprintf(buf, sizeof(buf), "%d°%c", inst->forecast[i].low, inst->units.temp);
+             if (inst->forecast[i].low != TEMP_MIN_OUT_OF_RANGE)
+               snprintf(buf, sizeof(buf), "%d°%c", inst->forecast[i].low, inst->units.temp);
+             else
+               snprintf(buf, sizeof(buf), "N/A");
              edje_object_part_text_set(inst->forecasts->forecasts_obj, name, buf);
 
              snprintf(name, sizeof(name), "e.swallow.day%d.icon", i);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to