Update Date Formatting for php8.1

This commit is contained in:
Patrick Schwarz 2023-04-23 20:10:15 +02:00
parent 4d021eb32d
commit 02d163ae79

View file

@ -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;
}
}