Switch dates to from/to range, sort by most recent end date

This commit is contained in:
isUnknown 2026-05-06 11:21:41 +02:00
parent 03099845a8
commit 7e6854da22
2 changed files with 16 additions and 22 deletions

View file

@ -7,20 +7,10 @@ class EventPage extends Page
$groups = array_values($this->dates()->toStructure()->data());
usort($groups, fn($a, $b) => strcmp(
$this->firstDateOf($a),
$this->firstDateOf($b)
$b->to()->value() ?? '',
$a->to()->value() ?? ''
));
return $groups;
}
private function firstDateOf($group): string
{
$dates = array_filter(array_map(
fn($item) => $item->date()->value(),
array_values($group->dates()->toStructure()->data())
));
return !empty($dates) ? min($dates) : '';
}
}