xref: /PHP-8.2/ext/date/tests/bug78055.phpt (revision 4e8a6554)
1--TEST--
2Bug #78055 (DatePeriod's getRecurrences and ->recurrences don't match)
3--FILE--
4<?php
5$start = new DateTime('2018-12-31 00:00:00');
6$end   = new DateTime('2021-12-31 00:00:00');
7$interval = new DateInterval('P1M');
8$recurrences = 5;
9
10$period = new DatePeriod($start, $interval, $recurrences, DatePeriod::EXCLUDE_START_DATE);
11echo $period->getRecurrences(), " ", $period->recurrences, "\n";
12
13$period = new DatePeriod($start, $interval, $recurrences);
14echo $period->getRecurrences(), " ", $period->recurrences, "\n";
15
16$period = new DatePeriod($start, $interval, $recurrences, DatePeriod::INCLUDE_END_DATE);
17echo $period->getRecurrences(), " ", $period->recurrences, "\n";
18
19$period = new DatePeriod($start, $interval, $end);
20echo $period->getRecurrences(), " ", $period->recurrences, "\n";
21
22$period = new DatePeriod($start, $interval, $end, DatePeriod::EXCLUDE_START_DATE);
23echo $period->getRecurrences(), " ", $period->recurrences, "\n";
24?>
25--EXPECT--
265 5
275 6
285 7
29 1
30 0
31