Add Agenda::getNextOfEach()

This commit is contained in:
Jørn Åne 2016-08-26 22:56:52 +02:00
parent f39389ead4
commit 1650328ccd
1 changed files with 15 additions and 0 deletions

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');
}