From 84183d9f7ef669779841cfccd65aae8000012e6d Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 09:11:12 +0000 Subject: show event timezone only if adjust ist set and the offset of the event timezone is different from the channel default timezone offset --- include/event.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index c8f9d2561..69ca64e0f 100644 --- a/include/event.php +++ b/include/event.php @@ -77,14 +77,22 @@ function format_event_obj($jobject) { if(array_key_exists('description', $object)) { $event_tz = ''; - if(is_array($object['asld']) && isset($object['asld']['attachment'])) { + if($object['adjust'] && is_array($object['asld']) && is_array($object['asld']['attachment'])) { foreach($object['asld']['attachment'] as $attachment) { if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) { - $event_tz = $attachment['value']; + // check if the offset of the timezones is different and only set event_tz if offset is not the same + $local_tz = new DateTimeZone(date_default_timezone_get()); + $local_dt = new DateTime('now', $local_tz); + + $ev_tz = new DateTimeZone($attachment['value']); + $ev_dt = new DateTime('now', $ev_tz); + + if($local_dt->getOffset() !== $ev_dt->getOffset()) + $event_tz = $attachment['value']; + break; } } - } $allday = (($object['adjust']) ? false : true); -- cgit v1.2.3