From 632c77889a0c3d7e3c5cf5d4d974f2b866c857e7 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Tue, 2 Aug 2016 22:12:09 +0200 Subject: sort events in a day (frab does that but not all schedules are sorted that way) --- model/Schedule.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'model') diff --git a/model/Schedule.php b/model/Schedule.php index 371a8ce..96ac28e 100644 --- a/model/Schedule.php +++ b/model/Schedule.php @@ -107,7 +107,20 @@ class Schedule extends ModelBase if($room_known) $name = $mapping[$name]; + $eventsSorted = []; foreach($room->event as $event) + { + $eventsSorted[] = $event; + } + + usort($eventsSorted, function($a, $b) { + $a_start = (string)$a->date; + $b_start = (string)$b->date; + + return strcmp($a_start, $b_start); + }); + + foreach($eventsSorted as $event) { $start = strtotime((string)$event->date); $duration = $this->strToDuration((string)$event->duration); -- cgit v1.2.3