[gnome-calendar] edit-dialog: fake inclusive end date for all-day events



commit 46a05e5d00ec0430daae2ad19f5f5e07fb730715
Author: Ernestas Kulik <ernestask src gnome org>
Date:   Tue Aug 2 00:35:39 2016 +0300

    edit-dialog: fake inclusive end date for all-day events
    
    Currently, all-day multi-day events are displayed inconsistently with
    regard to other calendar applications. That is due to strict following
    of RFC 5545, which mandates non-inclusive all-day multi-day event end
    dates. This commit makes the edit dialog display a faked date for such
    events.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=769300

 src/gcal-edit-dialog.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)
---
diff --git a/src/gcal-edit-dialog.c b/src/gcal-edit-dialog.c
index 435c03a..777bb18 100644
--- a/src/gcal-edit-dialog.c
+++ b/src/gcal-edit-dialog.c
@@ -595,6 +595,19 @@ gcal_edit_dialog_action_button_clicked (GtkWidget *widget,
       start_date = gcal_edit_dialog_get_date_start (dialog);
       end_date = gcal_edit_dialog_get_date_end (dialog);
 
+      /*
+       * The end date for multi-day events is exclusive, so we bump it by a day.
+       * This fixes the discrepancy between the end day of the event and how it
+       * is displayed in the month view. See bug 769300.
+       */
+      if (all_day)
+        {
+          GDateTime *fake_end_date = g_date_time_add_days (end_date, 1);
+
+          g_clear_pointer (&end_date, g_date_time_unref);
+          end_date = fake_end_date;
+        }
+
       gcal_event_set_date_start (dialog->event, start_date);
       gcal_event_set_date_end (dialog->event, end_date);
 
@@ -1051,7 +1064,11 @@ gcal_edit_dialog_set_event (GcalEditDialog *dialog,
       date_start = all_day ? g_date_time_ref (date_start) : g_date_time_to_local (date_start);
 
       date_end = gcal_event_get_date_end (event);
-      date_end = all_day ? g_date_time_ref (date_end) : g_date_time_to_local (date_end);
+      /*
+       * This is subtracting what has been added in gcal_edit_dialog_action_button_clicked ().
+       * See bug 769300.
+       */
+      date_end = all_day ? g_date_time_add_days (date_end, -1) : g_date_time_to_local (date_end);
 
       /* date */
       gcal_date_selector_set_date (GCAL_DATE_SELECTOR (dialog->start_date_selector), date_start);


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