[libgweather/wip/hadess/fix-utc-sunrise: 31/32] weather: Consider moon phases to not be available for named timezones



commit e9da48dbb9d8636ff086d8fd3f06bb81d9d9b968
Author: Bastien Nocera <hadess hadess net>
Date:   Mon Oct 8 12:27:14 2018 +0200

    weather: Consider moon phases to not be available for named timezones
    
    Don't return a moon phase that's marked as valid for GWeatherLocations
    without a valid long/lat.

 libgweather/test_libgweather.c | 7 +++++++
 libgweather/weather-moon.c     | 3 +++
 2 files changed, 10 insertions(+)
---
diff --git a/libgweather/test_libgweather.c b/libgweather/test_libgweather.c
index ba69941..11a594c 100644
--- a/libgweather/test_libgweather.c
+++ b/libgweather/test_libgweather.c
@@ -387,6 +387,9 @@ test_utc_sunset (void)
        GWeatherLocation *world, *utc;
        GWeatherInfo *info;
        char *sunset;
+       GWeatherMoonPhase phase;
+       GWeatherMoonLatitude lat;
+       gboolean ret;
 
        world = gweather_location_get_world ();
        g_assert_nonnull (world);
@@ -399,6 +402,10 @@ test_utc_sunset (void)
 
        sunset = gweather_info_get_sunset (info);
        g_assert_nonnull (sunset);
+       g_free (sunset);
+
+       ret = gweather_info_get_value_moonphase (info, &phase, &lat);
+       g_assert_false (ret);
 }
 
 static void
diff --git a/libgweather/weather-moon.c b/libgweather/weather-moon.c
index 993cdff..01466b1 100644
--- a/libgweather/weather-moon.c
+++ b/libgweather/weather-moon.c
@@ -141,6 +141,9 @@ _gweather_info_ensure_moon (GWeatherInfo *info)
 
     priv = info->priv;
 
+    if (!info->priv->location.latlon_valid)
+        return;
+
     if (!priv->moonValid)
        priv->moonValid = calc_moon_internal (priv->current_time,
                                              &priv->moonphase,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]