diff options
author | Mario Vavti <mario@mariovavti.com> | 2019-06-03 19:03:43 +0000 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2019-06-03 21:04:51 +0200 |
commit | e64a7b87a847a414a99f7f1b3fd6a9eb445754de (patch) | |
tree | f16d20cc3d1b6d8e0689bf3ac872335864c21fb3 | |
parent | 5b4aa1afc2d3811aae93706299dfb5d5c703198f (diff) | |
download | volse-hubzilla-e64a7b87a847a414a99f7f1b3fd6a9eb445754de.tar.gz volse-hubzilla-e64a7b87a847a414a99f7f1b3fd6a9eb445754de.tar.bz2 volse-hubzilla-e64a7b87a847a414a99f7f1b3fd6a9eb445754de.zip |
fix timezone issue when importing adjusted events
(cherry picked from commit 2b452ea3e8dca9324ebea6031b3060e6c27d5526)
-rw-r--r-- | include/event.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/include/event.php b/include/event.php index b1da2de8e..f1a095d1d 100644 --- a/include/event.php +++ b/include/event.php @@ -757,7 +757,6 @@ function parse_vobject($ical, $type) { function parse_ical_file($f,$uid) { - require_once('vendor/autoload.php'); $s = @file_get_contents($f); @@ -816,12 +815,23 @@ function event_import_ical($ical, $uid) { // logger('dtstart: ' . var_export($dtstart,true)); - $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $ev['timezone'] = 'UTC'; + + // Try to get an usable olson format timezone + if($ev['adjust']) { + //TODO: we should pass the vcalendar to getTimeZone() to be more accurate + // we do not have it here since parse_ical_file() is passing the vevent only. + $timezone_obj = \Sabre\VObject\TimeZoneUtil::getTimeZone($ical->DTSTART['TZID']); + $timezone = $timezone_obj->getName(); + $ev['timezone'] = $timezone; + } + + $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),$ev['timezone'], $dtstart->format(\DateTime::W3C)); if(isset($ical->DTEND)) { $dtend = $ical->DTEND->getDateTime(); - $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC', + $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),$ev['timezone'], $dtend->format(\DateTime::W3C)); } else { @@ -871,10 +881,6 @@ function event_import_ical($ical, $uid) { $ev['external_id'] = $evuid; } - $ev['timezone'] = 'UTC'; - if(isset($ical->DTSTART['TZID'])) - $ev['timezone'] = $ical->DTSTART['TZID']; - if($ev['summary'] && $ev['dtstart']) { $ev['event_xchan'] = $channel['channel_hash']; $ev['uid'] = $channel['channel_id']; |