Merge branch '2013.10' into 2014.11
authorPhilipp Schüle <p.schuele@metaways.de>
Tue, 22 Sep 2015 13:25:05 +0000 (15:25 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Tue, 22 Sep 2015 13:25:05 +0000 (15:25 +0200)
Conflicts:
tests/tine20/Calendar/Convert/Event/VCalendar/MacOSXTest.php

Change-Id: I19bca261578d8c7af1149c2e4e5d494875805414

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 36091d1..06bfa6e 100644 (file)
@@ -126,4 +126,14 @@ class Calendar_Convert_Event_VCalendar_MacOSXTest extends Calendar_TestCase
 
         $this->assertCount(2, $event->attendee, 'CHAIR should be skipped, Attendee should be recognised');
     }
+
+    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 f3513c3..4a3e99d 100644 (file)
@@ -149,6 +149,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
@@ -158,6 +159,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;
     }