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;