week-view: use the correct inclusive end date

Event dates are, by definition, inclusive on their
start dates, but exclusives on their end dates. That
means that end dates don't actually contain the date
they represent.

Week grid code, however, was considering that end date
as inclusive, and the layout code was miscalculated
because of that.

Fix that by using an inclusive end date when calculating
the event span. Since Calendar does not support subsecond
precision, we do that by subtracting one second from the
exclusive end date.

Issue: #279
This commit is contained in:
Georges Basile Stavracas Neto
2018-05-01 18:50:27 -03:00
parent 93b22f2c43
commit d272bbe3c8
+4 -5
View File
@@ -152,11 +152,12 @@ get_event_range (GcalWeekGrid *self,
if (end)
{
GDateTime *event_end;
g_autoptr (GDateTime) inclusive_end_date = NULL;
g_autoptr (GDateTime) event_end = NULL;
gboolean event_end_dst;
event_end = g_date_time_to_local (gcal_event_get_date_end (event));
inclusive_end_date = g_date_time_add_seconds (gcal_event_get_date_end (event), -1);
event_end = g_date_time_to_local (inclusive_end_date);
event_end_dst = g_date_time_is_daylight_savings (event_end);
diff = g_date_time_difference (event_end, week_start);
@@ -171,8 +172,6 @@ get_event_range (GcalWeekGrid *self,
*/
if (start && *start == *end)
*end = *end + 1;
g_clear_pointer (&event_end, g_date_time_unref);
}
g_clear_pointer (&week_start, g_date_time_unref);