MDL-54607 calendar: Export 0 duration events properly
Thanks to Paul Prencis for initial suggestion of this patch
This commit is contained in:
@@ -214,10 +214,14 @@ foreach($events as $event) {
|
||||
//dtend is better than duration, because it works in Microsoft Outlook and works better in Korganizer
|
||||
$ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->timestart)); // when event starts.
|
||||
$ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart + $event->timeduration));
|
||||
} else if ($event->timeduration == 0) {
|
||||
// When no duration is present, the event is instantaneous event, ex - Due date of a module.
|
||||
// Moodle doesn't support all day events yet. See MDL-56227.
|
||||
$ev->add_property('dtstart', Bennu::timestamp_to_datetime($event->timestart));
|
||||
$ev->add_property('dtend', Bennu::timestamp_to_datetime($event->timestart));
|
||||
} else {
|
||||
// When no duration is present, ie an all day event, VALUE should be date instead of time and dtend = dtstart + 1 day.
|
||||
$ev->add_property('dtstart', Bennu::timestamp_to_date($event->timestart), array('value' => 'DATE')); // All day event.
|
||||
$ev->add_property('dtend', Bennu::timestamp_to_date($event->timestart + DAYSECS), array('value' => 'DATE')); // All day event.
|
||||
// This can be used to represent all day events in future.
|
||||
throw new coding_exception("Negative duration is not supported yet.");
|
||||
}
|
||||
if ($event->courseid != 0) {
|
||||
$coursecontext = context_course::instance($event->courseid);
|
||||
|
||||
+2
-1
@@ -3017,7 +3017,8 @@ function calendar_add_icalendar_event($event, $courseid, $subscriptionid, $timez
|
||||
// Check to see if the event started at Midnight on the imported calendar.
|
||||
date_default_timezone_set($timezone);
|
||||
if (date('H:i:s', $eventrecord->timestart) === "00:00:00") {
|
||||
// This event should be an all day event.
|
||||
// This event should be an all day event. This is not correct, we don't do anything differently for all day events.
|
||||
// See MDL-56227.
|
||||
$eventrecord->timeduration = 0;
|
||||
}
|
||||
core_date::set_default_server_timezone();
|
||||
|
||||
Reference in New Issue
Block a user