[gnome-calendar] event: If no end date is given, make the event be all_day explicitly



commit ace87328a9357f87ee75316a0fa75054d18e155a
Author: Iain Lane <iain orangesquash org uk>
Date:   Tue Mar 8 10:12:19 2016 +0000

    event: If no end date is given, make the event be all_day explicitly
    
    Previously we were synthesising an end date of "start + 1 day", but this
    isn't necessary. RFC 2445 tells us that no end date already means an all
    day event.
    
    Check this case directly.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=762985

 src/gcal-event.c |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/src/gcal-event.c b/src/gcal-event.c
index a3916c2..9cc61a8 100644
--- a/src/gcal-event.c
+++ b/src/gcal-event.c
@@ -197,9 +197,9 @@ gcal_event_set_component_internal (GcalEvent     *self,
       ECalComponentDateTime end;
       icaltimetype date;
       GDateTime *date_start;
-      GTimeZone *zone_start;
+      GTimeZone *zone_start = NULL;
       GDateTime *date_end;
-      GTimeZone *zone_end;
+      GTimeZone *zone_end = NULL;
       gboolean start_is_all_day, end_is_all_day;
       gchar *description;
 
@@ -225,23 +225,26 @@ gcal_event_set_component_internal (GcalEvent     *self,
 
       if(!end.value)
         {
-          end = start;
-          end.value->day = start.value->day + 1;
+            self->all_day = TRUE;
         }
+      else
+        {
+          date = icaltime_normalize (*end.value);
+          zone_end = get_timezone_from_ical (&end);
+          date_end = g_date_time_new (zone_end,
+                                      date.year, date.month, date.day,
+                                      date.is_date ? 0 : date.hour,
+                                      date.is_date ? 0 : date.minute,
+                                      date.is_date ? 0 : date.second);
+          end_is_all_day = datetime_is_date (date_end);
 
-      date = icaltime_normalize (*end.value);
-      zone_end = get_timezone_from_ical (&end);
-      date_end = g_date_time_new (zone_end,
-                                  date.year, date.month, date.day,
-                                  date.is_date ? 0 : date.hour,
-                                  date.is_date ? 0 : date.minute,
-                                  date.is_date ? 0 : date.second);
-      end_is_all_day = datetime_is_date (date_end);
+          self->dt_end = g_date_time_ref (date_end);
 
-      self->dt_end = g_date_time_ref (date_end);
+          /* Setup all day */
+          self->all_day = start_is_all_day && end_is_all_day;
 
-      /* Setup all day */
-      self->all_day = start_is_all_day && end_is_all_day;
+          e_cal_component_free_datetime (&end);
+        }
 
       /* Setup description */
       description = get_desc_from_component (component, "\n\n");
@@ -258,8 +261,7 @@ gcal_event_set_component_internal (GcalEvent     *self,
       g_clear_pointer (&zone_end, g_time_zone_unref);
       g_clear_pointer (&description, g_free);
 
-      e_cal_component_free_datetime(&start);
-      e_cal_component_free_datetime(&end);
+      e_cal_component_free_datetime (&start);
     }
 }
 


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