Fix timezone issues when computing recurring all-day events (#431)

This commit is contained in:
Thomas 2011-09-23 12:50:06 +02:00
parent 778bc7cefc
commit e80490a9c7
3 changed files with 17 additions and 8 deletions

View file

@ -331,15 +331,17 @@ class database_driver extends calendar_driver
// use start date from master but try to be smart on time or duration changes // use start date from master but try to be smart on time or duration changes
$old_start_date = date('Y-m-d', $old['start']); $old_start_date = date('Y-m-d', $old['start']);
$old_start_time = date('H:i:s', $old['start']); $old_start_time = date('H:i', $old['start']);
$old_duration = $old['end'] - $old['start']; $old_duration = $old['end'] - $old['start'];
$new_start_date = date('Y-m-d', $event['start']); $new_start_date = date('Y-m-d', $event['start']);
$new_start_time = date('H:i:s', $event['start']); $new_start_time = date('H:i', $event['start']);
$new_duration = $event['end'] - $event['start']; $new_duration = $event['end'] - $event['start'];
$diff = $old_start_date != $new_start_date || $old_start_time != $new_start_time || $old_duration != $new_duration;
// shifted or resized // shifted or resized
if ($old_start_date == $new_start_date || $old_duration == $new_duration) { if ($diff && $event['id'] != $master['id'] && ($old_start_date == $new_start_date || $old_duration == $new_duration)) {
$event['start'] = $master['start'] + ($event['start'] - $old['start']); $event['start'] = $master['start'] + ($event['start'] - $old['start']);
$event['end'] = $event['start'] + $new_duration; $event['end'] = $event['start'] + $new_duration;
} }

View file

@ -447,10 +447,15 @@ class kolab_calendar
$events = array(); $events = array();
$duration = $event['end'] - $event['start']; $duration = $event['end'] - $event['start'];
$next = new Horde_Date($event['start']); $tz_offset = $event['allday'] ? $this->cal->timezone * 3600 - date('Z') : 0;
$next = new Horde_Date($event['start'] + $tz_offset); # shift all-day times to server timezone because computation operates in local TZ
$i = 0; $i = 0;
while ($next = $recurrence->nextActiveRecurrence(array('year' => $next->year, 'month' => $next->month, 'mday' => $next->mday + 1, 'hour' => $next->hour, 'min' => $next->min, 'sec' => $next->sec))) { while ($next = $recurrence->nextActiveRecurrence(array('year' => $next->year, 'month' => $next->month, 'mday' => $next->mday + 1, 'hour' => $next->hour, 'min' => $next->min, 'sec' => $next->sec))) {
$rec_start = $next->timestamp(); if ($event['allday']) {
$next->hour = $hour; # fix time for all-day events
$next->min = 0;
}
$rec_start = $next->timestamp() - $tz_offset;
$rec_end = $rec_start + $duration; $rec_end = $rec_start + $duration;
$rec_id = $event['id'] . '-' . ++$i; $rec_id = $event['id'] . '-' . ++$i;

View file

@ -660,15 +660,17 @@ class kolab_driver extends calendar_driver
// use start date from master but try to be smart on time or duration changes // use start date from master but try to be smart on time or duration changes
$old_start_date = date('Y-m-d', $old['start']); $old_start_date = date('Y-m-d', $old['start']);
$old_start_time = date('H:i:s', $old['start']); $old_start_time = date('H:i', $old['start']);
$old_duration = $old['end'] - $old['start']; $old_duration = $old['end'] - $old['start'];
$new_start_date = date('Y-m-d', $event['start']); $new_start_date = date('Y-m-d', $event['start']);
$new_start_time = date('H:i:s', $event['start']); $new_start_time = date('H:i', $event['start']);
$new_duration = $event['end'] - $event['start']; $new_duration = $event['end'] - $event['start'];
$diff = $old_start_date != $new_start_date || $old_start_time != $new_start_time || $old_duration != $new_duration;
// shifted or resized // shifted or resized
if ($old_start_date == $new_start_date || $old_duration == $new_duration) { if ($diff && $event['id'] != $master['id'] && ($old_start_date == $new_start_date || $old_duration == $new_duration)) {
$event['start'] = $master['start'] + ($event['start'] - $old['start']); $event['start'] = $master['start'] + ($event['start'] - $old['start']);
$event['end'] = $event['start'] + $new_duration; $event['end'] = $event['start'] + $new_duration;