week-header: don't account first weekday twice

The auxiliary functions to calculate the week start
already takes the first weekday into account. We,
however, were considering it again when calculating
the event position.

Fix that by only considering it once, through the
get_start_of_week() function.

https://bugzilla.gnome.org/show_bug.cgi?id=780051
This commit is contained in:
Georges Basile Stavracas Neto
2017-03-14 20:27:32 -03:00
parent 0dcf86b7c2
commit f608f8fd9d
+2 -4
View File
@@ -1608,13 +1608,11 @@ gcal_week_header_add_event (GcalWeekHeader *self,
g_autoptr (GDateTime) week_start = NULL;
g_autoptr (GDateTime) week_end = NULL;
gboolean all_day;
gint first_weekday;
gint start, end;
g_return_if_fail (GCAL_IS_WEEK_HEADER (self));
all_day = gcal_event_get_all_day (event);
first_weekday = get_first_weekday ();
week_start = get_start_of_week (self->active_date);
week_end = get_end_of_week (self->active_date);
@@ -1632,13 +1630,13 @@ gcal_week_header_add_event (GcalWeekHeader *self,
/* Start position */
if (datetime_compare_date (start_date, week_start) >= 0)
start = g_date_time_get_day_of_week (start_date) % 7 + first_weekday;
start = g_date_time_get_day_of_week (start_date) % 7;
else
start = 0;
/* End position */
if (g_date_time_compare (end_date, week_end) <= 0)
end = (g_date_time_get_day_of_week (end_date) - all_day) % 7 + first_weekday;
end = (g_date_time_get_day_of_week (end_date) - all_day) % 7;
else
end = 6;