diff --git a/plugins/libkolab/lib/kolab_format_task.php b/plugins/libkolab/lib/kolab_format_task.php index 46408754..cb35f98d 100644 --- a/plugins/libkolab/lib/kolab_format_task.php +++ b/plugins/libkolab/lib/kolab_format_task.php @@ -116,6 +116,20 @@ class kolab_format_task extends kolab_format_xcal return $this->data; } + /** + * Return the reference date for recurrence and alarms + * + * @return mixed DateTime instance of null if no refdate is available + */ + public function get_reference_date() + { + if ($this->data['due'] && $this->data['due'] instanceof DateTime) { + return $this->data['due']; + } + + return self::php_datetime($this->obj->due()) ?: parent::get_reference_date(); + } + /** * Callback for kolab_storage_cache to get object specific tags to cache * diff --git a/plugins/libkolab/lib/kolab_format_xcal.php b/plugins/libkolab/lib/kolab_format_xcal.php index 8c63b263..e7d1122a 100644 --- a/plugins/libkolab/lib/kolab_format_xcal.php +++ b/plugins/libkolab/lib/kolab_format_xcal.php @@ -184,7 +184,10 @@ abstract class kolab_format_xcal extends kolab_format $object['recurrence']['COUNT'] = $count; } else if ($until = self::php_datetime($rr->end())) { - $until->setTime($object['start']->format('G'), $object['start']->format('i'), 0); + $refdate = $this->get_reference_date(); + if ($refdate && $refdate instanceof DateTime && !$refdate->_dateonly) { + $until->setTime($refdate->format('G'), $refdate->format('i'), 0); + } $object['recurrence']['UNTIL'] = $until; } @@ -567,6 +570,20 @@ abstract class kolab_format_xcal extends kolab_format $this->set_attachments($object); } + /** + * Return the reference date for recurrence and alarms + * + * @return mixed DateTime instance of null if no refdate is available + */ + public function get_reference_date() + { + if ($this->data['start'] && $this->data['start'] instanceof DateTime) { + return $this->data['start']; + } + + return self::php_datetime($this->obj->start()); + } + /** * Callback for kolab_storage_cache to get words to index for fulltext search *