Changeset View
Changeset View
Standalone View
Standalone View
plugins/libcalendaring/lib/libcalendaring_recurrence.php
Show First 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | class libcalendaring_recurrence | ||||
/** | /** | ||||
* Get the end date of the occurence of this recurrence cycle | * Get the end date of the occurence of this recurrence cycle | ||||
* | * | ||||
* @return DateTime|bool End datetime of the last occurence or False if recurrence exceeds limit | * @return DateTime|bool End datetime of the last occurence or False if recurrence exceeds limit | ||||
*/ | */ | ||||
public function end() | public function end() | ||||
{ | { | ||||
// recurrence end date is given | // recurrence end date is given | ||||
if ($this->recurrence['UNTIL'] instanceof DateTime) { | if ($this->recurrence['UNTIL'] instanceof DateTime || $this->recurrence['UNTIL'] instanceof DateTimeImmutable) { | ||||
return $this->recurrence['UNTIL']; | return $this->recurrence['UNTIL']; | ||||
} | } | ||||
// take the last RDATE entry if set | // take the last RDATE entry if set | ||||
if (is_array($this->recurrence['RDATE']) && !empty($this->recurrence['RDATE'])) { | if (is_array($this->recurrence['RDATE']) && !empty($this->recurrence['RDATE'])) { | ||||
$last = end($this->recurrence['RDATE']); | $last = end($this->recurrence['RDATE']); | ||||
if ($last instanceof DateTime) { | if ($last instanceof DateTime || $last instanceof DateTimeImmutable) { | ||||
return $last; | return $last; | ||||
} | } | ||||
} | } | ||||
// run through all items till we reach the end | // run through all items till we reach the end | ||||
if ($this->recurrence['COUNT']) { | if ($this->recurrence['COUNT']) { | ||||
$last = $this->start; | $last = $this->start; | ||||
$this->next = new Horde_Date($this->start, $this->lib->timezone->getName()); | $this->next = new Horde_Date($this->start, $this->lib->timezone->getName()); | ||||
▲ Show 20 Lines • Show All 90 Lines • Show Last 20 Lines |