Parse event durations
This commit is contained in:
parent
2130199951
commit
b452d54dd3
18
index.php
18
index.php
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
require_once 'vendor/autoload.php';
|
require_once 'vendor/autoload.php';
|
||||||
use ICal\ICal;
|
use ICal\ICal;
|
||||||
|
$DATE_FORMAT = 'd.m.Y H:i';
|
||||||
$state_map = array(
|
$state_map = array(
|
||||||
'closed' => (object) array(
|
'closed' => (object) array(
|
||||||
'state_string' => 'Das Dorf ist gerade <em>geschlossen</em>.',
|
'state_string' => 'Das Dorf ist gerade <em>geschlossen</em>.',
|
||||||
@ -80,9 +81,7 @@ $v = file_get_contents('/media/sg/dorf.jetzt_visitors');
|
|||||||
<div class="card mb-3 text-center">
|
<div class="card mb-3 text-center">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h5 class="card-title">Türstatus</h5>
|
<h5 class="card-title">Türstatus</h5>
|
||||||
<i class="material-icons" id="state-icn" style="color:<?= $state_map[$state]->color ?>;font-size:16rem;">
|
<i class="material-icons" id="state-icn" style="color:<?= $state_map[$state]->color ?>;font-size:16rem;"><?= $state_map[$state]->svg ?></i>
|
||||||
<?= $state_map[$state]->svg ?>
|
|
||||||
</i>
|
|
||||||
<p class="card-text"><?= $state_map[$state]->state_string ?></p>
|
<p class="card-text"><?= $state_map[$state]->state_string ?></p>
|
||||||
<div class="btn-wrapper">
|
<div class="btn-wrapper">
|
||||||
<a href="https://wiki.chaosdorf.de/Raumstatus" class="btn btn-lg btn-block btn-primary">What's this?</a>
|
<a href="https://wiki.chaosdorf.de/Raumstatus" class="btn btn-lg btn-block btn-primary">What's this?</a>
|
||||||
@ -96,14 +95,23 @@ $v = file_get_contents('/media/sg/dorf.jetzt_visitors');
|
|||||||
<h6 class="card-subtitle mb-2 text-muted">Nächste Veranstaltung</h6>
|
<h6 class="card-subtitle mb-2 text-muted">Nächste Veranstaltung</h6>
|
||||||
<p class="card-text">
|
<p class="card-text">
|
||||||
<h5 class="font-weight-bold"><?= htmlspecialchars($first_event->summary, ENT_QUOTES, 'UTF-8') ?></h5>
|
<h5 class="font-weight-bold"><?= htmlspecialchars($first_event->summary, ENT_QUOTES, 'UTF-8') ?></h5>
|
||||||
<span class="font-weight-normal"><?= $ical->iCalDateToDateTime($first_event->dtstart_array[3])->format('Y-m-d H:i'); ?></span>
|
<span class="font-weight-normal"><?= $ical->iCalDateToDateTime($first_event->dtstart_array[3])->format($DATE_FORMAT) ?></span>
|
||||||
</p>
|
</p>
|
||||||
<h5 class="card-title">Danach:</h5>
|
<h5 class="card-title">Danach:</h5>
|
||||||
<table class="table">
|
<table class="table">
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach ($events as $event) : ?>
|
<?php foreach ($events as $event) : ?>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="row"><?= $ical->iCalDateToDateTime($event->dtstart_array[3])->format('Y-m-d H:i') ?></th>
|
<th scope="row"><?php
|
||||||
|
$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');
|
||||||
|
}
|
||||||
|
echo($startdate_str . ' — ' . $enddate_str); ?></th>
|
||||||
<td><?= htmlspecialchars($event->summary) ?></td>
|
<td><?= htmlspecialchars($event->summary) ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user