Created
January 8, 2019 21:23
-
-
Save akf/e7d9e56c632447e724d3c5b278bb1a9d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Every three months (quarterly) on the first Monday of the month, | |
* starting January 7 2019, until February 2, 2021 (issue #TODO) | |
* DTSTART;TZID=America/New_York:20190107T170000 | |
* RRULE:FREQ=MONTHLY;INTERVAL=3;BYDAY=1MO;WKST=MO;UNTIL=2021-02-01T18:00:00-0500 | |
*/ | |
function testQuarterlyOne() | |
{ | |
$tz = new DateTimeZone("America/New_York"); | |
$results[] = new DateTime('2019-01-07 17:00:00', $tz); | |
$results[] = new DateTime('2019-04-01 17:00:00', $tz); | |
$results[] = new DateTime('2019-07-01 17:00:00', $tz); | |
$results[] = new DateTime('2019-10-07 17:00:00', $tz); | |
$results[] = new DateTime('2020-01-06 17:00:00', $tz); | |
$results[] = new DateTime('2020-04-06 17:00:00', $tz); | |
$results[] = new DateTime('2020-07-06 17:00:00', $tz); | |
$results[] = new DateTime('2020-10-05 17:00:00', $tz); | |
$results[] = new DateTime('2021-01-04 17:00:00', $tz); | |
$r = new When(); | |
$r->startDate(new DateTime("20190107T170000", $tz)) | |
->freq("monthly") | |
->interval(3) | |
->byday('1MO') | |
->until(new DateTime("2021-02-01T18:00:00", $tz)) | |
->generateOccurrences(); | |
$occurrences = $r->occurrences; | |
foreach ($results as $key => $result) | |
{ | |
$this->assertEquals($result, $occurrences[$key]); | |
} | |
/* Check that $occurrences doesn't have extra results, as well */ | |
$this->assertEquals(count($occurrences), count($results)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment