summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Bruederli <bruederli@kolabsys.com>2015-01-08 13:32:38 (GMT)
committerThomas Bruederli <bruederli@kolabsys.com>2015-01-08 13:32:38 (GMT)
commit0463028a7613692c534930fed7fc634126175288 (patch)
tree4a6558d6847e91cbec7dee7ad724c03c9a75a6af
parent1dd6cc8a0bbce39c181ee101150653aecc21f074 (diff)
downloadroundcubemail-plugins-kolab-0463028a7613692c534930fed7fc634126175288.tar.gz
Export RRULE UNTIL date as UTC time (#3998)
-rw-r--r--plugins/libcalendaring/libcalendaring.php7
-rw-r--r--plugins/libcalendaring/tests/libcalendaring.php76
-rw-r--r--plugins/libcalendaring/tests/libvcalendar.php2
3 files changed, 83 insertions, 2 deletions
diff --git a/plugins/libcalendaring/libcalendaring.php b/plugins/libcalendaring/libcalendaring.php
index 95cbffb..7506336 100644
--- a/plugins/libcalendaring/libcalendaring.php
+++ b/plugins/libcalendaring/libcalendaring.php
@@ -1440,7 +1440,12 @@ class libcalendaring extends rcube_plugin
$k = strtoupper($k);
switch ($k) {
case 'UNTIL':
- $val = $val->format('Ymd\THis');
+ // convert to UTC according to RFC 5545
+ if (is_a($val, 'DateTime')) {
+ $until = clone $val;
+ $until->setTimezone(new DateTimeZone('UTC'));
+ $val = $until->format('Ymd\THis\Z');
+ }
break;
case 'RDATE':
case 'EXDATE':
diff --git a/plugins/libcalendaring/tests/libcalendaring.php b/plugins/libcalendaring/tests/libcalendaring.php
new file mode 100644
index 0000000..3d0eb86
--- /dev/null
+++ b/plugins/libcalendaring/tests/libcalendaring.php
@@ -0,0 +1,76 @@
+<?php
+
+/**
+ * libcalendaring plugin's utility functions tests
+ *
+ * @author Thomas Bruederli <bruederli@kolabsys.com>
+ *
+ * Copyright (C) 2015, Kolab Systems AG <contact@kolabsys.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+class libcalendaring_test extends PHPUnit_Framework_TestCase
+{
+ function setUp()
+ {
+ require_once __DIR__ . '/../libcalendaring.php';
+ }
+
+ /**
+ * libcalendaring::part_is_vcalendar()
+ */
+ function test_part_is_vcalendar()
+ {
+ $part = new StdClass;
+ $part->mimetype = 'text/plain';
+ $part->filename = 'event.ics';
+
+ $this->assertFalse(libcalendaring::part_is_vcalendar($part));
+
+ $part->mimetype = 'text/calendar';
+ $this->assertTrue(libcalendaring::part_is_vcalendar($part));
+
+ $part->mimetype = 'text/x-vcalendar';
+ $this->assertTrue(libcalendaring::part_is_vcalendar($part));
+
+ $part->mimetype = 'application/ics';
+ $this->assertTrue(libcalendaring::part_is_vcalendar($part));
+
+ $part->mimetype = 'application/x-any';
+ $this->assertTrue(libcalendaring::part_is_vcalendar($part));
+ }
+
+ /**
+ * libcalendaring::to_rrule()
+ */
+ function test_to_rrule()
+ {
+ $rrule = array(
+ 'FREQ' => 'MONTHLY',
+ 'BYDAY' => '2WE',
+ 'INTERVAL' => 2,
+ 'UNTIL' => new DateTime('2025-05-01 18:00:00 CEST'),
+ );
+
+ $s = libcalendaring::to_rrule($rrule);
+
+ $this->assertRegExp('/FREQ='.$rrule['FREQ'].'/', $s, "Recurrence Frequence");
+ $this->assertRegExp('/INTERVAL='.$rrule['INTERVAL'].'/', $s, "Recurrence Interval");
+ $this->assertRegExp('/BYDAY='.$rrule['BYDAY'].'/', $s, "Recurrence BYDAY");
+ $this->assertRegExp('/UNTIL=20250501T160000Z/', $s, "Recurrence End date (in UTC)");
+ }
+
+}
+
diff --git a/plugins/libcalendaring/tests/libvcalendar.php b/plugins/libcalendaring/tests/libvcalendar.php
index bb0f121..81b2120 100644
--- a/plugins/libcalendaring/tests/libvcalendar.php
+++ b/plugins/libcalendaring/tests/libvcalendar.php
@@ -371,7 +371,7 @@ class libvcalendar_test extends PHPUnit_Framework_TestCase
$rrule = $event['recurrence'];
$this->assertRegExp('/RRULE:.*FREQ='.$rrule['FREQ'].'/', $ics, "Export Recurrence Frequence");
$this->assertRegExp('/RRULE:.*INTERVAL='.$rrule['INTERVAL'].'/', $ics, "Export Recurrence Interval");
- $this->assertRegExp('/RRULE:.*UNTIL=20140718/', $ics, "Export Recurrence End date");
+ $this->assertRegExp('/RRULE:.*UNTIL=20140718T215959Z/', $ics, "Export Recurrence End date");
$this->assertRegExp('/RRULE:.*BYDAY='.$rrule['BYDAY'].'/', $ics, "Export Recurrence BYDAY");
$this->assertRegExp('/EXDATE.*:20131218/', $ics, "Export Recurrence EXDATE");