From 9cf6685a77ab2201b37f621bf95e84ca0904871a Mon Sep 17 00:00:00 2001 From: nathangray Date: Tue, 23 May 2017 13:37:34 -0600 Subject: [PATCH] Calendar - all day recurring events would extend one day longer for some timezone combinations --- calendar/inc/class.calendar_boupdate.inc.php | 10 +++++++--- calendar/inc/class.calendar_rrule.inc.php | 3 ++- calendar/inc/class.calendar_so.inc.php | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/calendar/inc/class.calendar_boupdate.inc.php b/calendar/inc/class.calendar_boupdate.inc.php index 074c7cf756..646e9ac511 100644 --- a/calendar/inc/class.calendar_boupdate.inc.php +++ b/calendar/inc/class.calendar_boupdate.inc.php @@ -1245,11 +1245,15 @@ class calendar_boupdate extends calendar_bo } if (!empty($event['recur_enddate'])) { - $time = $this->so->startOfDay(new Api\DateTime($event['recur_enddate'], Api\DateTime::$user_timezone)); + // all-day events are handled in server time + $time = $this->so->startOfDay( + new Api\DateTime($event['recur_enddate'], Api\DateTime::$user_timezone), + Api\DateTime::$server_timezone->getName() + ); $time->modify(($event['end'] - $event['start'] + 1).' seconds'); - $event['recur_enddate'] = Api\DateTime::to($time, 'ts'); + $event['recur_enddate'] = Api\DateTime::to($time, 'ts') - 1; $time->setUser(); - $save_event['recur_enddate'] = Api\DateTime::to($time, 'ts'); + $save_event['recur_enddate'] = Api\DateTime::to($time, 'ts') - 1; } $timestamps = array('modified','created'); // all-day events are handled in server time diff --git a/calendar/inc/class.calendar_rrule.inc.php b/calendar/inc/class.calendar_rrule.inc.php index 7f9f9b21f0..25eea2ee11 100644 --- a/calendar/inc/class.calendar_rrule.inc.php +++ b/calendar/inc/class.calendar_rrule.inc.php @@ -759,8 +759,9 @@ class calendar_rrule implements Iterator if ($event['recur_enddate']) { - $enddate = is_a($event['recur_enddate'],'DateTime') ? $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'],self::$tz_cache[$to_tz]); + $enddate = is_a($event['recur_enddate'],'DateTime') ? $event['recur_enddate'] : new Api\DateTime($event['recur_enddate'],$timestamp_tz); $enddate->setTime(23,59,59); + $enddate->setTimezone(self::$tz_cache[$to_tz]); } if (is_array($event['recur_exception'])) { diff --git a/calendar/inc/class.calendar_so.inc.php b/calendar/inc/class.calendar_so.inc.php index 950882fd93..c07052ac74 100644 --- a/calendar/inc/class.calendar_so.inc.php +++ b/calendar/inc/class.calendar_so.inc.php @@ -730,7 +730,7 @@ class calendar_so { $all_cols = self::get_columns('calendar', $this->cal_table); $all_cols[0] = $this->db->to_varchar($this->cal_table.'.cal_id'); - $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end AS recur_enddate,".implode(',',$all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date"; + $cols = "$this->repeats_table.recur_type,$this->repeats_table.recur_interval,$this->repeats_table.recur_data,range_end - 1 AS recur_enddate,".implode(',',$all_cols).",cal_start,cal_end,$this->user_table.cal_recur_date"; } $where = array(); if (is_array($params['query']))