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.
This commit is contained in:
Georges Basile Stavracas Neto
2017-03-05 20:31:34 -03:00
parent 1d8993d450
commit 0d27d36218
+5 -1
View File
@@ -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);