From 3f4d11f68e5a66b9b9804b4fdaaeb8f4eab03f40 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 16 Feb 2016 10:39:37 +0900 Subject: [PATCH] event: normalize dates before applying them I don't know the reasoning behind it, but sometimes I see dates like March 32 or February 30. Events are correctly added, so I suspect it's an issue with another app. In any case, we should be able to handle weird dates without crashing, so normalize the dates before using them. --- src/gcal-event.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/gcal-event.c b/src/gcal-event.c index 937edb35..e60df488 100644 --- a/src/gcal-event.c +++ b/src/gcal-event.c @@ -181,6 +181,7 @@ gcal_event_set_component_internal (GcalEvent *self, { ECalComponentDateTime start; ECalComponentDateTime end; + icaltimetype normalized_date; GDateTime *date_start; GTimeZone *zone_start; GDateTime *date_end; @@ -191,8 +192,9 @@ gcal_event_set_component_internal (GcalEvent *self, /* Setup start date */ e_cal_component_get_dtstart (component, &start); + normalized_date = icaltime_normalize (*start.value); zone_start = get_timezone_from_ical (&start); - aux = icaltime_to_datetime (start.value); + aux = icaltime_to_datetime (&normalized_date); date_start = g_date_time_to_timezone (aux, zone_start); start_is_all_day = datetime_is_date (aux); @@ -205,8 +207,9 @@ gcal_event_set_component_internal (GcalEvent *self, /* Setup end date */ e_cal_component_get_dtend (component, &end); + normalized_date = icaltime_normalize (*end.value); zone_end = get_timezone_from_ical (&end); - aux = icaltime_to_datetime (end.value); + aux = icaltime_to_datetime (&normalized_date); date_end = g_date_time_to_timezone (aux, zone_end); end_is_all_day = datetime_is_date (aux);