[Pkg-owncloud-commits] [php-sabre-vobject] 12/128: Cause RecurrenceIterator to respect the timezone of the event that is recurring.

David Prévot taffit at moszumanska.debian.org
Tue May 20 23:10:58 UTC 2014


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 dd6a718a45f0ad16f95708630a4ee09419a6a450
Author: Kenneth Scott <kscott at churchcommunitybuilder.com>
Date:   Mon Dec 16 17:43:26 2013 -0700

    Cause RecurrenceIterator to respect the timezone of the event that is recurring.
    
    The UNTIL value for the RRULE of an event is being parsed without a
    timezone, thus all UNTIL values are in UTC timezone, even if that is not
    what is indicated.
    
    When the UNTIL value comes from a valid ICS feed that specifies a
    timezone, but does not end with 'Z', the timezone of the event should
    be used.
    
    If the UNTIL value ends in "Z", it will still be interpreted as a UTC
    value, and work the same way as current functionality.
---
 lib/Sabre/VObject/RecurrenceIterator.php           |  2 +-
 ...RecurrenceIteratorUntilRespectsTimezoneTest.ics | 39 +++++++++++++++
 ...RecurrenceIteratorUntilRespectsTimezoneTest.php | 55 ++++++++++++++++++++++
 3 files changed, 95 insertions(+), 1 deletion(-)

diff --git a/lib/Sabre/VObject/RecurrenceIterator.php b/lib/Sabre/VObject/RecurrenceIterator.php
index 9efbc1d..7b7efa2 100644
--- a/lib/Sabre/VObject/RecurrenceIterator.php
+++ b/lib/Sabre/VObject/RecurrenceIterator.php
@@ -387,7 +387,7 @@ class RecurrenceIterator implements \Iterator {
                     break;
 
                 case 'UNTIL' :
-                    $this->until = DateTimeParser::parse($value);
+                    $this->until = DateTimeParser::parse($value, $this->startDate->getTimezone());
 
                     // In some cases events are generated with an UNTIL=
                     // parameter before the actual start of the event.
diff --git a/tests/Sabre/VObject/RecurrenceIteratorUntilRespectsTimezoneTest.ics b/tests/Sabre/VObject/RecurrenceIteratorUntilRespectsTimezoneTest.ics
new file mode 100644
index 0000000..6b2cccb
--- /dev/null
+++ b/tests/Sabre/VObject/RecurrenceIteratorUntilRespectsTimezoneTest.ics
@@ -0,0 +1,39 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+X-WR-TIMEZONE:America/New_York
+PRODID:-//www.churchcommunitybuilder.com//Church Community Builder//EN
+CALSCALE:GREGORIAN
+METHOD:PUBLISH
+X-WR-CALNAME:Test Event
+BEGIN:VTIMEZONE
+TZID:America/New_York
+X-LIC-LOCATION:America/New_York
+BEGIN:DAYLIGHT
+TZOFFSETFROM:-0500
+TZOFFSETTO:-0400
+TZNAME:EDT
+DTSTART:19700308T020000
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:-0400
+TZOFFSETTO:-0500
+TZNAME:EST
+DTSTART:19701101T020000
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+UID:10621-1440 at ccbchurch.com
+DTSTART;TZID=America/New_York:20130923T183000
+DTEND;TZID=America/New_York:20130923T203000
+DTSTAMP:20131216T170211
+RRULE:FREQ=WEEKLY;UNTIL=20131118T183000
+CREATED:20130423T161111
+DESCRIPTION:Test Event ending November 11, 2013
+LAST-MODIFIED:20131126T163428
+SEQUENCE:1387231331
+SUMMARY:Test
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
diff --git a/tests/Sabre/VObject/RecurrenceIteratorUntilRespectsTimezoneTest.php b/tests/Sabre/VObject/RecurrenceIteratorUntilRespectsTimezoneTest.php
new file mode 100644
index 0000000..a8e4671
--- /dev/null
+++ b/tests/Sabre/VObject/RecurrenceIteratorUntilRespectsTimezoneTest.php
@@ -0,0 +1,55 @@
+<?php
+namespace Sabre\VObject;
+
+class RecurrenceIteratorUntilRespectsTimezoneTest extends \PHPUnit_Framework_TestCase {
+	public function testUntilBeginHasTimezone() {
+		$filepath = realpath(__DIR__ . "/.");
+		$event = Reader::read(file_get_contents($filepath . "/RecurrenceIteratorUntilRespectsTimezoneTest.ics"));
+
+		$ri = new RecurrenceIterator($event, "10621-1440 at ccbchurch.com");
+		$this->assertEquals("America/New_York", $ri->until->getTimezone()->getName());
+	}
+
+	public function testUntilEndingInZIsUtc()
+	{
+		$ics_data = <<<ICS
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//Mac OS X 10.9//EN
+CALSCALE:GREGORIAN
+BEGIN:VTIMEZONE
+TZID:America/Chicago
+BEGIN:DAYLIGHT
+TZOFFSETFROM:-0600
+RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
+DTSTART:20070311T020000
+TZNAME:CDT
+TZOFFSETTO:-0500
+END:DAYLIGHT
+BEGIN:STANDARD
+TZOFFSETFROM:-0500
+RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
+DTSTART:20071104T020000
+TZNAME:CST
+TZOFFSETTO:-0600
+END:STANDARD
+END:VTIMEZONE
+BEGIN:VEVENT
+CREATED:20131216T214410Z
+UID:D33B6D78-A214-4752-8659-9EE718D5AB8D
+RRULE:FREQ=WEEKLY;INTERVAL=1;UNTIL=20131119T065959Z
+DTEND;TZID=America/Chicago:20130923T203000
+TRANSP:OPAQUE
+SUMMARY:Test Financial Peace
+DTSTART;TZID=America/Chicago:20130923T183000
+DTSTAMP:20131216T215922Z
+SEQUENCE:28
+END:VEVENT
+END:VCALENDAR
+ICS;
+		$event = Reader::read($ics_data);
+		$ri = new RecurrenceIterator($event, "D33B6D78-A214-4752-8659-9EE718D5AB8D");
+		$this->assertEquals("UTC", $ri->until->getTimezone()->getName());
+	}
+}
+

-- 
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