aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-06-03 21:03:43 +0200
committerMario Vavti <mario@mariovavti.com>2019-06-03 21:03:43 +0200
commit2b452ea3e8dca9324ebea6031b3060e6c27d5526 (patch)
tree57da762a756b49c6ee18c81cb821549cbe524091 /include
parent66c6c6c7d1c87aa50ac0fe701505802110b8eecb (diff)
downloadvolse-hubzilla-2b452ea3e8dca9324ebea6031b3060e6c27d5526.tar.gz
volse-hubzilla-2b452ea3e8dca9324ebea6031b3060e6c27d5526.tar.bz2
volse-hubzilla-2b452ea3e8dca9324ebea6031b3060e6c27d5526.zip
fix timezone issue when importing adjusted events
Diffstat (limited to 'include')
-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'];