Fix finding first occurrence for all-day events (Bifrost#T82770)
Bug caused e.g. annual all-day events not displayed on the first occurrence (start date)
This commit is contained in:
parent
77aa438b51
commit
700a64b40d
2 changed files with 35 additions and 8 deletions
|
@ -140,7 +140,7 @@ class kolab_date_recurrence
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find date/time of the first occurrence (excluding start date)
|
* Find date/time of the first occurrence
|
||||||
*/
|
*/
|
||||||
public function first_occurrence()
|
public function first_occurrence()
|
||||||
{
|
{
|
||||||
|
@ -196,11 +196,17 @@ class kolab_date_recurrence
|
||||||
$object->set($event);
|
$object->set($event);
|
||||||
$recurrence = new self($object);
|
$recurrence = new self($object);
|
||||||
|
|
||||||
// find the first occurrence
|
$orig_date = $orig_start->format('Y-m-d');
|
||||||
$found = false;
|
$found = false;
|
||||||
|
|
||||||
|
// find the first occurrence
|
||||||
while ($next = $recurrence->next_start()) {
|
while ($next = $recurrence->next_start()) {
|
||||||
$start = $next;
|
$start = $next;
|
||||||
if ($next >= $orig_start) {
|
if ($next->format('Y-m-d') >= $orig_date) {
|
||||||
|
if ($event['allday']) {
|
||||||
|
$next->setTime($orig_start->format('G'), $orig_start->format('i'), $orig_start->format('s'));
|
||||||
|
}
|
||||||
|
|
||||||
$found = true;
|
$found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -217,7 +223,7 @@ class kolab_date_recurrence
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($orig_start->_dateonly) {
|
if ($event['allday']) {
|
||||||
$start->_dateonly = true;
|
$start->_dateonly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,13 +157,13 @@ class kolab_date_recurrence_test extends PHPUnit_Framework_TestCase
|
||||||
// yearly
|
// yearly
|
||||||
array(
|
array(
|
||||||
array('FREQ' => 'YEARLY', 'INTERVAL' => '1'),
|
array('FREQ' => 'YEARLY', 'INTERVAL' => '1'),
|
||||||
'2017-08-16 11:00:00',
|
'2017-08-16 12:00:00',
|
||||||
'2017-08-16 11:00:00',
|
'2017-08-16 12:00:00',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('FREQ' => 'YEARLY', 'INTERVAL' => '1', 'BYMONTH' => '8'),
|
array('FREQ' => 'YEARLY', 'INTERVAL' => '1', 'BYMONTH' => '8'),
|
||||||
'2017-08-16 11:00:00',
|
'2017-08-16 12:00:00',
|
||||||
'2017-08-16 11:00:00',
|
'2017-08-16 12:00:00',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
array('FREQ' => 'YEARLY', 'INTERVAL' => '1', 'BYDAY' => '-1MO'),
|
array('FREQ' => 'YEARLY', 'INTERVAL' => '1', 'BYDAY' => '-1MO'),
|
||||||
|
@ -209,5 +209,26 @@ class kolab_date_recurrence_test extends PHPUnit_Framework_TestCase
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* kolab_date_recurrence::first_occurrence() for all-day events
|
||||||
|
*
|
||||||
|
* @dataProvider data_first_occurrence
|
||||||
|
*/
|
||||||
|
function test_first_occurrence_allday($recurrence_data, $start, $expected)
|
||||||
|
{
|
||||||
|
$start = new DateTime($start);
|
||||||
|
if (!empty($recurrence_data['UNTIL'])) {
|
||||||
|
$recurrence_data['UNTIL'] = new DateTime($recurrence_data['UNTIL']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$event = array('start' => $start, 'recurrence' => $recurrence_data, 'allday' => true);
|
||||||
|
$object = kolab_format::factory('event', 3.0);
|
||||||
|
$object->set($event);
|
||||||
|
|
||||||
|
$recurrence = new kolab_date_recurrence($object);
|
||||||
|
$first = $recurrence->first_occurrence();
|
||||||
|
|
||||||
|
$this->assertEquals($expected, $first ? $first->format('Y-m-d H:i:s') : '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue