From 0d27d36218aca0dde8e73db3c59bf87877e2c43e Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sun, 5 Mar 2017 20:31:34 -0300 Subject: [PATCH] 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 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/gcal-window.c b/src/gcal-window.c index 8548f069..d4ed8df9 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);