From 99961cfa556e56c514f80694040f53634c958c84 Mon Sep 17 00:00:00 2001 From: khuxkm fbexl Date: Thu, 2 Jul 2020 22:48:06 -0400 Subject: [PATCH] HOTFIX: Fix the ICS generator (again) 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. --- schedule/ics.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/schedule/ics.php b/schedule/ics.php index f715547..db57d5f 100644 --- a/schedule/ics.php +++ b/schedule/ics.php @@ -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; -- 2.34.1