mirror of
https://gitlab.com/davical-project/davical.git
synced 2026-08-29 18:26:05 +00:00
Merge branch 'piotrfilip/davical-freebusy_count_fix'
This commit is contained in:
commit
351b853948
@ -816,12 +816,12 @@ class RepeatRule {
|
||||
if ( !isset($this->instances[$position]) || $instance != $this->instances[$position] ) {
|
||||
$got_more = true;
|
||||
$position++;
|
||||
$this->instances[$position] = $instance;
|
||||
if ( DEBUG_RRULE ) printf( "Added date %s into position %d in current set\n", $instance->format('c'), $position );
|
||||
if ( isset($this->count) && ($position + 1) >= $this->count ) {
|
||||
if ( isset($this->count) && $position >= $this->count ) {
|
||||
$this->finished = true;
|
||||
return;
|
||||
}
|
||||
$this->instances[$position] = $instance;
|
||||
if ( DEBUG_RRULE ) printf( "Added date %s into position %d in current set\n", $instance->format('c'), $position );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,12 +88,28 @@ END:VEVENT
|
||||
END:VCALENDAR
|
||||
");
|
||||
|
||||
$count_cal = new vCalendar("BEGIN:VCALENDAR
|
||||
PRODID:-//Mozilla.org/NONSGML Mozilla Calendar V1.1//EN
|
||||
VERSION:2.0
|
||||
BEGIN:VEVENT
|
||||
CREATED:20190117T001216Z
|
||||
LAST-MODIFIED:20190117T001233Z
|
||||
DTSTAMP:20190117T001233Z
|
||||
UID:dae6404d-1ce0-42d0-af3b-0d303034197b
|
||||
SUMMARY:New Event
|
||||
RRULE:FREQ=WEEKLY;COUNT=4;BYDAY=MO,TU,WE,TH
|
||||
DTSTART;TZID=Pacific/Auckland:20190121T130000
|
||||
DTEND;TZID=Pacific/Auckland:20190121T140000
|
||||
TRANSP:OPAQUE
|
||||
END:VEVENT
|
||||
END:VCALENDAR");
|
||||
|
||||
/**
|
||||
* A simplified model of get_freebusy, which works off of a passed-in vCalendar
|
||||
* rather than making SQL queries
|
||||
*/
|
||||
function get_freebusyish(vCalendar $cal) {
|
||||
$expansion = expand_event_instances($cal)->GetComponents(['VEVENT' => true]);
|
||||
$expansion = expand_event_instances($cal, new RepeatRuleDateTime('2019-01-01 00:00:00'))->GetComponents(['VEVENT' => true]);
|
||||
|
||||
$result = array();
|
||||
|
||||
@ -150,4 +166,14 @@ final class ExpansionTest extends TestCase
|
||||
get_freebusyish($tuesday_renamed_cal_order_swapped)
|
||||
);
|
||||
}
|
||||
|
||||
public function testCalWithCount() {
|
||||
global $count_cal;
|
||||
|
||||
self::assertEquals(
|
||||
self::expected_freebusyish_for_base,
|
||||
get_freebusyish($count_cal)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user