24 $vevent =
$calendar->createComponent(
'VEVENT');
25 $vevent->DTSTART =
'20111223T120000Z';
26 $tests[] = [$vevent, new \DateTime(
'2011-01-01'), new \DateTime(
'2012-01-01'),
true];
27 $tests[] = [$vevent, new \DateTime(
'2011-01-01'), new \DateTime(
'2011-11-01'),
false];
29 $vevent2 = clone $vevent;
30 $vevent2->DTEND =
'20111225T120000Z';
31 $tests[] = [$vevent2, new \DateTime(
'2011-01-01'), new \DateTime(
'2012-01-01'),
true];
32 $tests[] = [$vevent2, new \DateTime(
'2011-01-01'), new \DateTime(
'2011-11-01'),
false];
34 $vevent3 = clone $vevent;
35 $vevent3->DURATION =
'P1D';
36 $tests[] = [$vevent3, new \DateTime(
'2011-01-01'), new \DateTime(
'2012-01-01'),
true];
37 $tests[] = [$vevent3, new \DateTime(
'2011-01-01'), new \DateTime(
'2011-11-01'),
false];
39 $vevent4 = clone $vevent;
40 $vevent4->DTSTART =
'20111225';
41 $vevent4->DTSTART[
'VALUE'] =
'DATE';
42 $tests[] = [$vevent4, new \DateTime(
'2011-01-01'), new \DateTime(
'2012-01-01'),
true];
43 $tests[] = [$vevent4, new \DateTime(
'2011-01-01'), new \DateTime(
'2011-11-01'),
false];
45 $tests[] = [$vevent4, new \DateTime(
'2011-12-25 16:00:00'), new \DateTime(
'2011-12-25 17:00:00'),
true];
47 $tests[] = [$vevent4, new \DateTime(
'2011-12-26 00:00:00'), new \DateTime(
'2011-12-26 17:00:00'),
false];
49 $tests[] = [$vevent4, new \DateTime(
'2011-12-26 00:00:00',
new \
DateTimeZone(
'Europe/Berlin')), new \DateTime(
'2011-12-26 17:00:00',
new \
DateTimeZone(
'Europe/Berlin')),
false];
51 $vevent5 = clone $vevent;
52 $vevent5->DURATION =
'P1D';
53 $vevent5->RRULE =
'FREQ=YEARLY';
54 $tests[] = [$vevent5, new \DateTime(
'2011-01-01'), new \DateTime(
'2012-01-01'),
true];
55 $tests[] = [$vevent5, new \DateTime(
'2011-01-01'), new \DateTime(
'2011-11-01'),
false];
56 $tests[] = [$vevent5, new \DateTime(
'2013-12-01'), new \DateTime(
'2013-12-31'),
true];
58 $vevent6 = clone $vevent;
59 $vevent6->DTSTART =
'20111225';
60 $vevent6->DTSTART[
'VALUE'] =
'DATE';
61 $vevent6->DTEND =
'20111225';
62 $vevent6->DTEND[
'VALUE'] =
'DATE';
64 $tests[] = [$vevent6, new \DateTime(
'2011-01-01'), new \DateTime(
'2012-01-01'),
true];
65 $tests[] = [$vevent6, new \DateTime(
'2011-01-01'), new \DateTime(
'2011-11-01'),
false];
69 $vevent7 = clone $vevent;
70 $vevent7->DTSTART =
'20120101';
71 $vevent7->DTSTART[
'VALUE'] =
'DATE';
72 $vevent7->RRULE =
'FREQ=MONTHLY';
73 $tests[] = [$vevent7, new \DateTime(
'2012-02-01 15:00:00'), new \DateTime(
'2012-02-02'),
true];
75 $tests[] = [$vevent7, new \DateTime(
'2012-02-02 00:00:00',
new \
DateTimeZone(
'Europe/Berlin')), new \DateTime(
'2012-02-03 00:00:00',
new \
DateTimeZone(
'Europe/Berlin')),
false];
78 $vevent8 = clone $vevent;
79 $vevent8->DTSTART =
'20130329T140000';
80 $vevent8->DTEND =
'20130329T153000';
81 $vevent8->RRULE = [
'FREQ' =>
'WEEKLY',
'BYDAY' => [
'FR'],
'UNTIL' =>
'20130412T115959Z'];
82 $vevent8->add(
'EXDATE',
'20130405T140000');
83 $vevent8->add(
'EXDATE',
'20130329T140000');
84 $tests[] = [$vevent8, new \DateTime(
'2013-03-01'), new \DateTime(
'2013-04-01'),
false];
87 $vevent9 = clone $vevent;
88 $vevent9->DTSTART =
'20161027';
89 $vevent9->DTEND =
'20161028';
90 $vevent9->RRULE =
'FREQ=DAILY';
91 $tests[] = [$vevent9, new \DateTime(
'2016-10-31'), new \DateTime(
'2016-12-12'),
true];
testInTimeRange(VEvent $vevent, $start, $end, $outcome)
timeRangeTestData
isInTimeRange(DateTimeInterface $start, DateTimeInterface $end)
Returns true or false depending on if the event falls in the specified time-range.