try fix event

This commit is contained in:
isUnknown 2024-09-24 08:59:17 +02:00
parent 3809d96504
commit ece995352f
5 changed files with 14 additions and 15 deletions

View file

@ -4,6 +4,10 @@ class EventPage extends Page {
public function schedule() {
$sessions = $this->isMapadoEvent() != 'true' ? $this->sessions()->toStructure() : $this->remoteSessions()->toStructure();
if ($sessions->isEmpty()) {
throw new Exception('Can\'t define sessions for event "' . $this->title()->value() . '". No sessions found.', 1);
}
try {
$firstSession = $sessions->first()->date();
$lastSession = $sessions->last()->date();
@ -18,6 +22,7 @@ class EventPage extends Page {
$isSameMonth = $firstSession->toDate('y-M') === $lastSession->toDate('y-M');
$isSameDay = $firstSession->toDate('d') === $lastSession->toDate('d');
if ($isSameMonth) {
if ($isSameDay) {
return $startDay . ' ' . $endMonth;
@ -28,4 +33,4 @@ class EventPage extends Page {
return $startDay . ' ' . $startMonth . ' - ' . $endDay . ' ' . $endMonth;
}
}
}
}