Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/calendar/parser/data/PhutilCalendarRecurrenceList.php
12262 views
1
<?php
2
3
final class PhutilCalendarRecurrenceList
4
extends PhutilCalendarRecurrenceSource {
5
6
private $dates = array();
7
private $order;
8
9
public function setDates(array $dates) {
10
assert_instances_of($dates, 'PhutilCalendarDateTime');
11
$this->dates = $dates;
12
return $this;
13
}
14
15
public function getDates() {
16
return $this->dates;
17
}
18
19
public function resetSource() {
20
foreach ($this->getDates() as $date) {
21
$date->setViewerTimezone($this->getViewerTimezone());
22
}
23
24
$order = msort($this->getDates(), 'getEpoch');
25
$order = array_reverse($order);
26
$this->order = $order;
27
28
return $this;
29
}
30
31
public function getNextEvent($cursor) {
32
while ($this->order) {
33
$next = array_pop($this->order);
34
if ($next->getEpoch() >= $cursor) {
35
return $next;
36
}
37
}
38
39
return null;
40
}
41
42
43
}
44
45