From 15d7c69d94b77add6c2e234ac14047db0771e2eb Mon Sep 17 00:00:00 2001 From: Francis Lachapelle Date: Mon, 16 Dec 2019 10:48:26 -0500 Subject: [PATCH] fix(calendar): adjust invalid dates when importing a vEvent Fixes #4845 --- SoObjects/Appointments/iCalEvent+SOGo.m | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/SoObjects/Appointments/iCalEvent+SOGo.m b/SoObjects/Appointments/iCalEvent+SOGo.m index 15509f86d..79983fc57 100644 --- a/SoObjects/Appointments/iCalEvent+SOGo.m +++ b/SoObjects/Appointments/iCalEvent+SOGo.m @@ -475,7 +475,7 @@ [self setStartDate: date]; } startDate = (iCalDateTime *) [self uniqueChildWithTag: @"dtstart"]; - [self errorWithFormat: @"Fixed event with no start date; setting start date to %@ for UID %@", [startDate dateTime], [self uid]]; + [self errorWithFormat: @"Event with no start date; setting start date to %@ for UID %@", [startDate dateTime], [self uid]]; } if ([startDate dateTime]) @@ -488,8 +488,9 @@ else { startDateAsString = [[startDate valuesAtIndex: 0 forKey: @""] objectAtIndex: 0]; - if (![startDateAsString hasSuffix: @"Z"] && - ![startDateAsString hasSuffix: @"z"]) + if (!([self isAllDay] || + [startDateAsString hasSuffix: @"Z"] || + [startDateAsString hasSuffix: @"z"])) { // The start date is a "floating time", let's use the user's timezone // for both the start and end dates. @@ -499,11 +500,13 @@ [self setStartDate: [[self startDate] dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: -delta]]; [startDate setTimeZone: timezone]; + [self errorWithFormat: @"Event with no timezone; setting timezone %@ to start date for UID %@", [timezone tzId], [self uid]]; if ([endDate dateTime]) { [self setEndDate: [[self endDate] dateByAddingYears: 0 months: 0 days: 0 hours: 0 minutes: 0 seconds: -delta]]; [endDate setTimeZone: timezone]; + [self errorWithFormat: @"Event with no timezone; setting timezone %@ to end date for UID %@", [timezone tzId], [self uid]]; } } } @@ -517,7 +520,7 @@ else [self setDuration: @"PT1H"]; - [self errorWithFormat: @"Fixed event with no end date; setting duration to %@ for UID %@", [self duration], [self uid]]; + [self errorWithFormat: @"Event with no end date; setting duration to %@ for UID %@", [self duration], [self uid]]; } // @@ -530,7 +533,7 @@ if ([self isAllDay] && [[self startDate] isEqual: [self endDate]]) { [self setEndDate: [[self startDate] dateByAddingYears: 0 months: 0 days: 1 hours: 0 minutes: 0 seconds: 0]]; - [self errorWithFormat: @"Fixed broken all-day event; setting end date to %@ for UID %@", [self endDate], [self uid]]; + [self errorWithFormat: @"Broken all-day event; setting end date to %@ for UID %@", [self endDate], [self uid]]; }