Skip to content

Commit 1893ca8

Browse files
committed
Alternative fix for #312. Extract the timezone, even when there's no master event.
This fix uses the TZID from the RECURRENCE-ID to figure out the timezone. This is more accurate than just grabbing the first VTIMEZONE. RECURRENCE-ID must always be in the same timezone as DTSTART from the master event.
1 parent 98e8508 commit 1893ca8

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/ITip/Broker.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,8 @@ protected function parseEventForAttendee(VCalendar $calendar, array $eventInfo,
813813
* 7. attendees
814814
* 8. sequence
815815
* 9. exdate
816-
* 10. timezone
816+
* 10. timezone - strictly the timezone on which the recurrence rule is
817+
* based on.
817818
* 11. significantChangeHash
818819
* 12. status
819820
* @param VCalendar $calendar
@@ -826,7 +827,7 @@ protected function parseEventInfo(VCalendar $calendar = null) {
826827
$organizerName = null;
827828
$organizerForceSend = null;
828829
$sequence = null;
829-
$timezone = $calendar->VTIMEZONE ? $calendar->VTIMEZONE->getTimeZone() : null;
830+
$timezone = null;
830831
$status = null;
831832
$organizerScheduleAgent = 'SERVER';
832833

@@ -884,9 +885,13 @@ protected function parseEventInfo(VCalendar $calendar = null) {
884885
$status = strtoupper($vevent->STATUS->getValue());
885886
}
886887

887-
$recurId = isset($vevent->{'RECURRENCE-ID'})?$vevent->{'RECURRENCE-ID'}->getValue():'master';
888-
if ($recurId==='master') {
889-
$timezone = $vevent->DTSTART->getDateTime()->getTimeZone();
888+
$recurId = isset($vevent->{'RECURRENCE-ID'}) ? $vevent->{'RECURRENCE-ID'}->getValue() : 'master';
889+
if (is_null($timezone)) {
890+
if ($recurId === 'master') {
891+
$timezone = $vevent->DTSTART->getDateTime()->getTimeZone();
892+
} else {
893+
$timezone = $vevent->{'RECURRENCE-ID'}->getDateTime()->getTimeZone();
894+
}
890895
}
891896
if(isset($vevent->ATTENDEE)) {
892897
foreach($vevent->ATTENDEE as $attendee) {

tests/VObject/ITip/BrokerTimezoneInParseEventInfoWithoutMasterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ function testTimezoneInParseEventInfoWithoutMaster()
7171
$reflectionMethod = new \ReflectionMethod($broker, 'parseEventInfo');
7272
$reflectionMethod->setAccessible(true);
7373
$data = $reflectionMethod->invoke($broker, $calendar);
74-
74+
$this->assertInstanceOf('DateTimeZone', $data['timezone']);
7575
$this->assertEquals($data['timezone']->getName(), 'Europe/Minsk');
7676
}
7777
}

0 commit comments

Comments
 (0)