[gnome-calendar/wip/flb/weather-forecast: 37/50] weather: Change the way I calculate begin-of-day



commit 1503837416e331fbe9dc78c692895b718525bc76
Author: Florian Brosch <flo brosch gmail com>
Date:   Mon Oct 23 22:39:27 2017 +0200

    weather: Change the way I calculate begin-of-day

 src/gcal-weather-service.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/src/gcal-weather-service.c b/src/gcal-weather-service.c
index 92ae97b..c584e77 100644
--- a/src/gcal-weather-service.c
+++ b/src/gcal-weather-service.c
@@ -654,25 +654,25 @@ get_time_day_start (GcalWeatherService *self,
                     gint64             *ret_unix,
                     gint64             *ret_unix_exact)
 {
+  g_autoptr (GTimeZone) zone = NULL;
   g_autoptr (GDateTime) now = NULL;
   g_autoptr (GDateTime) day = NULL;
 
-
   g_return_val_if_fail (self != NULL, FALSE);
   g_return_val_if_fail (ret_date != NULL, FALSE);
   g_return_val_if_fail (ret_unix != NULL, FALSE);
   g_return_val_if_fail (ret_unix_exact != NULL, FALSE);
 
-  now = (self->time_zone == NULL)
-          ? g_date_time_new_now_local ()
-          : g_date_time_new_now (self->time_zone);
-  day = g_date_time_add_full (now,
-                              0, /* years */
-                              0, /* months */
-                              0, /* days */
-                              - g_date_time_get_hour (now),
-                              - g_date_time_get_minute (now),
-                              - g_date_time_get_seconds (now));
+  zone = (self->time_zone == NULL)
+          ? g_time_zone_new_local ()
+          : g_time_zone_ref (self->time_zone);
+
+  now = g_date_time_new_now (zone);
+  day = g_date_time_new (zone,
+                         g_date_time_get_year (now),
+                         g_date_time_get_month (now),
+                         g_date_time_get_day_of_month (now),
+                         0, 0, 0);
 
   g_date_set_dmy (ret_date,
                   g_date_time_get_day_of_month (day),


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