-
Notifications
You must be signed in to change notification settings - Fork 167
Incorrect ical format #181
Description
When exporting a calendar from x2crm, the ical format produced is incorrect. Here are 3 issues I've come across:
-
Calendar Actions are single day events -- they should not span multiple days. However they seem to use the completeDate field as the end date, which is not updated appropriately. Recommendation is for Actions to use the dueDate field for the end date.
-
All Day Events are not respected in the ical file because the formatting is incorrect. Recommendation is that all day events should only have the 'Ymd' format, and not include the time ('His'). Additionally, multi-all-day events require the end date to be one day later.
-
Calendar Actions include mandatory Subject fields that are not reported in the ical. Recommendation is to place the subject in the SUBJECT field and move the description to the DESCRIPTION field.
Here are my recommended code modifcations for render() in /components/Ical.php:
$start = new DateTime();
$end = new DateTime();
$tzOb = new DateTimeZone($tz);
$start->setTimestamp($action->dueDate);
$end->setTimestamp((isset($action->type) && $action->type == 'event') ? $action->completeDate : $action->dueDate);
$start->setTimezone($tzOb);
$end->setTimezone($tzOb);
$allDay = isset($action->allDay) && $action->allDay == 1 ? true : false;
echo "DTSTART;TZID=$tz:".$start->format($allDay?'Ymd':'Ymd\THis')."\r\n";
echo "DTEND;TZID=$tz:".$end->add(new DateInterval($allDay?'P1D':'P0D'))->format($allDay?'Ymd':'Ymd\THis')."\r\n";
echo "SUMMARY:".self::escapeText(!empty($action->subject) ? $action->subject : $action->actionText->text)."\r\n";
echo "DESCRIPTION:".self::escapeText(!empty($action->subject) ? $action->actionText->text : '')."\r\n";
echo "END:VEVENT\r\n";