From 3e4f817da4e1b11496fec8583db352622687b60e Mon Sep 17 00:00:00 2001 From: Alyssa Retodo Date: Thu, 8 Oct 2020 18:06:16 -0700 Subject: [PATCH 1/2] Fix VTIMEZONE DTSTART format -- remove TZID and use local time --- src/CalendarExport.php | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/CalendarExport.php b/src/CalendarExport.php index 9961e6c..4a56bcf 100755 --- a/src/CalendarExport.php +++ b/src/CalendarExport.php @@ -114,13 +114,6 @@ public function getStream() $varName = ($transition['isdst']) ? 'daylightSavings' : 'standard'; ${$varName}['exists'] = true; - if ($this->dateTimeFormat === 'local') { - ${$varName}['start'] = ':' . $this->formatter->getFormattedDateTime(new \DateTime($transition['time'])); - } else if ($this->dateTimeFormat === 'utc') { - ${$varName}['start'] = ':' . $this->formatter->getFormattedUTCDateTime(new \DateTime($transition['time'])); - } else if ($this->dateTimeFormat == 'local-tz') { - ${$varName}['start'] = ';' . $this->formatter->getFormattedDateTimeWithTimeZone(new \DateTime($transition['time'])); - } ${$varName}['offsetTo'] = $this->formatter->getFormattedTimeOffset($transition['offset']); @@ -131,6 +124,10 @@ public function getStream() $offset = $tzDate->getOffset(); ${$varName}['offsetFrom'] = $this->formatter->getFormattedTimeOffset($offset); + + //use previous offset to get local transition start time + $transitionStartLocal = (new \DateTime($transition['time']))->modify($offset.' seconds'); + ${$varName}['start'] = ':' . $this->formatter->getFormattedDateTime($transitionStartLocal); } $this->stream->addItem('TZID:'.$tz->getName()); From 88cee01d1cd454e910abdd96f2b9aededdee708a Mon Sep 17 00:00:00 2001 From: Alyssa Retodo Date: Thu, 8 Oct 2020 18:08:08 -0700 Subject: [PATCH 2/2] Fix VTIMEZONE TZOFFSETFROM -- look back > 1hr to get previous offset --- src/CalendarExport.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/CalendarExport.php b/src/CalendarExport.php index 4a56bcf..805bb4e 100755 --- a/src/CalendarExport.php +++ b/src/CalendarExport.php @@ -118,7 +118,7 @@ public function getStream() ${$varName}['offsetTo'] = $this->formatter->getFormattedTimeOffset($transition['offset']); //get previous offset - $previousTimezoneObservance = $transition['ts'] - 100; + $previousTimezoneObservance = $transition['ts'] - 3700; $tzDate = new \DateTime('now', $tz); $tzDate->setTimestamp($previousTimezoneObservance); $offset = $tzDate->getOffset();