diff --git a/index.php b/index.php index 3d12998..e773ed0 100644 --- a/index.php +++ b/index.php @@ -1,7 +1,7 @@ (object) array( 'state_string' => 'Das Dorf ist gerade geschlossen.', @@ -64,6 +64,18 @@ if ($locale !== null){ setlocale(LC_TIME, $locale); } $v = file_get_contents('/media/sg/dorf.jetzt_visitors'); +function format_event($event): string{ + global $DATE_FORMAT, $ical; + $startdate_loop = $ical->iCalDateToDateTime($event->dtstart_array[3]); + $startdate_str = $startdate_loop->format($DATE_FORMAT); + $interval_loop = new DateInterval($event->duration); + if ($interval_loop->d != 0 || $interval_loop->h >= 24){ + $enddate_str = $startdate_loop->add($interval_loop)->format($DATE_FORMAT); + }else{ + $enddate_str = $startdate_loop->add($interval_loop)->format('H:i'); + } + return $startdate_str . ' – ' . $enddate_str; +} ?> @@ -96,23 +108,14 @@ $v = file_get_contents('/media/sg/dorf.jetzt_visitors');
iCalDateToDateTime($event->dtstart_array[3]); - $startdate_str = $startdate_loop->format($DATE_FORMAT); - $interval_loop = new DateInterval($event->duration); - if ($interval_loop->d != 0 || $interval_loop->h >= 24){ - $enddate_str = $startdate_loop->add($interval_loop)->format($DATE_FORMAT); - }else{ - $enddate_str = $startdate_loop->add($interval_loop)->format('H:i'); - } - echo($startdate_str . ' – ' . $enddate_str); ?> | +=format_event($event)?> | = htmlspecialchars($event->summary) ?> |
---|