@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhutilCalendarRecurrenceList
4 extends PhutilCalendarRecurrenceSource {
5
6 private $dates = array();
7 private $order;
8
9 /**
10 * @param array<PhutilCalendarDateTime> $dates
11 */
12 public function setDates(array $dates) {
13 assert_instances_of($dates, PhutilCalendarDateTime::class);
14 $this->dates = $dates;
15 return $this;
16 }
17
18 public function getDates() {
19 return $this->dates;
20 }
21
22 public function resetSource() {
23 foreach ($this->getDates() as $date) {
24 $date->setViewerTimezone($this->getViewerTimezone());
25 }
26
27 $order = msort($this->getDates(), 'getEpoch');
28 $order = array_reverse($order);
29 $this->order = $order;
30
31 return $this;
32 }
33
34 public function getNextEvent($cursor) {
35 while ($this->order) {
36 $next = array_pop($this->order);
37 if ($next->getEpoch() >= $cursor) {
38 return $next;
39 }
40 }
41
42 return null;
43 }
44
45
46}