Exemple #1
0
 public function testTwentyFive()
 {
     $results[] = new DateTime('2010-01-15 09:00:00');
     $results[] = new DateTime('2011-01-15 09:00:00');
     $results[] = new DateTime('2012-01-15 09:00:00');
     $results[] = new DateTime('2013-01-15 09:00:00');
     $results[] = new DateTime('2014-01-15 09:00:00');
     $results[] = new DateTime('2015-01-15 09:00:00');
     $r = new Recurrence();
     $r->recur('20100115T090000')->rrule('FREQ=YEARLY');
     foreach ($results as $result) {
         $this->assertEquals($result, $r->next());
     }
 }
Exemple #2
0
 /**
  * Every day in January, for 3 years:
  * DTSTART;TZID=America/New_York:19980101T090000
  * RRULE:FREQ=DAILY;UNTIL=20000131T140000Z;BYMONTH=1
  */
 public function testThirtySeven()
 {
     $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 Recurrence();
     $r->recur('19980101T090000', 'daily')->until('20000131T140000')->bymonth(array(1));
     foreach ($results as $result) {
         $this->assertEquals($result, $r->next());
     }
 }
Exemple #3
0
 /**
  * The same day of every month:
  * RRULE:FREQ=MONTHLY
  */
 public function testTwentyThree()
 {
     $results[] = new DateTime('1997-09-14 09:00:00');
     $results[] = new DateTime('1997-10-14 09:00:00');
     $results[] = new DateTime('1997-11-14 09:00:00');
     $results[] = new DateTime('1997-12-14 09:00:00');
     $results[] = new DateTime('1998-01-14 09:00:00');
     $results[] = new DateTime('1998-02-14 09:00:00');
     $results[] = new DateTime('1998-03-14 09:00:00');
     $results[] = new DateTime('1998-04-14 09:00:00');
     $results[] = new DateTime('1998-05-14 09:00:00');
     $results[] = new DateTime('1998-06-14 09:00:00');
     $results[] = new DateTime('1998-07-14 09:00:00');
     $results[] = new DateTime('1998-08-14 09:00:00');
     $results[] = new DateTime('1998-09-14 09:00:00');
     $results[] = new DateTime('1998-10-14 09:00:00');
     $results[] = new DateTime('1998-11-14 09:00:00');
     $results[] = new DateTime('1998-12-14 09:00:00');
     $results[] = new DateTime('1999-01-14 09:00:00');
     $r = new Recurrence();
     $r->recur('19970914T090000')->count(17)->rrule('FREQ=MONTHLY');
     foreach ($results as $result) {
         $date = $r->next();
         $this->assertEquals($result, $date);
     }
 }
Exemple #4
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testValidFrequencies()
 {
     $r = new Recurrence();
     $r->recur('2000-01-01', 'yearlyy');
 }
Exemple #5
0
 /**
  * RRULE:FREQ=DAILY
  */
 public function testThirtyNine()
 {
     $results[] = new DateTime('1999-12-25 09:00:00');
     $results[] = new DateTime('1999-12-26 09:00:00');
     $results[] = new DateTime('1999-12-27 09:00:00');
     $results[] = new DateTime('1999-12-28 09:00:00');
     $results[] = new DateTime('1999-12-29 09:00:00');
     $results[] = new DateTime('1999-12-30 09:00:00');
     $results[] = new DateTime('1999-12-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');
     $r = new Recurrence();
     $r->recur('19991225T090000')->rrule('FREQ=DAILY');
     foreach ($results as $result) {
         $this->assertEquals($result, $r->next());
     }
 }
Exemple #6
0
 /**
  * The second-to-last weekday of the month:
  * DTSTART;TZID=America/New_York:19970929T090000
  * RRULE:FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-2
  */
 public function testTwentyTwo()
 {
     $results[] = new DateTime('1997-09-29 09:00:00');
     $results[] = new DateTime('1997-10-30 09:00:00');
     $results[] = new DateTime('1997-11-27 09:00:00');
     $results[] = new DateTime('1997-12-30 09:00:00');
     $results[] = new DateTime('1998-01-29 09:00:00');
     $results[] = new DateTime('1998-02-26 09:00:00');
     $results[] = new DateTime('1998-03-30 09:00:00');
     $r = new Recurrence();
     $r->recur('19970929T090000', 'monthly')->count(7)->byday(array('MO', 'TU', 'WE', 'TH', 'FR'))->bysetpos(array(-2));
     foreach ($results as $result) {
         $this->assertEquals($result, $r->next());
     }
 }
Exemple #7
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
  */
 public function testThirtyTwo()
 {
     $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 Recurrence();
     $r->recur('19970805T090000')->rrule('FREQ=WEEKLY;INTERVAL=2;COUNT=4;BYDAY=TU,SU;WKST=SU');
     foreach ($results as $result) {
         $this->assertEquals($result, $r->next());
     }
 }
Exemple #8
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
  */
 public function testThirtyTwo()
 {
     $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 Recurrence();
     $r->recur('19970805T090000', 'weekly')->interval(2)->count(4)->byday(array('TU', 'SU'))->wkst('SU');
     foreach ($results as $result) {
         $this->assertEquals($result, $r->next());
     }
 }
Exemple #9
0
 /**
  * Every year on the -1th, -100th, and -200th day for 5 occurrences (checked via google calendar import below)
  * BEGIN:VCALENDAR
  * PRODID:-//Google Inc//Google Calendar 70.9054//EN
  * VERSION:2.0
  * CALSCALE:GREGORIAN
  * METHOD:PUBLISH
  * BEGIN:VTIMEZONE
  * TZID:America/New_York
  * X-LIC-LOCATION:America/New_York
  * BEGIN:DAYLIGHT
  * TZOFFSETFROM:-0500
  * TZOFFSETTO:-0400
  * TZNAME:EDT
  * DTSTART:19700308T020000
  * RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU
  * END:DAYLIGHT
  * BEGIN:STANDARD
  * TZOFFSETFROM:-0400
  * TZOFFSETTO:-0500
  * TZNAME:EST
  * DTSTART:19701101T020000
  * RRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU
  * END:STANDARD
  * END:VTIMEZONE
  * BEGIN:VEVENT
  * DTSTART;VALUE=DATE:20101231
  * RRULE:FREQ=YEARLY;COUNT=5;BYYEARDAY=-1,-100,-200
  * DTSTAMP:20101231T090000
  * CREATED:20101231T090000
  * DESCRIPTION:
  * LAST-MODIFIED:20101231T090000
  * LOCATION:
  * SEQUENCE:2
  * STATUS:CONFIRMED
  * SUMMARY:testing yearly event
  * TRANSP:TRANSPARENT
  * END:VEVENT
  * END:VCALENDAR
  */
 public function testTwentyFour()
 {
     $results[] = new DateTime('2010-12-31 09:00:00');
     $results[] = new DateTime('2010-09-23 09:00:00');
     $results[] = new DateTime('2010-06-15 09:00:00');
     $results[] = new DateTime('2011-12-31 09:00:00');
     $results[] = new DateTime('2011-09-23 09:00:00');
     $r = new Recurrence();
     $r->recur('20101231T090000', 'yearly')->count(5)->byyearday(array(-1, -100, -200));
     foreach ($results as $result) {
         $this->assertEquals($result, $r->next());
     }
 }