[gnome-calendar] quick-add-popover: fix single all-day events



commit 653fb86d16c408ae9a8942eb3064dc79384b132d
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Sep 28 01:02:45 2016 -0300

    quick-add-popover: fix single all-day events

 src/gcal-quick-add-popover.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/gcal-quick-add-popover.c b/src/gcal-quick-add-popover.c
index 3596038..b85d4c6 100644
--- a/src/gcal-quick-add-popover.c
+++ b/src/gcal-quick-add-popover.c
@@ -415,7 +415,7 @@ edit_or_create_event (GcalQuickAddPopover *self,
   GcalEvent *event;
   ESource *source;
   const gchar *summary;
-  gboolean all_day;
+  gboolean all_day, single_day, is_today;
 
   if (!self->selected_row)
     return;
@@ -427,8 +427,9 @@ edit_or_create_event (GcalQuickAddPopover *self,
    * We consider all day events multiday and/or non-today events.
    * Events on today starts now and lasts 1 hour.
    */
-  all_day = datetime_compare_date (self->date_end, self->date_start) > 1 ||
-            datetime_compare_date (now, self->date_start) != 0;
+  single_day = datetime_compare_date (self->date_end, self->date_start) == 0;
+  is_today = single_day && datetime_compare_date (now, self->date_start) == 0;
+  all_day = datetime_compare_date (self->date_end, self->date_start) > 1 || !is_today;
 
   tz = all_day ? g_time_zone_new_utc () : g_time_zone_new_local ();
 
@@ -447,14 +448,14 @@ edit_or_create_event (GcalQuickAddPopover *self,
       date_end = g_date_time_new (tz,
                                   g_date_time_get_year (self->date_end),
                                   g_date_time_get_month (self->date_end),
-                                  g_date_time_get_day_of_month (self->date_end),
-                                  all_day ? 0 : g_date_time_get_hour (now) + 1,
+                                  g_date_time_get_day_of_month (self->date_end)+ (all_day ? 1 : 0),
+                                  all_day ? 0 : g_date_time_get_hour (now) + (is_today ? 1 : 0),
                                   all_day ? 0 : g_date_time_get_minute (now),
                                   all_day ? 0 : g_date_time_get_second (now));
     }
   else
     {
-      date_end = g_date_time_add_hours (date_start, 1);
+      date_end = all_day ? g_date_time_add_days (date_start, 1) : g_date_time_add_hours (date_start, 1);
     }
 
   /* Gather the summary */


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