Add Agenda::getNextOfEach()

This commit is contained in:
Yorin Anne De Jong 2016-08-26 22:56:52 +02:00
parent f39389ead4
commit 1650328ccd

View File

@ -69,6 +69,21 @@ class Agenda {
return $result;
}
public function getNextOfEach(DateTimeImmutable $startDate) {
$result = array_map(
function($a) use ($startDate){
return $a->getNextEventFrom($startDate);
}, $this->activities
);
usort($result, function($a, $b) {
return ($a->getStart()->getTimeStamp() < $b->getStart()->getTimeStamp())
? -1
: 1
;
});
return $result;
}
public static function isToday(DateTimeImmutable $date) {
return $date->format('dmY') == date('dmY');
}