[gnome-calendar] event-widget: advertise properly multiday status



commit 5a36689e070bc18ae22e510b7ffc580e3e1397e3
Author: Erick Pérez Castellanos <erick red gmail com>
Date:   Mon Dec 22 14:52:34 2014 -0500

    event-widget: advertise properly multiday status
    
    When an event is marked all day, the end-date is always one day ahead of
    the true end of the event, and both dates are marked as date. We need to
    take this into account.

 src/gcal-event-widget.c |   16 ++++++++++++++--
 1 files changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/src/gcal-event-widget.c b/src/gcal-event-widget.c
index e5736a2..8c3e016 100644
--- a/src/gcal-event-widget.c
+++ b/src/gcal-event-widget.c
@@ -29,7 +29,7 @@ typedef struct
   gchar         *summary;
   GdkRGBA       *color;
   icaltimetype  *dt_start;
-  icaltimetype  *dt_end;
+  icaltimetype  *dt_end; /* could be NULL, meaning dt_end is the same as start_date */
   gboolean       all_day;
   gboolean       has_reminders;
 
@@ -1034,12 +1034,24 @@ gboolean
 gcal_event_widget_is_multiday (GcalEventWidget *event)
 {
   GcalEventWidgetPrivate *priv;
+
+  gint start_day_of_year, end_day_of_year;
   priv = gcal_event_widget_get_instance_private (event);
 
   if (priv->dt_end == NULL)
     return FALSE;
 
-  return priv->dt_start->day != priv->dt_end->day;
+  start_day_of_year = icaltime_day_of_year (*(priv->dt_start));
+  end_day_of_year = icaltime_day_of_year (*(priv->dt_end));
+
+  if (priv->all_day && start_day_of_year + 1 == end_day_of_year)
+    return FALSE;
+
+  if (priv->all_day && start_day_of_year == icaltime_days_in_year (priv->dt_start->year) && end_day_of_year 
== 1 &&
+      priv->dt_start->year + 1 == priv->dt_end->year)
+    return FALSE;
+
+  return start_day_of_year != end_day_of_year;
 }
 
 void


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