diff --git a/lib/Service/Appointments/TimezoneGenerator.php b/lib/Service/Appointments/TimezoneGenerator.php index 8d7ac406d..aa21f9569 100644 --- a/lib/Service/Appointments/TimezoneGenerator.php +++ b/lib/Service/Appointments/TimezoneGenerator.php @@ -47,14 +47,6 @@ public function generateVtimezone(string $timezone, int $from, int $to): ?VTimeZ $standard = $daylightStart = null; foreach ($transitions as $i => $trans) { $component = null; - - // skip the first entry... - if ($i === 0) { - // ... but remember the offset for the next TZOFFSETFROM value - $tzfrom = $trans['offset'] / 3600; - continue; - } - // daylight saving time definition if ($trans['isdst']) { $daylightDefinition = $trans['ts']; @@ -69,9 +61,15 @@ public function generateVtimezone(string $timezone, int $from, int $to): ?VTimeZ } if ($component) { - $date = new \DateTime($trans['time']); - $offset = $trans['offset'] / 3600; - + if ($i === 0) { + $date = new \DateTime('19700101T000000'); + $tzfrom = $trans['offset'] / 3600; + $offset = $tzfrom; + } else { + $date = new \DateTime($trans['time']); + $offset = $trans['offset'] / 3600; + } + $component->DTSTART = $date->format('Ymd\THis'); $component->TZOFFSETFROM = sprintf('%s%02d%02d', $tzfrom >= 0 ? '+' : '-', abs(floor($tzfrom)), ($tzfrom - floor($tzfrom)) * 60); $component->TZOFFSETTO = sprintf('%s%02d%02d', $offset >= 0 ? '+' : '-', abs(floor($offset)), ($offset - floor($offset)) * 60); diff --git a/tests/php/unit/Service/Appointments/TimezoneGeneratorTest.php b/tests/php/unit/Service/Appointments/TimezoneGeneratorTest.php index 0f8ea764b..68b76c2af 100644 --- a/tests/php/unit/Service/Appointments/TimezoneGeneratorTest.php +++ b/tests/php/unit/Service/Appointments/TimezoneGeneratorTest.php @@ -43,7 +43,7 @@ public function testNoDaylightSaving($timezone, $daytime, $standard, $msTimezone $this->assertEquals($timezone, $generated->TZID->getValue()); $this->assertNull($generated->DAYLIGHT); - $this->assertNull($generated->STANDARD); + $this->assertNotNull($generated->STANDARD); $this->assertEquals($generated->{'X-MICROSOFT-CDO-TZID'}->getValue(), $msTimezoneId); } @@ -57,17 +57,17 @@ public function testInvalid(): void { public function providerDaylightSaving(): array { $microsoftExchangeMap = array_flip(TimeZoneUtil::$microsoftExchangeMap); return [ - ['Europe/Berlin', 3, 3, $microsoftExchangeMap['Europe/Berlin']], - ['Europe/London', 3, 3, $microsoftExchangeMap['Europe/London']], - ['Australia/Adelaide', 3, 3, $microsoftExchangeMap['Australia/Adelaide']], + ['Europe/Berlin', 3, 4, $microsoftExchangeMap['Europe/Berlin']], + ['Europe/London', 3, 4, $microsoftExchangeMap['Europe/London']], + ['Australia/Adelaide', 4, 3, $microsoftExchangeMap['Australia/Adelaide']], ]; } public function providerNoDaylightSaving(): array { $microsoftExchangeMap = array_flip(TimeZoneUtil::$microsoftExchangeMap); return [ - ['Pacific/Midway', null, null, $microsoftExchangeMap['Pacific/Midway']], - ['Asia/Singapore', null, null, $microsoftExchangeMap['Asia/Singapore']], + ['Pacific/Midway', null, 1, $microsoftExchangeMap['Pacific/Midway']], + ['Asia/Singapore', null, 1, $microsoftExchangeMap['Asia/Singapore']], ]; }