[Pkg-owncloud-commits] [php-sabre-vobject] 08/65: Keep floating time on Recur\EventIterator::getEventObject to correctly expand with reference timezone (if any)

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:57:12 UTC 2015


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 512250ab2c8a49faf779bf44f49c38f3e61ab53b
Author: Armin Hackmann <armin at fruux.com>
Date:   Wed Jan 21 10:44:25 2015 +0100

    Keep floating time on Recur\EventIterator::getEventObject to correctly expand with reference timezone (if any)
---
 lib/Recur/EventIterator.php                        |   4 +-
 .../EventIterator/ExpandFloatingTimesTest.php      | 122 +++++++++++++++++++++
 2 files changed, 124 insertions(+), 2 deletions(-)

diff --git a/lib/Recur/EventIterator.php b/lib/Recur/EventIterator.php
index 2430545..c621293 100644
--- a/lib/Recur/EventIterator.php
+++ b/lib/Recur/EventIterator.php
@@ -268,9 +268,9 @@ class EventIterator implements \Iterator {
         );
         // @codeCoverageIgnoreEnd
 
-        $event->DTSTART->setDateTime($this->getDtStart());
+        $event->DTSTART->setDateTime($this->getDtStart(), $event->DTSTART->isFloating());
         if (isset($event->DTEND)) {
-            $event->DTEND->setDateTime($this->getDtEnd());
+            $event->DTEND->setDateTime($this->getDtEnd(), $event->DTEND->isFloating());
         }
         // Including a RECURRENCE-ID to the object, unless this is the first
         // object.
diff --git a/tests/VObject/Recur/EventIterator/ExpandFloatingTimesTest.php b/tests/VObject/Recur/EventIterator/ExpandFloatingTimesTest.php
new file mode 100644
index 0000000..397b99a
--- /dev/null
+++ b/tests/VObject/Recur/EventIterator/ExpandFloatingTimesTest.php
@@ -0,0 +1,122 @@
+<?php
+
+namespace Sabre\VObject;
+
+use
+    DateTime,
+    DateTimeZone;
+
+/**
+ * This is a unittest for Issue #53.
+ */
+class ExpandFloatingTimesTest extends \PHPUnit_Framework_TestCase {
+
+    function testExpand() {
+
+        $input = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foo
+DTSTART:20150109T090000
+DTEND:20150109T100000
+RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20191002T070000Z;BYDAY=FR
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $vcal = Reader::read($input);
+        $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal);
+
+        $vcal->expand(new DateTime('2015-01-01'), new DateTime('2015-01-31'));
+
+        $result = $vcal->serialize();
+
+        $output = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foo
+DTSTART:20150109T090000Z
+DTEND:20150109T100000Z
+END:VEVENT
+BEGIN:VEVENT
+UID:foo
+DTSTART:20150116T090000Z
+DTEND:20150116T100000Z
+RECURRENCE-ID:20150116T090000Z
+END:VEVENT
+BEGIN:VEVENT
+UID:foo
+DTSTART:20150123T090000Z
+DTEND:20150123T100000Z
+RECURRENCE-ID:20150123T090000Z
+END:VEVENT
+BEGIN:VEVENT
+UID:foo
+DTSTART:20150130T090000Z
+DTEND:20150130T100000Z
+RECURRENCE-ID:20150130T090000Z
+END:VEVENT
+END:VCALENDAR
+
+ICS;
+        $this->assertEquals($output, str_replace("\r", "", $result));
+    
+    }
+
+    function testExpandWithReferenceTimezone() {
+
+        $input = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foo
+DTSTART:20150109T090000
+DTEND:20150109T100000
+RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20191002T070000Z;BYDAY=FR
+END:VEVENT
+END:VCALENDAR
+ICS;
+
+        $vcal = Reader::read($input);
+        $this->assertInstanceOf('Sabre\\VObject\\Component\\VCalendar', $vcal);
+
+        $vcal->expand(new DateTime('2015-01-01'), new DateTime('2015-01-31'), new \DateTimeZone('Europe/Berlin'));
+
+        $result = $vcal->serialize();
+
+        $output = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+BEGIN:VEVENT
+UID:foo
+DTSTART:20150109T080000Z
+DTEND:20150109T090000Z
+END:VEVENT
+BEGIN:VEVENT
+UID:foo
+DTSTART:20150116T080000Z
+DTEND:20150116T090000Z
+RECURRENCE-ID:20150116T080000Z
+END:VEVENT
+BEGIN:VEVENT
+UID:foo
+DTSTART:20150123T080000Z
+DTEND:20150123T090000Z
+RECURRENCE-ID:20150123T080000Z
+END:VEVENT
+BEGIN:VEVENT
+UID:foo
+DTSTART:20150130T080000Z
+DTEND:20150130T090000Z
+RECURRENCE-ID:20150130T080000Z
+END:VEVENT
+END:VCALENDAR
+
+ICS;
+        $this->assertEquals($output, str_replace("\r", "", $result));
+    
+    }
+
+}

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list