From 62b70637a7ad01cfb9a40d797704bdda4704b528 Mon Sep 17 00:00:00 2001 From: ralf Date: Tue, 6 Aug 2024 11:59:49 +0200 Subject: [PATCH] fixing the fix: whole-day fix affected adding/updating regular events (non-whole-day) via CalDAV Adding/updating events via CalDAV with timezone different to user-timezone seems to be broken since some time before the fix :( --- api/src/DateTime.php | 10 +--------- calendar/inc/class.calendar_ical.inc.php | 6 +++--- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/api/src/DateTime.php b/api/src/DateTime.php index ccf23341f8..3896997f81 100644 --- a/api/src/DateTime.php +++ b/api/src/DateTime.php @@ -378,15 +378,7 @@ class DateTime extends \DateTime case 'integer': case 'ts': // EGroupware's integer timestamp is NOT the usual UTC timestamp, but has a timezone offset applied! - // calendar_ical unfortunately sets different timezones, breaking all sorts of things, if we're not setting the TZ back to our server-timezone - if (date_default_timezone_get() !== self::$server_timezone->getName()) - { - $tz_backup = date_default_timezone_get(); - date_default_timezone_set(self::$server_timezone->getName()); - } - $ret = mktime(parent::format('H'),parent::format('i'),parent::format('s'),parent::format('m'),parent::format('d'),parent::format('Y')); - if (isset($tz_backup)) date_default_timezone_set($tz_backup); - return $ret; + return mktime(parent::format('H'),parent::format('i'),parent::format('s'),parent::format('m'),parent::format('d'),parent::format('Y')); case 'utc': // alias for "U" / timestamp in UTC return $this->getTimestamp(); case 'object': diff --git a/calendar/inc/class.calendar_ical.inc.php b/calendar/inc/class.calendar_ical.inc.php index 40ef030819..0b31accff7 100644 --- a/calendar/inc/class.calendar_ical.inc.php +++ b/calendar/inc/class.calendar_ical.inc.php @@ -615,11 +615,11 @@ class calendar_ical extends calendar_boupdate $event['end'] = new Api\DateTime($event['end'], self::$tz_cache[$event['tzid']]); } $event['end-nextday'] = clone $event['end']; - $event['end-nextday']->add("1 day"); // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445 + $event['end-nextday']->add("60 sec"); // we need the date of the next day, as DTEND is non-inclusive (= exclusive) in rfc2445 foreach (array('start' => 'DTSTART','end-nextday' => 'DTEND') as $f => $t) { - $time = new Api\DateTime($event[$f], self::$tz_cache[$event['tzid']]); - $arr = Api\DateTime::to($time,'array'); + // we need to convert whole-day events to user-timezone, as only there they start at midnight + $arr = Api\DateTime::server2user($event[$f],'array'); $vevent->setAttribute($t, array('year' => $arr['year'],'month' => $arr['month'],'mday' => $arr['day']), array('VALUE' => 'DATE')); }