aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/event.php20
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'];