Skip to content

Commit

Permalink
Add test cases for large negative BYYEARDAY values that cross 29 Feb
Browse files Browse the repository at this point in the history
  • Loading branch information
phil-davis committed Aug 17, 2022
1 parent 21631cb commit 408b591
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/VObject/Recur/RRuleIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,53 @@ public function testYearlyByYearDayNegative()
);
}

/*
* Verifies that -365 back in the year is usually 1 Jan, but
* in leap years it is 2 Jan.
*/
public function testYearlyByYearDayLargeNegative()
{
$this->parse(
'FREQ=YEARLY;COUNT=8;BYYEARDAY=-365',
'2001-01-01 14:53:11',
[
'2001-01-01 14:53:11',
'2002-01-01 14:53:11',
'2003-01-01 14:53:11',
'2004-01-02 14:53:11',
'2005-01-01 14:53:11',
'2006-01-01 14:53:11',
'2007-01-01 14:53:11',
'2008-01-02 14:53:11',
]
);
}

/*
* Verifies that -366 back in the year is 1 Jan in a leap year
* Interestingly, it goes back to 31 Dec of the previous year
* when not a leap year. The spec says that -366 is valid, and
* makes no mention of it being valid only in a leap year, so
* the behavior seems reasonable.
*/
public function testYearlyByYearDayMaxNegative()
{
$this->parse(
'FREQ=YEARLY;COUNT=8;BYYEARDAY=-366',
'2001-01-01 14:53:11',
[
'2001-01-01 14:53:11',
'2001-12-31 14:53:11',
'2002-12-31 14:53:11',
'2004-01-01 14:53:11',
'2004-12-31 14:53:11',
'2005-12-31 14:53:11',
'2006-12-31 14:53:11',
'2008-01-01 14:53:11',
]
);
}

public function testYearlyByYearDayInvalid390()
{
$this->expectException(InvalidDataException::class);
Expand Down

0 comments on commit 408b591

Please sign in to comment.