From d22a9aa537479e41397288f011607fdf573e72b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Lehrke?= Date: Sat, 1 May 2010 16:25:10 +0000 Subject: [PATCH] Fix all-day recurring event timezone issue --- calendar/inc/class.calendar_bo.inc.php | 19 +++++++++++---- calendar/inc/class.calendar_boupdate.inc.php | 25 +++++++++++++------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/calendar/inc/class.calendar_bo.inc.php b/calendar/inc/class.calendar_bo.inc.php index 35a3fdbb90..a661802608 100644 --- a/calendar/inc/class.calendar_bo.inc.php +++ b/calendar/inc/class.calendar_bo.inc.php @@ -696,13 +696,24 @@ class calendar_bo //error_log('set_recurrences: days=' . array2string($days) ); foreach($events as $event) { - $start_servertime = $this->date2ts($event['start'],true); - if (in_array($start_servertime, (array)$days)) + $start = $this->date2ts($event['start'],true); + if (in_array($start, (array)$days)) { // we don't change the stati of recurrence exceptions $event['participants'] = array(); } - $this->so->recurrence($event['id'],$start_servertime,$this->date2ts($event['end'],true),$event['participants']); + if ($event['whole_day']) + { + $time = new egw_time($event['end'], egw_time::$user_timezone); + $time =& $this->so->startOfDay($time); + $time->setTime(23, 59, 59); + $end = $this->date2ts($time,true); + } + else + { + $end = $this->date2ts($event['end'],true); + } + $this->so->recurrence($event['id'],$start,$end,$event['participants']); } } @@ -879,7 +890,7 @@ class calendar_bo $event['recur_enddate'] = $end; } // loop over all recurrences and insert them, if they are after $start - $rrule = calendar_rrule::event2rrule($event,true); // true = we operate in usertime, like the rest of calendar_bo + $rrule = calendar_rrule::event2rrule($event, true); // true = we operate in usertime, like the rest of calendar_bo foreach($rrule as $time) { $time->setUser(); // $time is in timezone of event, convert it to usertime used here diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index 07198a06bf..3cbf3cd1d7 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -851,25 +851,34 @@ class calendar_boupdate extends calendar_bo $old_event = null; } - $save_event = $event; if (!isset($event['whole_day'])) $event['whole_day'] = $this->isWholeDay($event); + $save_event = $event; if ($event['whole_day']) { $time = new egw_time($event['start'], egw_time::$user_timezone); $time =& $this->so->startOfDay($time); $event['start'] = egw_time::to($time, 'ts'); + $save_event['start'] = $time; $time = new egw_time($event['end'], egw_time::$user_timezone); $time =& $this->so->startOfDay($time); $time->setTime(23, 59, 59); $event['end'] = egw_time::to($time, 'ts'); - $time = new egw_time($event['recurrence'], egw_time::$user_timezone); - $time =& $this->so->startOfDay($time); - $event['recurrence'] = egw_time::to($time, 'ts'); - $time = new egw_time($event['recur_enddate'], egw_time::$user_timezone); - $time =& $this->so->startOfDay($time); - $time->setTime(23, 59, 59); - $event['recur_enddate'] = egw_time::to($time, 'ts'); + if (!empty($event['recurrence'])) + { + $time = new egw_time($event['recurrence'], egw_time::$user_timezone); + $time =& $this->so->startOfDay($time); + $event['recurrence'] = egw_time::to($time, 'ts'); + } + if (!empty($event['recur_enddate'])) + { + $time = new egw_time($event['recur_enddate'], egw_time::$user_timezone); + $time =& $this->so->startOfDay($time); + $event['recur_enddate'] = egw_time::to($time, 'ts'); + $save_event['recur_enddate'] = $event['recur_enddate']; + } $timestamps = array('modified','created'); + // all-day events are handled in server time + $event['tzid'] = $save_event['tzid'] = egw_time::$server_timezone->getName(); } else {