Yearly recur increments by date not year
theninthnode opened this issue · comments
I'm trying to recur every 1 year for 5 years but it's incrementing the date instead of year.
public function test() {
$r = new \When\When();
$r->startDate(new DateTime('2015-09-17 00:00:00'));
$r->freq('yearly');
$r->interval(1);
$r->count(5);
$r->generateOccurrences();
print_r($r->occurrences);
}
Results
Array
(
[0] => DateTime Object
(
[date] => 2015-09-17 00:00:00
[timezone_type] => 3
[timezone] => UTC
)
[1] => DateTime Object
(
[date] => 2015-09-18 00:00:00
[timezone_type] => 3
[timezone] => UTC
)
[2] => DateTime Object
(
[date] => 2015-09-19 00:00:00
[timezone_type] => 3
[timezone] => UTC
)
[3] => DateTime Object
(
[date] => 2015-09-20 00:00:00
[timezone_type] => 3
[timezone] => UTC
)
[4] => DateTime Object
(
[date] => 2015-09-21 00:00:00
[timezone_type] => 3
[timezone] => UTC
)
)
I added a test and made some changes in order to fix this.
I do believe there are some additional issues with yearly frequency occurrences. I'll look into it a further, however this should be a start.
Thanks for filing the issue.
Thanks for the fix! Can you explain the additional issues with yearly? Maybe I can help resolve.
@tplaner I found another bug for this. Increments by day and not year when FREQ=YEARLY; in getOccurrencesBetween($start, $end)
generateOccurrences is fixed though
I will try to help track down a solution