workaround 10.10 allday event rrule until timezone bug
authorCornelius Weiß <c.weiss@metaways.de>
Fri, 18 Sep 2015 14:03:52 +0000 (16:03 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 22 Sep 2015 13:22:51 +0000 (15:22 +0200)
Change-Id: I9af6b6dcb2d26c4db0645117f38577e3d92ce6be
Reviewed-on: http://gerrit.tine20.com/customers/2207
Tested-by: Jenkins CI (http://ci.tine20.com/)
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
tests/tine20/Calendar/Convert/Event/VCalendar/MacOSXTest.php
tests/tine20/Calendar/Import/files/apple_calendar_10.10_birthday01-CREATE.ics [new file with mode: 0644]
tests/tine20/Calendar/Import/files/apple_calendar_10.10_birthday02-PUT-quit-old.ics [new file with mode: 0644]
tests/tine20/Calendar/Import/files/apple_calendar_10.10_birthday03-CREATE-new.ics [new file with mode: 0644]
tine20/Calendar/Convert/Event/VCalendar/MacOSX.php

index d8a2772..b64e76d 100644 (file)
@@ -116,4 +116,14 @@ class Calendar_Convert_Event_VCalendar_MacOSXTest extends Calendar_TestCase
         $this->assertEquals(1, count($updateEvent2->exdate), print_r($updateEvent2->toArray(), true));
         $this->assertEquals('2015-04-27 22:00:00', $updateEvent2->rrule_until);
     }
+
+    public function testConvertToTine20ModelYosemiteRecurringAllDayWithUntil()
+    {
+        $converter = Calendar_Convert_Event_VCalendar_Factory::factory(Calendar_Convert_Event_VCalendar_Factory::CLIENT_MACOSX, '10.10.5');
+
+        $vcalendarStream = fopen(dirname(__FILE__) . '/../../../Import/files/apple_calendar_10.10_birthday02-PUT-quit-old.ics', 'r');
+        $event = $converter->toTine20Model($vcalendarStream);
+
+        $this->assertEquals('FREQ=YEARLY;INTERVAL=1;UNTIL=2016-09-17 22:00:00', $event->rrule);
+    }
 }
diff --git a/tests/tine20/Calendar/Import/files/apple_calendar_10.10_birthday01-CREATE.ics b/tests/tine20/Calendar/Import/files/apple_calendar_10.10_birthday01-CREATE.ics
new file mode 100644 (file)
index 0000000..7b0fd25
--- /dev/null
@@ -0,0 +1,16 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//Mac OS X 10.10.5//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20150918T122244Z
+UID:6AC01B1A-707F-48DB-B3E2-D42E28333646
+RRULE:FREQ=YEARLY;INTERVAL=1
+DTEND;VALUE=DATE:20150920
+TRANSP:TRANSPARENT
+SUMMARY:Birthdays
+DTSTART;VALUE=DATE:20150919
+DTSTAMP:20150918T122244Z
+SEQUENCE:0
+END:VEVENT
+END:VCALENDAR
\ No newline at end of file
diff --git a/tests/tine20/Calendar/Import/files/apple_calendar_10.10_birthday02-PUT-quit-old.ics b/tests/tine20/Calendar/Import/files/apple_calendar_10.10_birthday02-PUT-quit-old.ics
new file mode 100644 (file)
index 0000000..2c7becc
--- /dev/null
@@ -0,0 +1,16 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//Mac OS X 10.10.5//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20150918T122244Z
+UID:6AC01B1A-707F-48DB-B3E2-D42E28333646
+RRULE:FREQ=YEARLY;INTERVAL=1;UNTIL=20160918T235959Z
+DTEND;VALUE=DATE:20150920
+TRANSP:TRANSPARENT
+SUMMARY:Birthdays
+DTSTART;VALUE=DATE:20150919
+DTSTAMP:20150918T122244Z
+SEQUENCE:0
+END:VEVENT
+END:VCALENDAR
\ No newline at end of file
diff --git a/tests/tine20/Calendar/Import/files/apple_calendar_10.10_birthday03-CREATE-new.ics b/tests/tine20/Calendar/Import/files/apple_calendar_10.10_birthday03-CREATE-new.ics
new file mode 100644 (file)
index 0000000..6579e7d
--- /dev/null
@@ -0,0 +1,16 @@
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//Apple Inc.//Mac OS X 10.10.5//EN
+CALSCALE:GREGORIAN
+BEGIN:VEVENT
+CREATED:20150918T122244Z
+UID:D87C37E1-2962-4E48-ABF6-76EE18DA294B
+RRULE:FREQ=YEARLY;INTERVAL=1
+DTEND;VALUE=DATE:20160920
+TRANSP:TRANSPARENT
+SUMMARY:Birthdays update
+DTSTART;VALUE=DATE:20160919
+DTSTAMP:20150918T122244Z
+SEQUENCE:0
+END:VEVENT
+END:VCALENDAR
\ No newline at end of file
index 88daafe..dbf94a6 100644 (file)
@@ -98,6 +98,7 @@ class Calendar_Convert_Event_VCalendar_MacOSX extends Calendar_Convert_Event_VCa
      */
     protected function _convertVevent(\Sabre\VObject\Component\VEvent $vevent, Calendar_Model_Event $event, $options)
     {
+
         $return = parent::_convertVevent($vevent, $event, $options);
 
         // NOTE: 10.7 sometimes uses (internal?) int's
@@ -107,6 +108,15 @@ class Calendar_Convert_Event_VCalendar_MacOSX extends Calendar_Convert_Event_VCa
                 Calendar_Model_Event::CLASS_PRIVATE;
         }
 
+        // 10.10 sends UNTIL in wrong timezone for all day events
+        if ($event->is_all_day_event && version_compare($this->_version, '10.10', '>=')) {
+            $event->rrule = preg_replace_callback('/UNTIL=([\d :-]{19})(?=;?)/', function($matches) use ($vevent) {
+                // refetch UNTIL from vevent and drop timepart
+                preg_match('/UNTIL=([\dTZ]+)(?=;?)/', $vevent->RRULE, $matches);
+                $dtUntil = Calendar_Convert_Event_VCalendar_Abstract::getUTCDateFromStringInUsertime(substr($matches[1], 0, 8));
+                return 'UNTIL=' . $dtUntil->format(Tinebase_Record_Abstract::ISO8601LONG);
+            }, $event->rrule);
+        }
         return $return;
     }