Update Date Formatting for php8.1
This commit is contained in:
parent
4d021eb32d
commit
02d163ae79
1 changed files with 11 additions and 4 deletions
15
index.php
15
index.php
|
@ -1,9 +1,9 @@
|
|||
<?php
|
||||
|
||||
# config
|
||||
$ical = 'https://cloud.MYURL/remote.php/dav/public-calendars/CALENDARID/?export';
|
||||
$cachefile = 'cache/hackcal.ics';
|
||||
$cachetime = 120; // 2 min
|
||||
setlocale(LC_TIME, "de_DE.utf8");
|
||||
|
||||
# requirements
|
||||
require_once 'ICal/ICal.php';
|
||||
|
@ -34,6 +34,10 @@ foreach ($events as $event) {
|
|||
continue;
|
||||
}
|
||||
|
||||
if (isset($event->categories) && strpos($event->categories, "hidden")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$start = new DateTime($event->dtstart);
|
||||
$end = new DateTime($event->dtend);
|
||||
$uid = $event->uid;
|
||||
|
@ -44,15 +48,18 @@ foreach ($events as $event) {
|
|||
foreach ($period as $dt) {
|
||||
$date = $dt->format("Y-m-d");
|
||||
|
||||
$result[$date]["name"] = strftime('%e. %B %Y', $dt->getTimestamp());
|
||||
$result[$date]["weekday"] = strftime('%A', $dt->getTimestamp());
|
||||
$dateFormatter = new IntlDateFormatter('de_DE', IntlDateFormatter::LONG, IntlDateFormatter::NONE, 'Europe/Berlin', IntlDateFormatter::GREGORIAN);
|
||||
$weekdayFormatter = new IntlDateFormatter('de_DE', IntlDateFormatter::NONE, IntlDateFormatter::NONE, 'Europe/Berlin', IntlDateFormatter::GREGORIAN, 'EEEE');
|
||||
|
||||
$result[$date]["name"] = $dateFormatter->format($dt->getTimestamp());
|
||||
$result[$date]["weekday"] = $weekdayFormatter->format($dt->getTimestamp());
|
||||
$result[$date]["events"][$uid]["dtstart"] = $event->dtstart; #TODO: Zeitzone aus lib auslesen
|
||||
$result[$date]["events"][$uid]["dtend"] = $event->dtend; #TODO: Zeitzone aus lib auslesen
|
||||
$result[$date]["events"][$uid]["datestr"] = (isset($event->dtstart_array[0]["VALUE"]) && $event->dtstart_array[0]["VALUE"] == 'DATE')?'Ganztägig':$start->format('H:i');
|
||||
$result[$date]["events"][$uid]["summary"] = $event->summary;
|
||||
$result[$date]["events"][$uid]["location"] = $event->location;
|
||||
$result[$date]["events"][$uid]["description"] = $event->description;
|
||||
$result[$date]["events"][$uid]["categories"] = $event->categories;
|
||||
if(isset($event->categories)) $result[$date]["events"][$uid]["categories"] = $event->categories;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue