plugins/libcalendaring
Thomas Brüderli
bruederli at kolabsys.com
Thu Jan 8 14:32:47 CET 2015
plugins/libcalendaring/libcalendaring.php | 7 +-
plugins/libcalendaring/tests/libcalendaring.php | 76 ++++++++++++++++++++++++
plugins/libcalendaring/tests/libvcalendar.php | 2
3 files changed, 83 insertions(+), 2 deletions(-)
New commits:
commit 0463028a7613692c534930fed7fc634126175288
Author: Thomas Bruederli <bruederli at kolabsys.com>
Date: Thu Jan 8 14:32:38 2015 +0100
Export RRULE UNTIL date as UTC time (#3998)
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 at kolabsys.com>
+ *
+ * Copyright (C) 2015, Kolab Systems AG <contact at 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");
More information about the commits
mailing list