HOTFIX: Fix the ICS generator (again)
continuous-integration/drone/pr Build encountered an error Details

I overestimated how much was in common between the two files. ics.php had its
own formatdate function, which it no longer does (thanks ben (/s)).

Reimplement ics.php's former formatdate function as ics_formatdate, and use
it instead of formatdate to format the dates in the ICS output.
This commit is contained in:
Robert Miles 2020-07-02 22:48:06 -04:00
parent 1c1744092b
commit 99961cfa55
1 changed files with 8 additions and 4 deletions

View File

@ -3,6 +3,10 @@ $from = gmdate("Y-m-d\T00:00:00\Z", strtotime(date("w") ? "last sunday" : "sunda
$to = gmdate("Y-m-d\T00:00:00\Z", strtotime(date("w") ? "sunday" : "next sunday"));
include 'schedule.php';
function ics_formatdate($date) {
return gmdate("Ymd\THis\Z", strtotime($date));
}
// ICS generation. Here be dragons.
// I created the file using a Python script and reverse-engineered it to figure this out.
@ -15,17 +19,17 @@ define("ICS_EOL","\r\n");
echo "BEGIN:VCALENDAR".ICS_EOL;
echo "VERSION:2.0".ICS_EOL;
echo "PRODID:tilderadio schedule".ICS_EOL;
echo "DTSTAMP:".formatdate("now").ICS_EOL;
echo "DTSTAMP:".ics_formatdate("now").ICS_EOL;
foreach ($schedule as $event) {
// The VEVENT structure's pretty easy to generate, especially since we're already in UTC.
echo "BEGIN:VEVENT".ICS_EOL;
// First, we need a creation date.
// Just go with now.
echo "DTSTAMP:".formatdate("now").ICS_EOL;
echo "DTSTAMP:".ics_formatdate("now").ICS_EOL;
// Next, the event start and end.
echo "DTEND:".formatdate($event["end"]).ICS_EOL;
echo "DTSTART:".formatdate($event["start"]).ICS_EOL;
echo "DTEND:".ics_formatdate($event["end"]).ICS_EOL;
echo "DTSTART:".ics_formatdate($event["start"]).ICS_EOL;
// Next, the recurrence rule.
// We assume the format is weekly. (No DJs have requested any other frequency yet.)
echo "RRULE:FREQ=WEEKLY".ICS_EOL;