[gnome-calendar] window: correctly subscribe the week view



commit 0d27d36218aca0dde8e73db3c59bf87877e2c43e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Mar 5 20:31:34 2017 -0300

    window: correctly subscribe the week view
    
    The week view was being subscribed to the wrong dates,
    because the window was miscalculating the start of week
    on sundays.
    
    Fix that by properly calculating the start of week offset.

 src/gcal-window.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-window.c b/src/gcal-window.c
index 8548f06..d4ed8df 100644
--- a/src/gcal-window.c
+++ b/src/gcal-window.c
@@ -414,8 +414,12 @@ update_active_date (GcalWindow   *window,
       !g_date_valid (&old_week) ||
       g_date_get_iso8601_week_of_year (&old_week) != g_date_get_iso8601_week_of_year (&new_week))
     {
+      gint offset;
+
+      offset = g_date_time_get_day_of_week (date_start) % 7 + get_first_weekday ();
+
       date_start = g_date_time_new_local (new_date->year, new_date->month, new_date->day, 0, 0, 0);
-      date_start = g_date_time_add_days (date_start, (get_first_weekday () - g_date_time_get_day_of_week 
(date_start) + 7) % 7 - 7);
+      date_start = g_date_time_add_days (date_start, offset);
       range_start = g_date_time_to_unix (date_start);
 
       date_end = g_date_time_add_days (date_start, 7);


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