fix dates in ical and add calendar title
[bdrem.git] / src / bdrem / Renderer / Ical.php
index 019e2180f188bfd868ac1cb416b21cdd5c675085..f20e461a2f10d5b758c65f807d386f27691ed937 100644 (file)
@@ -35,6 +35,9 @@ class Renderer_Ical extends Renderer
     /**
      * Render the events in an iCalendar file
      *
+     * X-WR-CALNAME is supported by claws mail's vcalendar plugin; it
+     * uses it as title.
+     *
      * @param array $arEvents Event objects to render
      *
      * @return string iCal file
@@ -43,17 +46,20 @@ class Renderer_Ical extends Renderer
     {
         $s = "BEGIN:VCALENDAR\n"
             . "VERSION:2.0\n"
-            . "PRODID:-//bdrem\n";
+            . "PRODID:-//bdrem\n"
+            . "X-WR-CALNAME:birthdays\n";
         foreach ($arEvents as $event) {
             $props = array('BEGIN' => 'VEVENT');
             
             $props['UID'] = str_replace(
-                array('-', '????'), array('', '0000'), $event->date
+                array('-', '????'), array('', '0000'), $event->localDate
             )
                 . '.' . $event->age
                 . '.' . md5($event->title . '/' . $event->type)
                 . '@bdrem';
-            $props['DTSTART']  = str_replace('-', '', $event->date);
+            // we want the zero time because it expresses midnight in every
+            // time zone
+            $props['DTSTART']  = str_replace('-', '', $event->localDate) . 'T000000';
             $props['DURATION'] = 'P1D';
             $props['SUMMARY']  = sprintf(
                 '%s - %s. %s', $event->title, $event->age, $event->type