Inheritance: extends when\DateTime
示例#1
0
 function testGetPrevOccurrenceFromFirstOccurence()
 {
     $r = new When();
     $r->startDate(new DateTime("19970902T090000"))->rrule("FREQ=WEEKLY")->until(new DateTime("19971104T090000"));
     $result = $r->getPrevOccurrence(new DateTime("19970902T090000"));
     $this->assertFalse($result);
 }
示例#2
0
 /**
  * I believe this rrule has a typo, the time zones don't match.
  *
  * Every 3 hours from 9:00 AM to 5:00 PM on a specific day:
  * DTSTART;TZID=America/New_York:19970902T090000
  * RRULE:FREQ=HOURLY;INTERVAL=3;UNTIL=19970902T170000Z
  */
 public function testHourlyOne()
 {
     $results[] = new DateTime('1997-09-02 09:00:00Z');
     $results[] = new DateTime('1997-09-02 12:00:00Z');
     $results[] = new DateTime('1997-09-02 15:00:00Z');
     $r = new When();
     $r->startDate(new DateTime("19970902T090000Z"))->freq("hourly")->interval(3)->until(new DateTime("19970902T170000Z"))->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
 /**
  * I believe this rrule has a typo, the time zones don't match.
  *
  * Every 3 hours from 9:00 AM to 5:00 PM on a specific day:
  * DTSTART;TZID=America/New_York:19970902T090000
  * RRULE:FREQ=HOURLY;INTERVAL=3;UNTIL=19970902T170000Z
  */
 public function testHourlyOne()
 {
     $results[] = new DateTime('1997-09-02 09:00:00Z');
     $results[] = new DateTime('1997-09-02 12:00:00Z');
     $results[] = new DateTime('1997-09-02 15:00:00Z');
     $r = new When();
     $r->startDate(new DateTime("19970902T090000Z"))->rrule("FREQ=HOURLY;INTERVAL=3;UNTIL=19970902T170000Z")->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
 /**
  * Every 15 minutes for 6 occurrences:
  * DTSTART;TZID=America/New_York:19970902T090000
  * RRULE:FREQ=MINUTELY;INTERVAL=15;COUNT=6
  */
 public function testMinutelyTwo()
 {
     $results[] = new DateTime('1997-09-02 09:00:00');
     $results[] = new DateTime('1997-09-02 09:15:00');
     $results[] = new DateTime('1997-09-02 09:30:00');
     $results[] = new DateTime('1997-09-02 09:45:00');
     $results[] = new DateTime('1997-09-02 10:00:00');
     $results[] = new DateTime('1997-09-02 10:15:00');
     $r = new When();
     $r->startDate(new DateTime("19970902T090000"))->rrule("FREQ=MINUTELY;INTERVAL=15;COUNT=6")->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
示例#5
0
 /**
  * Every 15 minutes for 6 occurrences:
  * DTSTART;TZID=America/New_York:19970902T090000
  * RRULE:FREQ=MINUTELY;INTERVAL=15;COUNT=6
  */
 public function testMinutelyTwo()
 {
     $results[] = new DateTime('1997-09-02 09:00:00');
     $results[] = new DateTime('1997-09-02 09:15:00');
     $results[] = new DateTime('1997-09-02 09:30:00');
     $results[] = new DateTime('1997-09-02 09:45:00');
     $results[] = new DateTime('1997-09-02 10:00:00');
     $results[] = new DateTime('1997-09-02 10:15:00');
     $r = new When();
     $r->startDate(new DateTime("19970902T090000"))->freq("minutely")->interval(15)->count(6)->generateOccurences();
     $occurences = $r->occurences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurences[$key]);
     }
 }
 /**
  * Every Sunday in January every other year at 8:30 am and 9:30 am
  * DTSTART;TZID=America/New_York:19970105T083000
  * RRULE:FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30
  */
 function testYearlyEleven()
 {
     $results[] = new DateTime("1997-01-05 08:30:00");
     $results[] = new DateTime("1997-01-05 09:30:00");
     $results[] = new DateTime("1997-01-12 08:30:00");
     $results[] = new DateTime("1997-01-12 09:30:00");
     $results[] = new DateTime("1997-01-19 08:30:00");
     $results[] = new DateTime("1997-01-19 09:30:00");
     $results[] = new DateTime("1997-01-26 08:30:00");
     $results[] = new DateTime("1997-01-26 09:30:00");
     $results[] = new DateTime("1999-01-03 08:30:00");
     $results[] = new DateTime("1999-01-03 09:30:00");
     $r = new When();
     $r->startDate(new DateTime("19970105T083000"))->rrule("FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30")->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
示例#7
0
 /**
  * Every 1st Monday, Tuesday, or Wednesday in April every year for 3 years (ticket #55)
  * DTSTART;TZID=America/New_York:19970407T090000
  * RRULE:FREQ=YEARLY;BYDAY=MO,TU,WE;BYSETPOS=1;BYMONTH=4;COUNT=3
  */
 function testYearlyThirteen()
 {
     $results[] = new DateTime("1997-04-07 09:00:00");
     $results[] = new DateTime("1998-04-01 09:00:00");
     $results[] = new DateTime("1999-04-05 09:00:00");
     $r = new When();
     $r->startDate(new DateTime("19970407T090000"))->rrule("FREQ=YEARLY;BYDAY=MO,TU,WE;BYSETPOS=1;BYMONTH=4;COUNT=3")->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
 /**
  * Check that we don't alter results
  * DTSTART;TZID=America/New_York:19970902T090000
  * RRULE:FREQ=WEEKLY;
  *
  * '2001-07-03 09:00:00' = #201
  * '2001-07-31 09:00:00' = #205
  */
 function testCurruptingThis()
 {
     $results[] = new DateTime('2001-07-03 09:00:00');
     $results[] = new DateTime('2001-07-10 09:00:00');
     $results[] = new DateTime('2001-07-17 09:00:00');
     $results[] = new DateTime('2001-07-24 09:00:00');
     $results[] = new DateTime('2001-07-31 09:00:00');
     $r = new When();
     $r->startDate(new DateTime("19970902T090000"))->rrule("FREQ=WEEKLY;");
     $occurrences = $r->getOccurrencesBetween(new DateTime("20010521T090000"), new DateTime("20010612T090000"));
     $occurrences2 = $r->getOccurrencesBetween(new DateTime("20010702T090000"), new DateTime("20010801T090000"));
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences2[$key]);
     }
 }
示例#9
0
 /**
  * changing only WKST from MO to SU, yields different results...
  * DTSTART;TZID=America/New_York:19970805T090000
  * RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU
  */
 function testWeeklyEight()
 {
     $results[] = new DateTime('1997-08-05 09:00:00');
     $results[] = new DateTime('1997-08-17 09:00:00');
     $results[] = new DateTime('1997-08-19 09:00:00');
     $results[] = new DateTime('1997-08-31 09:00:00');
     $r = new When();
     $r->startDate(new DateTime("19970805T090000"))->freq("weekly")->interval(2)->count(4)->byday(array('TU', 'SU'))->wkst('SU')->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
 /**
  * changing only WKST from MO to SU, yields different results...
  * DTSTART;TZID=America/New_York:19970805T090000
  * RRULE:FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU
  */
 function testWeeklyEight()
 {
     $results[] = new DateTime('1997-08-05 09:00:00');
     $results[] = new DateTime('1997-08-17 09:00:00');
     $results[] = new DateTime('1997-08-19 09:00:00');
     $results[] = new DateTime('1997-08-31 09:00:00');
     $r = new When();
     $r->startDate(new DateTime("19970805T090000"))->rrule("FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU")->generateOccurences();
     $occurences = $r->occurences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurences[$key]);
     }
 }
 /**
  * The third instance into the month of one of Tuesday, Wednesday, or Thursday, for the next 3 months:
  * DTSTART;TZID=America/New_York:19970904T090000
  * RRULE:FREQ=MONTHLY;COUNT=3;BYDAY=TU,WE,TH;BYSETPOS=3
  */
 function testMonthlySixteen()
 {
     $results[] = new DateTime('1997-09-04 09:00:00');
     $results[] = new DateTime('1997-10-07 09:00:00');
     $results[] = new DateTime('1997-11-06 09:00:00');
     $r = new When();
     $r->startDate(new DateTime("19970904T090000"))->rrule("FREQ=MONTHLY;COUNT=3;BYDAY=TU,WE,TH;BYSETPOS=3")->generateOccurences();
     $occurences = $r->occurences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurences[$key]);
     }
 }
示例#12
0
 /**
  * Every 2nd Monday every month for 4 months (issue #55)
  * Checking single BYDAY with BYSETPOS while Monthly
  * DTSTART;TZID=America/New_York:19970908T090000
  * RRULE:FREQ=MONTHLY;BYDAY=MO;BYSETPOS=2;COUNT=4
  */
 function testMonthlySeventeen()
 {
     $results[] = new DateTime("1997-09-08 09:00:00");
     $results[] = new DateTime("1997-10-13 09:00:00");
     $results[] = new DateTime("1997-11-10 09:00:00");
     $results[] = new DateTime("1997-12-08 09:00:00");
     $r = new When();
     $r->startDate(new DateTime("19970908T090000"))->rrule("FREQ=MONTHLY;BYDAY=MO;BYSETPOS=2;COUNT=4")->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
示例#13
0
 /**
  * Every Sunday in January every other year at 8:30 am and 9:30 am
  * DTSTART;TZID=America/New_York:19970105T083000
  * RRULE:FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30
  */
 function testYearlyEleven()
 {
     $results[] = new DateTime("1997-01-05 08:30:00");
     $results[] = new DateTime("1997-01-05 09:30:00");
     $results[] = new DateTime("1997-01-12 08:30:00");
     $results[] = new DateTime("1997-01-12 09:30:00");
     $results[] = new DateTime("1997-01-19 08:30:00");
     $results[] = new DateTime("1997-01-19 09:30:00");
     $results[] = new DateTime("1997-01-26 08:30:00");
     $results[] = new DateTime("1997-01-26 09:30:00");
     $results[] = new DateTime("1999-01-03 08:30:00");
     $results[] = new DateTime("1999-01-03 09:30:00");
     $r = new When();
     $r->startDate(new DateTime("19970105T083000"))->freq("yearly")->interval(2)->bymonth(1)->byday("su")->byhour("8,9")->byminute("30")->count(10)->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
示例#14
0
 /**
  * The third instance into the month of one of Tuesday, Wednesday, or Thursday, for the next 3 months:
  * DTSTART;TZID=America/New_York:19970904T090000
  * RRULE:FREQ=MONTHLY;COUNT=3;BYDAY=TU,WE,TH;BYSETPOS=3
  */
 function testMonthlySixteen()
 {
     $results[] = new DateTime('1997-09-04 09:00:00');
     $results[] = new DateTime('1997-10-07 09:00:00');
     $results[] = new DateTime('1997-11-06 09:00:00');
     $r = new When();
     $r->startDate(new DateTime("19970904T090000"))->freq("monthly")->count(3)->byday("tu, we, th")->bysetpos(3)->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
示例#15
0
 /**
  * Every Sunday in January every other year at 8:30 am and 9:30 am
  * DTSTART;TZID=America/New_York:19970105T083000
  * RRULE:FREQ=YEARLY;INTERVAL=2;BYMONTH=1;BYDAY=SU;BYHOUR=8,9;BYMINUTE=30
  */
 function testYearlyTheninthnode()
 {
     $results[] = new DateTime("2015-09-17 00:00:00");
     $results[] = new DateTime("2016-09-17 00:00:00");
     $results[] = new DateTime("2017-09-17 00:00:00");
     $results[] = new DateTime("2018-09-17 00:00:00");
     $results[] = new DateTime("2019-09-17 00:00:00");
     $r = new When();
     $r->startDate(new DateTime('2015-09-17 00:00:00'));
     $r->freq('yearly');
     $r->interval(1);
     $r->count(5);
     $r->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
示例#16
0
 /**
  * Every other week - forever:
  * DTSTART;TZID=America/New_York:19970902T000000
  * RRULE:FREQ=WEEKLY;INTERVAL=2;WKST=TU
  *
  * Weekstart meets first occurrence,
  * time is midnight.
  *
  * @see https://github.com/tplaner/When/issues/45
  */
 function testWeeklyNine()
 {
     $results[] = new DateTime('1997-09-02 00:00:00');
     $results[] = new DateTime('1997-09-16 00:00:00');
     $results[] = new DateTime('1997-09-30 00:00:00');
     $results[] = new DateTime('1997-10-14 00:00:00');
     $results[] = new DateTime('1997-10-28 00:00:00');
     $results[] = new DateTime('1997-11-11 00:00:00');
     $results[] = new DateTime('1997-11-25 00:00:00');
     $results[] = new DateTime('1997-12-09 00:00:00');
     $results[] = new DateTime('1997-12-23 00:00:00');
     $results[] = new DateTime('1998-01-06 00:00:00');
     $results[] = new DateTime('1998-01-20 00:00:00');
     $results[] = new DateTime('1998-02-03 00:00:00');
     $results[] = new DateTime('1998-02-17 00:00:00');
     $r = new When();
     $r->startDate(new \DateTime('1997-09-02 00:00:00'))->freq('weekly')->interval(2)->wkst('TU')->count(13)->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
示例#17
0
 /**
  * Every day in January, for 3 years:
  * DTSTART;TZID=America/New_York:19980101T090000
  * RRULE:FREQ=DAILY;UNTIL=20000131T140000Z;BYMONTH=1
  */
 function testDailyFive()
 {
     $results[] = new DateTime('1998-01-01 09:00:00');
     $results[] = new DateTime('1998-01-02 09:00:00');
     $results[] = new DateTime('1998-01-03 09:00:00');
     $results[] = new DateTime('1998-01-04 09:00:00');
     $results[] = new DateTime('1998-01-05 09:00:00');
     $results[] = new DateTime('1998-01-06 09:00:00');
     $results[] = new DateTime('1998-01-07 09:00:00');
     $results[] = new DateTime('1998-01-08 09:00:00');
     $results[] = new DateTime('1998-01-09 09:00:00');
     $results[] = new DateTime('1998-01-10 09:00:00');
     $results[] = new DateTime('1998-01-11 09:00:00');
     $results[] = new DateTime('1998-01-12 09:00:00');
     $results[] = new DateTime('1998-01-13 09:00:00');
     $results[] = new DateTime('1998-01-14 09:00:00');
     $results[] = new DateTime('1998-01-15 09:00:00');
     $results[] = new DateTime('1998-01-16 09:00:00');
     $results[] = new DateTime('1998-01-17 09:00:00');
     $results[] = new DateTime('1998-01-18 09:00:00');
     $results[] = new DateTime('1998-01-19 09:00:00');
     $results[] = new DateTime('1998-01-20 09:00:00');
     $results[] = new DateTime('1998-01-21 09:00:00');
     $results[] = new DateTime('1998-01-22 09:00:00');
     $results[] = new DateTime('1998-01-23 09:00:00');
     $results[] = new DateTime('1998-01-24 09:00:00');
     $results[] = new DateTime('1998-01-25 09:00:00');
     $results[] = new DateTime('1998-01-26 09:00:00');
     $results[] = new DateTime('1998-01-27 09:00:00');
     $results[] = new DateTime('1998-01-28 09:00:00');
     $results[] = new DateTime('1998-01-29 09:00:00');
     $results[] = new DateTime('1998-01-30 09:00:00');
     $results[] = new DateTime('1998-01-31 09:00:00');
     $results[] = new DateTime('1999-01-01 09:00:00');
     $results[] = new DateTime('1999-01-02 09:00:00');
     $results[] = new DateTime('1999-01-03 09:00:00');
     $results[] = new DateTime('1999-01-04 09:00:00');
     $results[] = new DateTime('1999-01-05 09:00:00');
     $results[] = new DateTime('1999-01-06 09:00:00');
     $results[] = new DateTime('1999-01-07 09:00:00');
     $results[] = new DateTime('1999-01-08 09:00:00');
     $results[] = new DateTime('1999-01-09 09:00:00');
     $results[] = new DateTime('1999-01-10 09:00:00');
     $results[] = new DateTime('1999-01-11 09:00:00');
     $results[] = new DateTime('1999-01-12 09:00:00');
     $results[] = new DateTime('1999-01-13 09:00:00');
     $results[] = new DateTime('1999-01-14 09:00:00');
     $results[] = new DateTime('1999-01-15 09:00:00');
     $results[] = new DateTime('1999-01-16 09:00:00');
     $results[] = new DateTime('1999-01-17 09:00:00');
     $results[] = new DateTime('1999-01-18 09:00:00');
     $results[] = new DateTime('1999-01-19 09:00:00');
     $results[] = new DateTime('1999-01-20 09:00:00');
     $results[] = new DateTime('1999-01-21 09:00:00');
     $results[] = new DateTime('1999-01-22 09:00:00');
     $results[] = new DateTime('1999-01-23 09:00:00');
     $results[] = new DateTime('1999-01-24 09:00:00');
     $results[] = new DateTime('1999-01-25 09:00:00');
     $results[] = new DateTime('1999-01-26 09:00:00');
     $results[] = new DateTime('1999-01-27 09:00:00');
     $results[] = new DateTime('1999-01-28 09:00:00');
     $results[] = new DateTime('1999-01-29 09:00:00');
     $results[] = new DateTime('1999-01-30 09:00:00');
     $results[] = new DateTime('1999-01-31 09:00:00');
     $results[] = new DateTime('2000-01-01 09:00:00');
     $results[] = new DateTime('2000-01-02 09:00:00');
     $results[] = new DateTime('2000-01-03 09:00:00');
     $results[] = new DateTime('2000-01-04 09:00:00');
     $results[] = new DateTime('2000-01-05 09:00:00');
     $results[] = new DateTime('2000-01-06 09:00:00');
     $results[] = new DateTime('2000-01-07 09:00:00');
     $results[] = new DateTime('2000-01-08 09:00:00');
     $results[] = new DateTime('2000-01-09 09:00:00');
     $results[] = new DateTime('2000-01-10 09:00:00');
     $results[] = new DateTime('2000-01-11 09:00:00');
     $results[] = new DateTime('2000-01-12 09:00:00');
     $results[] = new DateTime('2000-01-13 09:00:00');
     $results[] = new DateTime('2000-01-14 09:00:00');
     $results[] = new DateTime('2000-01-15 09:00:00');
     $results[] = new DateTime('2000-01-16 09:00:00');
     $results[] = new DateTime('2000-01-17 09:00:00');
     $results[] = new DateTime('2000-01-18 09:00:00');
     $results[] = new DateTime('2000-01-19 09:00:00');
     $results[] = new DateTime('2000-01-20 09:00:00');
     $results[] = new DateTime('2000-01-21 09:00:00');
     $results[] = new DateTime('2000-01-22 09:00:00');
     $results[] = new DateTime('2000-01-23 09:00:00');
     $results[] = new DateTime('2000-01-24 09:00:00');
     $results[] = new DateTime('2000-01-25 09:00:00');
     $results[] = new DateTime('2000-01-26 09:00:00');
     $results[] = new DateTime('2000-01-27 09:00:00');
     $results[] = new DateTime('2000-01-28 09:00:00');
     $results[] = new DateTime('2000-01-29 09:00:00');
     $results[] = new DateTime('2000-01-30 09:00:00');
     $results[] = new DateTime('2000-01-31 09:00:00');
     $r = new When();
     $r->startDate(new DateTime("19980101T090000"))->freq("daily")->bymonth(array(1))->until(new DateTime("20000131T140000"))->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
示例#18
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testInvalidCount()
 {
     $test = new When();
     $test->count('weekly');
 }
示例#19
0
 /**
  * TODO: I think there might be an issue with timezone here
  *
  * Every day in January, for 3 years:
  * DTSTART;TZID=America/New_York:19980101T090000
  * RRULE:FREQ=DAILY;UNTIL=20000131T140000Z;BYMONTH=1
  */
 function testDailyFive()
 {
     $results[] = new DateTime('1998-01-01 09:00:00');
     $results[] = new DateTime('1998-01-02 09:00:00');
     $results[] = new DateTime('1998-01-03 09:00:00');
     $results[] = new DateTime('1998-01-04 09:00:00');
     $results[] = new DateTime('1998-01-05 09:00:00');
     $results[] = new DateTime('1998-01-06 09:00:00');
     $results[] = new DateTime('1998-01-07 09:00:00');
     $results[] = new DateTime('1998-01-08 09:00:00');
     $results[] = new DateTime('1998-01-09 09:00:00');
     $results[] = new DateTime('1998-01-10 09:00:00');
     $results[] = new DateTime('1998-01-11 09:00:00');
     $results[] = new DateTime('1998-01-12 09:00:00');
     $results[] = new DateTime('1998-01-13 09:00:00');
     $results[] = new DateTime('1998-01-14 09:00:00');
     $results[] = new DateTime('1998-01-15 09:00:00');
     $results[] = new DateTime('1998-01-16 09:00:00');
     $results[] = new DateTime('1998-01-17 09:00:00');
     $results[] = new DateTime('1998-01-18 09:00:00');
     $results[] = new DateTime('1998-01-19 09:00:00');
     $results[] = new DateTime('1998-01-20 09:00:00');
     $results[] = new DateTime('1998-01-21 09:00:00');
     $results[] = new DateTime('1998-01-22 09:00:00');
     $results[] = new DateTime('1998-01-23 09:00:00');
     $results[] = new DateTime('1998-01-24 09:00:00');
     $results[] = new DateTime('1998-01-25 09:00:00');
     $results[] = new DateTime('1998-01-26 09:00:00');
     $results[] = new DateTime('1998-01-27 09:00:00');
     $results[] = new DateTime('1998-01-28 09:00:00');
     $results[] = new DateTime('1998-01-29 09:00:00');
     $results[] = new DateTime('1998-01-30 09:00:00');
     $results[] = new DateTime('1998-01-31 09:00:00');
     $results[] = new DateTime('1999-01-01 09:00:00');
     $results[] = new DateTime('1999-01-02 09:00:00');
     $results[] = new DateTime('1999-01-03 09:00:00');
     $results[] = new DateTime('1999-01-04 09:00:00');
     $results[] = new DateTime('1999-01-05 09:00:00');
     $results[] = new DateTime('1999-01-06 09:00:00');
     $results[] = new DateTime('1999-01-07 09:00:00');
     $results[] = new DateTime('1999-01-08 09:00:00');
     $results[] = new DateTime('1999-01-09 09:00:00');
     $results[] = new DateTime('1999-01-10 09:00:00');
     $results[] = new DateTime('1999-01-11 09:00:00');
     $results[] = new DateTime('1999-01-12 09:00:00');
     $results[] = new DateTime('1999-01-13 09:00:00');
     $results[] = new DateTime('1999-01-14 09:00:00');
     $results[] = new DateTime('1999-01-15 09:00:00');
     $results[] = new DateTime('1999-01-16 09:00:00');
     $results[] = new DateTime('1999-01-17 09:00:00');
     $results[] = new DateTime('1999-01-18 09:00:00');
     $results[] = new DateTime('1999-01-19 09:00:00');
     $results[] = new DateTime('1999-01-20 09:00:00');
     $results[] = new DateTime('1999-01-21 09:00:00');
     $results[] = new DateTime('1999-01-22 09:00:00');
     $results[] = new DateTime('1999-01-23 09:00:00');
     $results[] = new DateTime('1999-01-24 09:00:00');
     $results[] = new DateTime('1999-01-25 09:00:00');
     $results[] = new DateTime('1999-01-26 09:00:00');
     $results[] = new DateTime('1999-01-27 09:00:00');
     $results[] = new DateTime('1999-01-28 09:00:00');
     $results[] = new DateTime('1999-01-29 09:00:00');
     $results[] = new DateTime('1999-01-30 09:00:00');
     $results[] = new DateTime('1999-01-31 09:00:00');
     $results[] = new DateTime('2000-01-01 09:00:00');
     $results[] = new DateTime('2000-01-02 09:00:00');
     $results[] = new DateTime('2000-01-03 09:00:00');
     $results[] = new DateTime('2000-01-04 09:00:00');
     $results[] = new DateTime('2000-01-05 09:00:00');
     $results[] = new DateTime('2000-01-06 09:00:00');
     $results[] = new DateTime('2000-01-07 09:00:00');
     $results[] = new DateTime('2000-01-08 09:00:00');
     $results[] = new DateTime('2000-01-09 09:00:00');
     $results[] = new DateTime('2000-01-10 09:00:00');
     $results[] = new DateTime('2000-01-11 09:00:00');
     $results[] = new DateTime('2000-01-12 09:00:00');
     $results[] = new DateTime('2000-01-13 09:00:00');
     $results[] = new DateTime('2000-01-14 09:00:00');
     $results[] = new DateTime('2000-01-15 09:00:00');
     $results[] = new DateTime('2000-01-16 09:00:00');
     $results[] = new DateTime('2000-01-17 09:00:00');
     $results[] = new DateTime('2000-01-18 09:00:00');
     $results[] = new DateTime('2000-01-19 09:00:00');
     $results[] = new DateTime('2000-01-20 09:00:00');
     $results[] = new DateTime('2000-01-21 09:00:00');
     $results[] = new DateTime('2000-01-22 09:00:00');
     $results[] = new DateTime('2000-01-23 09:00:00');
     $results[] = new DateTime('2000-01-24 09:00:00');
     $results[] = new DateTime('2000-01-25 09:00:00');
     $results[] = new DateTime('2000-01-26 09:00:00');
     $results[] = new DateTime('2000-01-27 09:00:00');
     $results[] = new DateTime('2000-01-28 09:00:00');
     $results[] = new DateTime('2000-01-29 09:00:00');
     $results[] = new DateTime('2000-01-30 09:00:00');
     $results[] = new DateTime('2000-01-31 09:00:00');
     $r = new When();
     $r->startDate(new DateTime("19980101T090000"))->rrule("FREQ=DAILY;UNTIL=20000131T140000;BYMONTH=1")->generateOccurences();
     $occurences = $r->occurences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurences[$key]);
     }
 }
示例#20
0
 /**
  * every 1st Mon or Fri every week, for 4 weeks (ticket #55)
  * I'm sure there is a more useful way to use BYSETPOS weekly...
  * DTSTART;TZID=America/New_York:19970808T090000
  * RRULE:FREQ=WEEKLY;BYDAY=MO,FR;COUNT=4;BYSETPOS=1
  */
 function testWeeklyNine()
 {
     $results[] = new DateTime('1997-08-08 09:00:00');
     $results[] = new DateTime('1997-08-11 09:00:00');
     $results[] = new DateTime('1997-08-18 09:00:00');
     $results[] = new DateTime('1997-08-25 09:00:00');
     $r = new When();
     $r->startDate(new DateTime("19970808T090000"))->rrule("FREQ=WEEKLY;BYDAY=MO,FR;COUNT=4;BYSETPOS=1")->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
示例#21
0
 function testNman12WeeklyBug()
 {
     $results[] = new DateTime('2014-02-10 00:00:00');
     $results[] = new DateTime('2014-02-11 00:00:00');
     $results[] = new DateTime('2014-02-17 00:00:00');
     $results[] = new DateTime('2014-02-24 00:00:00');
     $results[] = new DateTime('2014-02-25 00:00:00');
     $results[] = new DateTime('2014-03-10 00:00:00');
     $results[] = new DateTime('2014-03-11 00:00:00');
     $results[] = new DateTime('2014-03-24 00:00:00');
     $results[] = new DateTime('2014-03-25 00:00:00');
     $results[] = new DateTime('2014-04-07 00:00:00');
     $r = new When();
     $r->startDate(new DateTime("2014-02-10"))->rrule("FREQ=WEEKLY;INTERVAL=2;BYDAY=MO,TU;COUNT=10")->generateOccurrences();
     $occurrences = $r->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }
示例#22
0
 public function testGenerateOccurrencesErrorIgnored()
 {
     $results[] = new DateTime('1997-10-07 09:00:00');
     $results[] = new DateTime('1997-11-06 09:00:00');
     $test = new When();
     $test->RFC5545_COMPLIANT = When::IGNORE;
     $test->startDate(new DateTime("19970905T090000"))->rrule("FREQ=MONTHLY;COUNT=3;BYDAY=TU,WE,TH;BYSETPOS=3")->generateOccurrences();
     $occurrences = $test->occurrences;
     foreach ($results as $key => $result) {
         $this->assertEquals($result, $occurrences[$key]);
     }
 }