[Pkg-owncloud-commits] [php-sabre-vobject] 14/30: Fix issue #301: when serializing rrule as json, format the UNTIL part as a date not as a string
David Prévot
taffit at moszumanska.debian.org
Sun Mar 13 00:53:02 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit 794ce7a851c76c96e3198dce7bd1d3b8778a04ab
Author: Graham Crosmarie <gcrosmarie at linagora.com>
Date: Tue Mar 1 15:54:21 2016 +0100
Fix issue #301: when serializing rrule as json, format the UNTIL part as a date not as a string
---
lib/Property/ICalendar/Recur.php | 7 ++++++-
tests/VObject/Property/ICalendar/RecurTest.php | 21 +++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
diff --git a/lib/Property/ICalendar/Recur.php b/lib/Property/ICalendar/Recur.php
index b012e7e..1b8e86c 100644
--- a/lib/Property/ICalendar/Recur.php
+++ b/lib/Property/ICalendar/Recur.php
@@ -168,7 +168,12 @@ class Recur extends Property {
$values = [];
foreach ($this->getParts() as $k => $v) {
- $values[strtolower($k)] = $v;
+ if (strcmp($k, 'UNTIL') === 0) {
+ $date = new DateTime($this->root, null, $v);
+ $values[strtolower($k)] = $date->getJsonValue()[0];
+ } else {
+ $values[strtolower($k)] = $v;
+ }
}
return [$values];
diff --git a/tests/VObject/Property/ICalendar/RecurTest.php b/tests/VObject/Property/ICalendar/RecurTest.php
index 4fb6bc2..6bde8e2 100644
--- a/tests/VObject/Property/ICalendar/RecurTest.php
+++ b/tests/VObject/Property/ICalendar/RecurTest.php
@@ -3,6 +3,7 @@
namespace Sabre\VObject\Property\ICalendar;
use Sabre\VObject\Component\VCalendar;
+use Sabre\VObject\Reader;
class RecurTest extends \PHPUnit_Framework_TestCase {
@@ -43,4 +44,24 @@ class RecurTest extends \PHPUnit_Framework_TestCase {
], $recur->getParts());
}
+
+ function testGetJSONWithUntil() {
+ $input = 'BEGIN:VCALENDAR
+BEGIN:VEVENT
+UID:908d53c0-e1a3-4883-b69f-530954d6bd62
+TRANSP:OPAQUE
+DTSTART;TZID=Europe/Berlin:20160301T150000
+DTEND;TZID=Europe/Berlin:20160301T170000
+SUMMARY:test
+RRULE:FREQ=DAILY;UNTIL=20160305T230000Z
+ORGANIZER;CN=robert pipo:mailto:robert at pipo.com
+END:VEVENT
+END:VCALENDAR
+';
+
+ $vcal = Reader::read($input);
+ $rrule = $vcal->VEVENT->RRULE;
+ $untilJsonString = $rrule->getJsonValue()[0]['until'];
+ $this->assertEquals('2016-03-05T23:00:00Z', $untilJsonString);
+ }
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-php/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list