From: Christian Weiske Date: Fri, 21 Mar 2014 16:34:07 +0000 (+0100) Subject: fix dates in ical and add calendar title X-Git-Tag: v0.5.0~6 X-Git-Url: https://git.cweiske.de/bdrem.git/commitdiff_plain/be516011d0da9b3ede5742428d280694e096532d?hp=fabbf07a9aaf9fe66145b84199f8bfbbd1ee0259 fix dates in ical and add calendar title --- diff --git a/README.rst b/README.rst index 66d0da2..c910740 100644 --- a/README.rst +++ b/README.rst @@ -24,6 +24,7 @@ Output formats - ASCII table - HTML - Email (text + HTML parts) +- iCalendar ===== @@ -80,6 +81,17 @@ If you only want an email if there is a birthday, use ``--stoponempty``:: Make sure your config file contains ``$mail_from`` and ``$mail_to`` settings. +iCalendar +========= +Exporting birthday events into an ics file is easy:: + + $ bdrem --renderer=ical > birthdays.ics + +It is possible to access the calendar via HTTP, too:: + + http://example.org/bdrem/?renderer=ical + + HTML page ========= Simply point your web browser to the ``.phar`` file, or ``index.php``. diff --git a/src/bdrem/Renderer/Ical.php b/src/bdrem/Renderer/Ical.php index 019e218..f20e461 100644 --- a/src/bdrem/Renderer/Ical.php +++ b/src/bdrem/Renderer/Ical.php @@ -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