mirror of
https://github.com/rlanvin/php-rrule.git
synced 2025-02-20 09:54:16 +01:00
Attempt to lower compatibility to PHP 5.3
This commit is contained in:
parent
fd31af6ae4
commit
3cf95e57ef
@ -1,5 +1,6 @@
|
||||
language: php
|
||||
php:
|
||||
- 5.3
|
||||
- 5.4
|
||||
- 5.5
|
||||
- 5.6
|
||||
|
@ -34,7 +34,7 @@ Complete doc is available in [the wiki](https://github.com/rlanvin/php-rrule/wik
|
||||
|
||||
## Requirements
|
||||
|
||||
- PHP >= 5.4
|
||||
- PHP >= 5.3
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "rlanvin/php-rrule",
|
||||
"type": "library",
|
||||
"description": "RRule implementation (RFC 5545)",
|
||||
"keywords": ["rrule","ical"],
|
||||
"description": "Lightweight RRule implementation (RFC 5545)",
|
||||
"keywords": ["rrule","ical","recurrence","recurring","date"],
|
||||
"homepage": "https://github.com/rlanvin/php-rrule",
|
||||
"license": "MIT",
|
||||
"require": {
|
||||
"php": ">=5.4.0"
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": ["src/"]
|
||||
|
@ -94,7 +94,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
const YEARLY = 1;
|
||||
|
||||
// frequency names
|
||||
public static $frequencies = [
|
||||
public static $frequencies = array(
|
||||
'SECONDLY' => self::SECONDLY,
|
||||
'MINUTELY' => self::MINUTELY,
|
||||
'HOURLY' => self::HOURLY,
|
||||
@ -102,10 +102,10 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
'WEEKLY' => self::WEEKLY,
|
||||
'MONTHLY' => self::MONTHLY,
|
||||
'YEARLY' => self::YEARLY
|
||||
];
|
||||
);
|
||||
|
||||
// weekdays numbered from 1 (ISO-8601 or date('N'))
|
||||
public static $week_days = [
|
||||
public static $week_days = array(
|
||||
'MO' => 1,
|
||||
'TU' => 2,
|
||||
'WE' => 3,
|
||||
@ -113,7 +113,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
'FR' => 5,
|
||||
'SA' => 6,
|
||||
'SU' => 7
|
||||
];
|
||||
);
|
||||
|
||||
// original rule
|
||||
protected $rule = array(
|
||||
@ -285,8 +285,8 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
if ( ! is_array($parts['BYDAY']) ) {
|
||||
$parts['BYDAY'] = explode(',',$parts['BYDAY']);
|
||||
}
|
||||
$this->byweekday = [];
|
||||
$this->byweekday_nth = [];
|
||||
$this->byweekday = array();
|
||||
$this->byweekday_nth = array();
|
||||
foreach ( $parts['BYDAY'] as $value ) {
|
||||
$value = trim($value);
|
||||
$valid = preg_match('/^([+-]?[0-9]+)?([A-Z]{2})$/', $value, $matches);
|
||||
@ -326,8 +326,8 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
$parts['BYMONTHDAY'] = explode(',',$parts['BYMONTHDAY']);
|
||||
}
|
||||
|
||||
$this->bymonthday = [];
|
||||
$this->bymonthday_negative = [];
|
||||
$this->bymonthday = array();
|
||||
$this->bymonthday_negative = array();
|
||||
foreach ( $parts['BYMONTHDAY'] as $value ) {
|
||||
if ( ! $value || $value < -31 || $value > 31 ) {
|
||||
throw new \InvalidArgumentException('Invalid BYMONTHDAY value: '.$value.' (valid values are 1 to 31 or -31 to -1)');
|
||||
@ -350,7 +350,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
$parts['BYYEARDAY'] = explode(',',$parts['BYYEARDAY']);
|
||||
}
|
||||
|
||||
$this->bysetpos = [];
|
||||
$this->bysetpos = array();
|
||||
foreach ( $parts['BYYEARDAY'] as $value ) {
|
||||
if ( ! $value || $value < -366 || $value > 366 ) {
|
||||
throw new \InvalidArgumentException('Invalid BYSETPOS value: '.$value.' (valid values are 1 to 366 or -366 to -1)');
|
||||
@ -370,7 +370,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
$parts['BYWEEKNO'] = explode(',',$parts['BYWEEKNO']);
|
||||
}
|
||||
|
||||
$this->byweekno = [];
|
||||
$this->byweekno = array();
|
||||
foreach ( $parts['BYWEEKNO'] as $value ) {
|
||||
if ( ! $value || $value < -53 || $value > 53 ) {
|
||||
throw new \InvalidArgumentException('Invalid BYWEEKNO value: '.$value.' (valid values are 1 to 53 or -53 to -1)');
|
||||
@ -386,7 +386,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
$parts['BYMONTH'] = explode(',',$parts['BYMONTH']);
|
||||
}
|
||||
|
||||
$this->bymonth = [];
|
||||
$this->bymonth = array();
|
||||
foreach ( $parts['BYMONTH'] as $value ) {
|
||||
if ( $value < 1 || $value > 12 ) {
|
||||
throw new \InvalidArgumentException('Invalid BYMONTH value: '.$value);
|
||||
@ -404,7 +404,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
$parts['BYSETPOS'] = explode(',',$parts['BYSETPOS']);
|
||||
}
|
||||
|
||||
$this->bysetpos = [];
|
||||
$this->bysetpos = array();
|
||||
foreach ( $parts['BYSETPOS'] as $value ) {
|
||||
if ( ! $value || $value < -366 || $value > 366 ) {
|
||||
throw new \InvalidArgumentException('Invalid BYSETPOS value: '.$value.' (valid values are 1 to 366 or -366 to -1)');
|
||||
@ -422,7 +422,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
$parts['BYHOUR'] = explode(',',$parts['BYHOUR']);
|
||||
}
|
||||
|
||||
$this->byhour = [];
|
||||
$this->byhour = array();
|
||||
foreach ( $parts['BYHOUR'] as $value ) {
|
||||
if ( $value < 0 || $value > 23 ) {
|
||||
throw new \InvalidArgumentException('Invalid BYHOUR value: '.$value);
|
||||
@ -443,7 +443,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
$parts['BYMINUTE'] = explode(',',$parts['BYMINUTE']);
|
||||
}
|
||||
|
||||
$this->byminute = [];
|
||||
$this->byminute = array();
|
||||
foreach ( $parts['BYMINUTE'] as $value ) {
|
||||
if ( $value < 0 || $value > 59 ) {
|
||||
throw new \InvalidArgumentException('Invalid BYMINUTE value: '.$value);
|
||||
@ -464,7 +464,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
$parts['BYSECOND'] = explode(',',$parts['BYSECOND']);
|
||||
}
|
||||
|
||||
$this->bysecond = [];
|
||||
$this->bysecond = array();
|
||||
foreach ( $parts['BYSECOND'] as $value ) {
|
||||
if ( $value < 0 || $value > 60 ) {
|
||||
throw new \InvalidArgumentException('Invalid BYSECOND value: '.$value);
|
||||
@ -506,7 +506,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
if ( ! $this->count && ! $this->until ) {
|
||||
throw new \LogicException('Cannot get all occurrences of an infinite recurrence rule.');
|
||||
}
|
||||
$res = [];
|
||||
$res = array();
|
||||
foreach ( $this as $occurrence ) {
|
||||
$res[] = $occurrence;
|
||||
}
|
||||
@ -518,7 +518,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
*/
|
||||
public function getOccurrencesBetween($begin, $end)
|
||||
{
|
||||
$res = [];
|
||||
$res = array();
|
||||
foreach ( $this as $occurrence ) {
|
||||
if ( $occurrence < $begin ) {
|
||||
continue;
|
||||
@ -779,7 +779,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
// crossing year boundary in reverse (i.e. if the week started
|
||||
// during the previous year), because that would generate
|
||||
// negative indexes (which would not work with the masks)
|
||||
$set = [];
|
||||
$set = array();
|
||||
$i = (int) date('z', mktime(0,0,0,$month,$day,$year));
|
||||
$start = $i;
|
||||
for ( $j = 0; $j < 7; $j++ ) {
|
||||
@ -793,7 +793,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
|
||||
case self::DAILY:
|
||||
$n = (int) date('z', mktime(0,0,0,$month,$day,$year));
|
||||
return [$n];
|
||||
return array($n);
|
||||
|
||||
case self::HOURLY:
|
||||
case self::MINUTELY:
|
||||
@ -820,15 +820,21 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
if ( $this->freq == self::YEARLY ) {
|
||||
if ( $this->bymonth ) {
|
||||
foreach ( $this->bymonth as $bymonth ) {
|
||||
$ranges[] = [$masks['last_day_of_month'][$bymonth-1], $masks['last_day_of_month'][$bymonth]-1];
|
||||
$ranges[] = array(
|
||||
$masks['last_day_of_month'][$bymonth - 1],
|
||||
$masks['last_day_of_month'][$bymonth] - 1
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$ranges = [[0,$masks['year_len']-1]];
|
||||
$ranges = array(array(0, $masks['year_len'] - 1));
|
||||
}
|
||||
}
|
||||
elseif ( $this->freq == self::MONTHLY ) {
|
||||
$ranges[] = [$masks['last_day_of_month'][$month-1], $masks['last_day_of_month'][$month]-1];
|
||||
$ranges[] = array(
|
||||
$masks['last_day_of_month'][$month - 1],
|
||||
$masks['last_day_of_month'][$month] - 1
|
||||
);
|
||||
}
|
||||
|
||||
if ( $ranges ) {
|
||||
@ -1119,7 +1125,7 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
|
||||
// XXX this needs to be applied after expanding the timeset
|
||||
if ( $this->bysetpos ) {
|
||||
$filtered_set = [];
|
||||
$filtered_set = array();
|
||||
$n = sizeof($current_set);
|
||||
foreach ( $this->bysetpos as $pos ) {
|
||||
if ( $pos < 0 ) {
|
||||
@ -1185,11 +1191,11 @@ class RRule implements \Iterator, \ArrayAccess
|
||||
break;
|
||||
case self::WEEKLY:
|
||||
// here we take a little shortcut from the Python version, by using DateTime
|
||||
list($year,$month,$day) = explode('-',(new \DateTime("$year-$month-$day"))->modify('+'.($this->interval*7).'day')->format('Y-n-j'));
|
||||
list($year,$month,$day) = explode('-',date_create("$year-$month-$day")->modify('+'.($this->interval*7).'day')->format('Y-n-j'));
|
||||
break;
|
||||
case self::DAILY:
|
||||
// here we take a little shortcut from the Python version, by using DateTime
|
||||
list($year,$month,$day) = explode('-',(new \DateTime("$year-$month-$day"))->modify('+'.$this->interval.'day')->format('Y-n-j'));
|
||||
list($year,$month,$day) = explode('-',date_create("$year-$month-$day")->modify('+'.$this->interval.'day')->format('Y-n-j'));
|
||||
break;
|
||||
case self::HOURLY:
|
||||
case self::MINUTELY:
|
||||
|
@ -7,38 +7,38 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
public function invalidRules()
|
||||
{
|
||||
return array(
|
||||
array([]),
|
||||
array(['FREQ' => 'foobar']),
|
||||
array(['FREQ' => 'DAILY', 'INTERVAL' => -1]),
|
||||
array(['FREQ' => 'DAILY', 'UNTIL' => 'foobar']),
|
||||
array(['FREQ' => 'DAILY', 'COUNT' => -1]),
|
||||
array(array()),
|
||||
array(array('FREQ' => 'foobar')),
|
||||
array(array('FREQ' => 'DAILY', 'INTERVAL' => -1)),
|
||||
array(array('FREQ' => 'DAILY', 'UNTIL' => 'foobar')),
|
||||
array(array('FREQ' => 'DAILY', 'COUNT' => -1)),
|
||||
|
||||
// The BYDAY rule part MUST NOT be specified with a numeric value
|
||||
// when the FREQ rule part is not set to MONTHLY or YEARLY.
|
||||
array(['FREQ' => 'DAILY', 'BYDAY' => ['1MO']]),
|
||||
array(['FREQ' => 'WEEKLY', 'BYDAY' => ['1MO']]),
|
||||
array(array('FREQ' => 'DAILY', 'BYDAY' => array('1MO'))),
|
||||
array(array('FREQ' => 'WEEKLY', 'BYDAY' => array('1MO'))),
|
||||
// The BYDAY rule part MUST NOT be specified with a numeric value
|
||||
// with the FREQ rule part set to YEARLY when the BYWEEKNO rule part is specified.
|
||||
array(['FREQ' => 'YEARLY', 'BYDAY' => ['1MO'], 'BYWEEKNO' => 20]),
|
||||
array(array('FREQ' => 'YEARLY', 'BYDAY' => array('1MO'), 'BYWEEKNO' => 20)),
|
||||
|
||||
array(['FREQ' => 'DAILY', 'BYMONTHDAY' => 0]),
|
||||
array(['FREQ' => 'DAILY', 'BYMONTHDAY' => 32]),
|
||||
array(['FREQ' => 'DAILY', 'BYMONTHDAY' => -32]),
|
||||
array(array('FREQ' => 'DAILY', 'BYMONTHDAY' => 0)),
|
||||
array(array('FREQ' => 'DAILY', 'BYMONTHDAY' => 32)),
|
||||
array(array('FREQ' => 'DAILY', 'BYMONTHDAY' => -32)),
|
||||
// The BYMONTHDAY rule part MUST NOT be specified when the FREQ rule
|
||||
// part is set to WEEKLY.
|
||||
array(['FREQ' => 'WEEKLY', 'BYMONTHDAY' => 1]),
|
||||
array(array('FREQ' => 'WEEKLY', 'BYMONTHDAY' => 1)),
|
||||
|
||||
array(['FREQ' => 'YEARLY', 'BYYEARDAY' => 0]),
|
||||
array(['FREQ' => 'YEARLY', 'BYYEARDAY' => 367]),
|
||||
array(array('FREQ' => 'YEARLY', 'BYYEARDAY' => 0)),
|
||||
array(array('FREQ' => 'YEARLY', 'BYYEARDAY' => 367)),
|
||||
// The BYYEARDAY rule part MUST NOT be specified when the FREQ
|
||||
// rule part is set to DAILY, WEEKLY, or MONTHLY.
|
||||
array(['FREQ' => 'DAILY', 'BYYEARDAY' => 1]),
|
||||
array(['FREQ' => 'WEEKLY', 'BYYEARDAY' => 1]),
|
||||
array(['FREQ' => 'MONTHLY', 'BYYEARDAY' => 1]),
|
||||
array(array('FREQ' => 'DAILY', 'BYYEARDAY' => 1)),
|
||||
array(array('FREQ' => 'WEEKLY', 'BYYEARDAY' => 1)),
|
||||
array(array('FREQ' => 'MONTHLY', 'BYYEARDAY' => 1)),
|
||||
|
||||
// BYSETPOS rule part MUST only be used in conjunction with another
|
||||
// BYxxx rule part.
|
||||
array(['FREQ' => 'DAILY', 'BYSETPOS' => -1]),
|
||||
array(array('FREQ' => 'DAILY', 'BYSETPOS' => -1)),
|
||||
);
|
||||
}
|
||||
|
||||
@ -59,48 +59,48 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertTrue(\RRule\is_leap_year(2000));
|
||||
}
|
||||
|
||||
// date_create\(([0-9]+), ([0-9]+), ([0-9]+)[ ,0-9\)]+
|
||||
// date_create\((array(0-9)+), (array(0-9)+), (array(0-9)+)array( ,0-9\))+
|
||||
|
||||
public function yearlyRules()
|
||||
{
|
||||
return array(
|
||||
array([],[date_create('1997-09-02'),date_create('1998-09-02'), date_create('1999-09-02')]),
|
||||
array(['INTERVAL' => 2], [date_create('1997-09-02'),date_create('1999-09-02'),date_create('2001-09-02')]),
|
||||
array(['DTSTART' => '2000-02-29'], [date_create('2000-02-29'),date_create('2004-02-29'),date_create('2008-02-29')]),
|
||||
array(['BYMONTH' => [1,3]], [date_create('1998-01-02'),date_create('1998-03-02'),date_create('1999-01-02')]),
|
||||
array(['BYMONTHDAY' => [1,3]], [date_create('1997-09-03'),date_create('1997-10-01'),date_create('1997-10-03')]),
|
||||
array(['BYMONTH' => [1,3], 'BYMONTHDAY' => [5,7]], [date_create('1998-01-05'),date_create('1998-01-07'),date_create('1998-03-05')]),
|
||||
array(['BYDAY' => ['TU','TH']], [date_create('1997-09-02'),date_create('1997-09-04'),date_create('1997-09-09')]),
|
||||
array(['BYDAY' => ['SU']], [date_create('1997-09-07'),date_create('1997-09-14'),date_create('1997-09-21')]),
|
||||
array(['BYDAY' => ['1TU','-1TH']], [date_create('1997-12-25'),date_create('1998-01-06'),date_create('1998-12-31')]),
|
||||
array(['BYDAY' => ['3TU','-3TH']], [date_create('1997-12-11'),date_create('1998-01-20'),date_create('1998-12-17')]),
|
||||
array(['BYMONTH' => [1,3], 'BYDAY' => ['TU','TH']], [date_create('1998-01-01'),date_create('1998-01-06'),date_create('1998-01-08')]),
|
||||
array(['BYMONTH' => [1,3], 'BYDAY' => ['1TU','-1TH']], [date_create('1998-01-06'),date_create('1998-01-29'),date_create('1998-03-03')]),
|
||||
array(array(),array(date_create('1997-09-02'),date_create('1998-09-02'), date_create('1999-09-02'))),
|
||||
array(array('INTERVAL' => 2), array(date_create('1997-09-02'),date_create('1999-09-02'),date_create('2001-09-02'))),
|
||||
array(array('DTSTART' => '2000-02-29'), array(date_create('2000-02-29'),date_create('2004-02-29'),date_create('2008-02-29'))),
|
||||
array(array('BYMONTH' => array(1,3)), array(date_create('1998-01-02'),date_create('1998-03-02'),date_create('1999-01-02'))),
|
||||
array(array('BYMONTHDAY' => array(1,3)), array(date_create('1997-09-03'),date_create('1997-10-01'),date_create('1997-10-03'))),
|
||||
array(array('BYMONTH' => array(1,3), 'BYMONTHDAY' => array(5,7)), array(date_create('1998-01-05'),date_create('1998-01-07'),date_create('1998-03-05'))),
|
||||
array(array('BYDAY' => array('TU','TH')), array(date_create('1997-09-02'),date_create('1997-09-04'),date_create('1997-09-09'))),
|
||||
array(array('BYDAY' => array('SU')), array(date_create('1997-09-07'),date_create('1997-09-14'),date_create('1997-09-21'))),
|
||||
array(array('BYDAY' => array('1TU','-1TH')), array(date_create('1997-12-25'),date_create('1998-01-06'),date_create('1998-12-31'))),
|
||||
array(array('BYDAY' => array('3TU','-3TH')), array(date_create('1997-12-11'),date_create('1998-01-20'),date_create('1998-12-17'))),
|
||||
array(array('BYMONTH' => array(1,3), 'BYDAY' => array('TU','TH')), array(date_create('1998-01-01'),date_create('1998-01-06'),date_create('1998-01-08'))),
|
||||
array(array('BYMONTH' => array(1,3), 'BYDAY' => array('1TU','-1TH')), array(date_create('1998-01-06'),date_create('1998-01-29'),date_create('1998-03-03'))),
|
||||
// This is interesting because the TH(-3) ends up before the TU(3).
|
||||
array(['BYMONTH' => [1,3], 'BYDAY' => ['3TU','-3TH']], [date_create('1998-01-15'),date_create('1998-01-20'),date_create('1998-03-12')]),
|
||||
array(['BYMONTHDAY' => [1,3], 'BYDAY' => ['TU','TH']], [date_create('1998-01-01'),date_create('1998-02-03'),date_create('1998-03-03')]),
|
||||
array(['BYMONTHDAY' => [1,3], 'BYDAY' => ['TU','TH'], 'BYMONTH' => [1,3]], [date_create('1998-01-01'),date_create('1998-03-03'),date_create('2001-03-01')]),
|
||||
array(['BYYEARDAY' => [1,100,200,365], 'COUNT' => 4], [date_create('1997-12-31'),date_create('1998-01-01'),date_create('1998-04-10'), date_create('1998-07-19')]),
|
||||
array(['BYYEARDAY' => [-365, -266, -166, -1], 'COUNT' => 4], [date_create('1997-12-31'),date_create('1998-01-01'),date_create('1998-04-10'), date_create('1998-07-19')]),
|
||||
array(['BYYEARDAY' => [1,100,200,365], 'BYMONTH' => [4,7], 'COUNT' => 4], [date_create('1998-04-10'),date_create('1998-07-19'),date_create('1999-04-10'), date_create('1999-07-19')]),
|
||||
array(['BYYEARDAY' => [-365, -266, -166, -1], 'BYMONTH' => [4,7], 'COUNT' => 4], [date_create('1998-04-10'),date_create('1998-07-19'),date_create('1999-04-10'), date_create('1999-07-19')]),
|
||||
array(['BYWEEKNO' => 20],[date_create('1998-05-11'),date_create('1998-05-12'),date_create('1998-05-13')]),
|
||||
array(array('BYMONTH' => array(1,3), 'BYDAY' => array('3TU','-3TH')), array(date_create('1998-01-15'),date_create('1998-01-20'),date_create('1998-03-12'))),
|
||||
array(array('BYMONTHDAY' => array(1,3), 'BYDAY' => array('TU','TH')), array(date_create('1998-01-01'),date_create('1998-02-03'),date_create('1998-03-03'))),
|
||||
array(array('BYMONTHDAY' => array(1,3), 'BYDAY' => array('TU','TH'), 'BYMONTH' => array(1,3)), array(date_create('1998-01-01'),date_create('1998-03-03'),date_create('2001-03-01'))),
|
||||
array(array('BYYEARDAY' => array(1,100,200,365), 'COUNT' => 4), array(date_create('1997-12-31'),date_create('1998-01-01'),date_create('1998-04-10'), date_create('1998-07-19'))),
|
||||
array(array('BYYEARDAY' => array(-365, -266, -166, -1), 'COUNT' => 4), array(date_create('1997-12-31'),date_create('1998-01-01'),date_create('1998-04-10'), date_create('1998-07-19'))),
|
||||
array(array('BYYEARDAY' => array(1,100,200,365), 'BYMONTH' => array(4,7), 'COUNT' => 4), array(date_create('1998-04-10'),date_create('1998-07-19'),date_create('1999-04-10'), date_create('1999-07-19'))),
|
||||
array(array('BYYEARDAY' => array(-365, -266, -166, -1), 'BYMONTH' => array(4,7), 'COUNT' => 4), array(date_create('1998-04-10'),date_create('1998-07-19'),date_create('1999-04-10'), date_create('1999-07-19'))),
|
||||
array(array('BYWEEKNO' => 20),array(date_create('1998-05-11'),date_create('1998-05-12'),date_create('1998-05-13'))),
|
||||
// That's a nice one. The first days of week number one may be in the last year.
|
||||
array(['BYWEEKNO' => 1, 'BYDAY' => 'MO'], [date_create('1997-12-29'), date_create('1999-01-04'), date_create('2000-01-03')]),
|
||||
array(array('BYWEEKNO' => 1, 'BYDAY' => 'MO'), array(date_create('1997-12-29'), date_create('1999-01-04'), date_create('2000-01-03'))),
|
||||
// Another nice test. The last days of week number 52/53 may be in the next year.
|
||||
array(['BYWEEKNO' => 52, 'BYDAY' => 'SU'], [date_create('1997-12-28'), date_create('1998-12-27'), date_create('2000-01-02')]),
|
||||
array(['BYWEEKNO' => -1, 'BYDAY' => 'SU'], [date_create('1997-12-28'), date_create('1999-01-03'), date_create('2000-01-02')]),
|
||||
array(['BYWEEKNO' => 53, 'BYDAY' => 'MO'], [date_create('1998-12-28'), date_create('2004-12-27'), date_create('2009-12-28')]),
|
||||
array(array('BYWEEKNO' => 52, 'BYDAY' => 'SU'), array(date_create('1997-12-28'), date_create('1998-12-27'), date_create('2000-01-02'))),
|
||||
array(array('BYWEEKNO' => -1, 'BYDAY' => 'SU'), array(date_create('1997-12-28'), date_create('1999-01-03'), date_create('2000-01-02'))),
|
||||
array(array('BYWEEKNO' => 53, 'BYDAY' => 'MO'), array(date_create('1998-12-28'), date_create('2004-12-27'), date_create('2009-12-28'))),
|
||||
|
||||
// FIXME (time part missing)
|
||||
// array(['BYHOUR' => [6, 18]], [date_create('1997-09-02'),date_create('1998-09-02'),date_create('1998-09-02')]),
|
||||
// array(['BYMINUTE'=> [6, 18]], ['1997-09-02', '1997-09-02', '1998-09-02']),
|
||||
// array(['BYSECOND' => [6, 18]], ['1997-09-02', '1997-09-02', '1998-09-02']),
|
||||
// array(['BYHOUR' => [6, 18], 'BYMINUTE' => [6, 18]], ['1997-09-02','1997-09-02','1998-09-02']),
|
||||
// array(['BYHOUR' => [6, 18], 'BYSECOND' => [6, 18]], ['1997-09-02','1997-09-02','1998-09-02']),
|
||||
// array(['BYMINUTE' => [6, 18], 'BYSECOND' => [6, 18]], ['1997-09-02','1997-09-02','1997-09-02']),
|
||||
// array(['BYHOUR'=>[6, 18],'BYMINUTE'=>[6, 18],'BYSECOND'=>[6, 18]],['1997-09-02','1997-09-02','1997-09-02']),
|
||||
// array(['BYMONTHDAY'=>15,'BYHOUR'=>[6, 18],'BYSETPOS'=>[3, -3],[date_create('1997-11-15'),date_create('1998-02-15'),date_create('1998-11-15')])
|
||||
// array(array('BYHOUR' => array(6, 18)), array(date_create('1997-09-02'),date_create('1998-09-02'),date_create('1998-09-02'))),
|
||||
// array(array('BYMINUTE'=> array(6, 18)), array('1997-09-02', '1997-09-02', '1998-09-02')),
|
||||
// array(array('BYSECOND' => array(6, 18)), array('1997-09-02', '1997-09-02', '1998-09-02')),
|
||||
// array(array('BYHOUR' => array(6, 18), 'BYMINUTE' => array(6, 18)), array('1997-09-02','1997-09-02','1998-09-02')),
|
||||
// array(array('BYHOUR' => array(6, 18), 'BYSECOND' => array(6, 18)), array('1997-09-02','1997-09-02','1998-09-02')),
|
||||
// array(array('BYMINUTE' => array(6, 18), 'BYSECOND' => array(6, 18)), array('1997-09-02','1997-09-02','1997-09-02')),
|
||||
// array(array('BYHOUR'=>array(6, 18),'BYMINUTE'=>array(6, 18),'BYSECOND'=>array(6, 18)),array('1997-09-02','1997-09-02','1997-09-02')),
|
||||
// array(array('BYMONTHDAY'=>15,'BYHOUR'=>array(6, 18),'BYSETPOS'=>array(3, -3),array(date_create('1997-11-15'),date_create('1998-02-15'),date_create('1998-11-15')))
|
||||
);
|
||||
}
|
||||
|
||||
@ -109,11 +109,11 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testYearly($rule, $occurrences)
|
||||
{
|
||||
$rule = new RRule(array_merge([
|
||||
$rule = new RRule(array_merge(array(
|
||||
'FREQ' => 'YEARLY',
|
||||
'COUNT' => 3,
|
||||
'DTSTART' => '1997-09-02'
|
||||
], $rule));
|
||||
), $rule));
|
||||
$this->assertEquals($occurrences, $rule->getOccurrences());
|
||||
foreach ( $occurrences as $date ) {
|
||||
$this->assertTrue($rule->occursAt($date), $date->format('r'));
|
||||
@ -124,31 +124,31 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
public function monthlyRules()
|
||||
{
|
||||
return array(
|
||||
array([],[date_create('1997-09-02'),date_create('1997-10-02'),date_create('1997-11-02')]),
|
||||
array(['INTERVAL'=>2],[date_create('1997-09-02'),date_create('1997-11-02'),date_create('1998-01-02')]),
|
||||
array(['INTERVAL'=>18],[date_create('1997-09-02'),date_create('1999-03-02'),date_create('2000-09-02')]),
|
||||
array(['BYMONTH' => [1, 3]],[date_create('1998-01-02'),date_create('1998-03-02'),date_create('1999-01-02')]),
|
||||
array(['BYMONTHDAY' => [1, 3]],[date_create('1997-09-03'),date_create('1997-10-01'),date_create('1997-10-03')]),
|
||||
array(['BYMONTHDAY' => [5, 7], 'BYMONTH' => [1, 3]], [date_create('1998-01-05'), date_create('1998-01-07'), date_create('1998-03-05')]),
|
||||
array(['BYDAY' => ['TU', 'TH']], [date_create('1997-09-02'),date_create('1997-09-04'),date_create('1997-09-09')]),
|
||||
array(array(),array(date_create('1997-09-02'),date_create('1997-10-02'),date_create('1997-11-02'))),
|
||||
array(array('INTERVAL'=>2),array(date_create('1997-09-02'),date_create('1997-11-02'),date_create('1998-01-02'))),
|
||||
array(array('INTERVAL'=>18),array(date_create('1997-09-02'),date_create('1999-03-02'),date_create('2000-09-02'))),
|
||||
array(array('BYMONTH' => array(1, 3)),array(date_create('1998-01-02'),date_create('1998-03-02'),date_create('1999-01-02'))),
|
||||
array(array('BYMONTHDAY' => array(1, 3)),array(date_create('1997-09-03'),date_create('1997-10-01'),date_create('1997-10-03'))),
|
||||
array(array('BYMONTHDAY' => array(5, 7), 'BYMONTH' => array(1, 3)), array(date_create('1998-01-05'), date_create('1998-01-07'), date_create('1998-03-05'))),
|
||||
array(array('BYDAY' => array('TU', 'TH')), array(date_create('1997-09-02'),date_create('1997-09-04'),date_create('1997-09-09'))),
|
||||
// Third Monday of the month
|
||||
array(['BYDAY' => '3MO'],[date_create('1997-09-15'),date_create('1997-10-20'),date_create('1997-11-17')]),
|
||||
array(['BYDAY' => '1TU,-1TH'],[date_create('1997-09-02'),date_create('1997-09-25'),date_create('1997-10-07')]),
|
||||
array(['BYDAY' => '3TU,-3TH'],[date_create('1997-09-11'),date_create('1997-09-16'),date_create('1997-10-16')]),
|
||||
array(['BYDAY' => 'TU,TH', 'BYMONTH' => [1, 3]],[date_create('1998-01-01'),date_create('1998-01-06'),date_create('1998-01-08')]),
|
||||
array(['BYMONTH' => [1, 3], 'BYDAY' => '1TU, -1TH'],[date_create('1998-01-06'),date_create('1998-01-29'),date_create('1998-03-03')]),
|
||||
array(['BYMONTH' => [1, 3], 'BYDAY' => '3TU, -3TH'],[date_create('1998-01-15'),date_create('1998-01-20'),date_create('1998-03-12')]),
|
||||
array(['BYMONTHDAY' => [1, 3], 'BYDAY' => ['TU', 'TH']], [date_create('1998-01-01'),date_create('1998-02-03'),date_create('1998-03-03')]),
|
||||
array(['BYMONTH' => [1, 3], 'BYMONTHDAY' => [1, 3], 'BYDAY' => ['TU', 'TH']],[date_create('1998-01-01'),date_create('1998-03-03'),date_create('2001-03-01')]),
|
||||
array(array('BYDAY' => '3MO'),array(date_create('1997-09-15'),date_create('1997-10-20'),date_create('1997-11-17'))),
|
||||
array(array('BYDAY' => '1TU,-1TH'),array(date_create('1997-09-02'),date_create('1997-09-25'),date_create('1997-10-07'))),
|
||||
array(array('BYDAY' => '3TU,-3TH'),array(date_create('1997-09-11'),date_create('1997-09-16'),date_create('1997-10-16'))),
|
||||
array(array('BYDAY' => 'TU,TH', 'BYMONTH' => array(1, 3)),array(date_create('1998-01-01'),date_create('1998-01-06'),date_create('1998-01-08'))),
|
||||
array(array('BYMONTH' => array(1, 3), 'BYDAY' => '1TU, -1TH'),array(date_create('1998-01-06'),date_create('1998-01-29'),date_create('1998-03-03'))),
|
||||
array(array('BYMONTH' => array(1, 3), 'BYDAY' => '3TU, -3TH'),array(date_create('1998-01-15'),date_create('1998-01-20'),date_create('1998-03-12'))),
|
||||
array(array('BYMONTHDAY' => array(1, 3), 'BYDAY' => array('TU', 'TH')), array(date_create('1998-01-01'),date_create('1998-02-03'),date_create('1998-03-03'))),
|
||||
array(array('BYMONTH' => array(1, 3), 'BYMONTHDAY' => array(1, 3), 'BYDAY' => array('TU', 'TH')),array(date_create('1998-01-01'),date_create('1998-03-03'),date_create('2001-03-01'))),
|
||||
|
||||
// array(['BYHOUR'=> [6, 18],['1997-09-02',date_create('1997-10-02'),date_create('1997-10-02')]),
|
||||
// array(['BYMINUTE'=> [6, 18],['1997-09-02','1997-09-02',date_create('1997-10-02')]),
|
||||
// array(['BYSECOND' => [6, 18],['1997-09-02','1997-09-02',date_create('1997-10-02')]),
|
||||
// array(['BYHOUR'=>[6, 18],'BYMINUTE'=>[6, 18]],['1997-09-02','1997-09-02',date_create('1997-10-02')]),
|
||||
// array(['BYHOUR'=>[6, 18],'BYSECOND'=>[6, 18]],['1997-09-02','1997-09-02',date_create('1997-10-02')]),
|
||||
// array(['BYMINUTE'=>[6, 18],'BYSECOND'=>[6, 18]],['1997-09-02','1997-09-02','1997-09-02']),
|
||||
// array(['BYHOUR'=>[6, 18],'BYMINUTE'=>[6, 18],'BYSECOND'=>[6, 18]],['1997-09-02','1997-09-02','1997-09-02']),
|
||||
// array(['BYMONTHDAY'=>[13, 17],'BYHOUR'=>[6, 18],'BYSETPOS'=>[3, -3]],[date_create('1997-09-13'),date_create('1997-09-17'),date_create('1997-10-13')])
|
||||
// array(array('BYHOUR'=> array(6, 18),array('1997-09-02',date_create('1997-10-02'),date_create('1997-10-02'))),
|
||||
// array(array('BYMINUTE'=> array(6, 18),array('1997-09-02','1997-09-02',date_create('1997-10-02'))),
|
||||
// array(array('BYSECOND' => array(6, 18),array('1997-09-02','1997-09-02',date_create('1997-10-02'))),
|
||||
// array(array('BYHOUR'=>array(6, 18),'BYMINUTE'=>array(6, 18)),array('1997-09-02','1997-09-02',date_create('1997-10-02'))),
|
||||
// array(array('BYHOUR'=>array(6, 18),'BYSECOND'=>array(6, 18)),array('1997-09-02','1997-09-02',date_create('1997-10-02'))),
|
||||
// array(array('BYMINUTE'=>array(6, 18),'BYSECOND'=>array(6, 18)),array('1997-09-02','1997-09-02','1997-09-02')),
|
||||
// array(array('BYHOUR'=>array(6, 18),'BYMINUTE'=>array(6, 18),'BYSECOND'=>array(6, 18)),array('1997-09-02','1997-09-02','1997-09-02')),
|
||||
// array(array('BYMONTHDAY'=>array(13, 17),'BYHOUR'=>array(6, 18),'BYSETPOS'=>array(3, -3)),array(date_create('1997-09-13'),date_create('1997-09-17'),date_create('1997-10-13')))
|
||||
);
|
||||
}
|
||||
|
||||
@ -157,11 +157,11 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testMonthly($rule, $occurrences)
|
||||
{
|
||||
$rule = new RRule(array_merge([
|
||||
$rule = new RRule(array_merge(array(
|
||||
'FREQ' => 'MONTHLY',
|
||||
'COUNT' => 3,
|
||||
'DTSTART' => '1997-09-02'
|
||||
], $rule));
|
||||
), $rule));
|
||||
$this->assertEquals($occurrences, $rule->getOccurrences());
|
||||
foreach ( $occurrences as $date ) {
|
||||
$this->assertTrue($rule->occursAt($date), $date->format('r'));
|
||||
@ -171,25 +171,25 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
public function weeklyRules()
|
||||
{
|
||||
return array(
|
||||
array([],[date_create('1997-09-02'), date_create('1997-09-09'), date_create('1997-09-16')]),
|
||||
array(['interval'=>2],[date_create('1997-09-02'),date_create('1997-09-16'),date_create('1997-09-30')]),
|
||||
array(['interval'=>20],[date_create('1997-09-02'),date_create('1998-01-20'),date_create('1998-06-09')]),
|
||||
array(['bymonth'=>[1, 3]],[date_create('1998-01-06'),date_create('1998-01-13'),date_create('1998-01-20')]),
|
||||
array(['byday'=> ['TU', 'TH']],[date_create('1997-09-02'), date_create('1997-09-04'), date_create('1997-09-09')]),
|
||||
array(array(),array(date_create('1997-09-02'), date_create('1997-09-09'), date_create('1997-09-16'))),
|
||||
array(array('interval'=>2),array(date_create('1997-09-02'),date_create('1997-09-16'),date_create('1997-09-30'))),
|
||||
array(array('interval'=>20),array(date_create('1997-09-02'),date_create('1998-01-20'),date_create('1998-06-09'))),
|
||||
array(array('bymonth'=>array(1, 3)),array(date_create('1998-01-06'),date_create('1998-01-13'),date_create('1998-01-20'))),
|
||||
array(array('byday'=> array('TU', 'TH')),array(date_create('1997-09-02'), date_create('1997-09-04'), date_create('1997-09-09'))),
|
||||
|
||||
# This test is interesting, because it crosses the year
|
||||
# boundary in a weekly period to find day '1' as a
|
||||
# valid recurrence.
|
||||
array(['bymonth'=>[1, 3],'byday'=>['TU', 'TH']],[date_create('1998-01-01'), date_create('1998-01-06'), date_create('1998-01-08')]),
|
||||
array(array('bymonth'=>array(1, 3),'byday'=>array('TU', 'TH')),array(date_create('1998-01-01'), date_create('1998-01-06'), date_create('1998-01-08'))),
|
||||
|
||||
// array(['byhour'=>[6, 18]],[date_create('1997-09-02'),date_create('1997-09-09'),date_create('1997-09-09')]),
|
||||
// array(['byminute'=>[6, 18]],[date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-09')]),
|
||||
// array(['bysecond'=> [6, 18]],[date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-09')]),
|
||||
// array(['byhour'=> [6, 18],'byminute'=>[6, 18]],[date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-09')]),
|
||||
// array(['byhour'=>[6, 18],'bysecond'=>[6, 18]],[date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-09')]),
|
||||
// array(['byminute'=>[6, 18],'bysecond'=>[6, 18]],[date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-02')]),
|
||||
// array(['byhour'=>[6, 18],'byminute'=>[6, 18],'bysecond'=>[6, 18]],[date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-02')]),
|
||||
// array(['byday'=>['TU', 'TH'],'byhour'=>[6, 18],'bysetpos'=>[3, -3]],[date_create('1997-09-02'),date_create('1997-09-04'),date_create('1997-09-09')])
|
||||
// array(array('byhour'=>array(6, 18)),array(date_create('1997-09-02'),date_create('1997-09-09'),date_create('1997-09-09'))),
|
||||
// array(array('byminute'=>array(6, 18)),array(date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-09'))),
|
||||
// array(array('bysecond'=> array(6, 18)),array(date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-09'))),
|
||||
// array(array('byhour'=> array(6, 18),'byminute'=>array(6, 18)),array(date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-09'))),
|
||||
// array(array('byhour'=>array(6, 18),'bysecond'=>array(6, 18)),array(date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-09'))),
|
||||
// array(array('byminute'=>array(6, 18),'bysecond'=>array(6, 18)),array(date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-02'))),
|
||||
// array(array('byhour'=>array(6, 18),'byminute'=>array(6, 18),'bysecond'=>array(6, 18)),array(date_create('1997-09-02'),date_create('1997-09-02'),date_create('1997-09-02'))),
|
||||
// array(array('byday'=>array('TU', 'TH'),'byhour'=>array(6, 18),'bysetpos'=>array(3, -3)),array(date_create('1997-09-02'),date_create('1997-09-04'),date_create('1997-09-09')))
|
||||
);
|
||||
}
|
||||
/**
|
||||
@ -197,11 +197,11 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testWeekly($rule, $occurrences)
|
||||
{
|
||||
$rule = new RRule(array_merge([
|
||||
$rule = new RRule(array_merge(array(
|
||||
'FREQ' => 'WEEKLY',
|
||||
'COUNT' => 3,
|
||||
'DTSTART' => '1997-09-02'
|
||||
], $rule));
|
||||
), $rule));
|
||||
$this->assertEquals($occurrences, $rule->getOccurrences());
|
||||
foreach ( $occurrences as $date ) {
|
||||
$this->assertTrue($rule->occursAt($date), $date->format('r'));
|
||||
@ -211,25 +211,25 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
public function dailyRules()
|
||||
{
|
||||
return array(
|
||||
array([], [date_create('1997-09-02'),date_create('1997-09-03'),date_create('1997-09-04')]),
|
||||
array(['interval'=>2],[date_create('1997-09-02'), date_create('1997-09-04'), date_create('1997-09-06')]),
|
||||
array(['interval'=>92],[date_create('1997-09-02'), date_create('1997-12-03'), date_create('1998-03-05')]),
|
||||
array(['bymonth'=>[1, 3]],[date_create('1998-01-01'), date_create('1998-01-02'), date_create('1998-01-03')]),
|
||||
array(['bymonthday'=>[1, 3]],[date_create('1997-09-03'), date_create('1997-10-01'), date_create('1997-10-03')]),
|
||||
array(['bymonth'=>[1, 3],'bymonthday'=>[5, 7]],[date_create('1998-01-05'), date_create('1998-01-07'), date_create('1998-03-05')]),
|
||||
array(['byday'=>['TU', 'TH']],[date_create('1997-09-02'), date_create('1997-09-04'), date_create('1997-09-09')]),
|
||||
array(['bymonth'=> [1, 3], 'byday'=> ['TU', 'TH']],[date_create('1998-01-01'), date_create('1998-01-06'), date_create('1998-01-08')]),
|
||||
array(['bymonthday'=> [1, 3], 'byday'=>['TU', 'TH']],[date_create('1998-01-01'), date_create('1998-02-03'), date_create('1998-03-03')]),
|
||||
array(['bymonth'=>[1, 3],'bymonthday'=>[1, 3],'byday'=>['TU', 'TH']],[date_create('1998-01-01'), date_create('1998-03-03'), date_create('2001-03-01')]),
|
||||
// array(['count'=>4,'byyearday'=>[1, 100, 200, 365]],[date_create('1997-12-31'), date_create('1998-01-01'), date_create('1998-04-10'), date_create('1998-07-19')]),
|
||||
// array(['count'=>4,'byyearday'=>[-365, -266, -166, -1]],[date_create('1997-12-31'), date_create('1998-01-01'), date_create('1998-04-10'), date_create('1998-07-19')]),
|
||||
// array(['count'=>4, 'bymonth'=>[1, 7],'byyearday'=>[1, 100, 200, 365]],[date_create('1998-01-01'),date_create('1998-07-19'),date_create('1999-01-01'),date_create('1999-07-19')]),
|
||||
// array(['count'=>4, 'bymonth' => [1, 7], 'byyearday' => [-365, -266, -166, -1]],[date_create('1998-01-01'), date_create('1998-07-19'), date_create('1999-01-01'), date_create('1999-07-19')]),
|
||||
// array(['byweekno' => 20], [date_create('1998-05-11'), date_create('1998-05-12'), date_create('1998-05-13')]),
|
||||
// array(['byweekno' => 1, 'byday' => 'MO'],[date_create('1997-12-29'),date_create('1999-01-04'),date_create('2000-01-03')]),
|
||||
// array(['byweekno' => 52, 'byday' => 'SU'], [date_create('1997-12-28'), date_create('1998-12-27'), date_create('2000-01-02')]),
|
||||
// array(['byweekno' => -1, 'byday' => 'SU'],[date_create('1997-12-28'),date_create('1999-01-03'),date_create('2000-01-02')]),
|
||||
// array(['byweekno'=>53,'byday'=>'MO'],[date_create('1998-12-28'), date_create('2004-12-27'), date_create('2009-12-28')])
|
||||
array(array(), array(date_create('1997-09-02'),date_create('1997-09-03'),date_create('1997-09-04'))),
|
||||
array(array('interval'=>2),array(date_create('1997-09-02'), date_create('1997-09-04'), date_create('1997-09-06'))),
|
||||
array(array('interval'=>92),array(date_create('1997-09-02'), date_create('1997-12-03'), date_create('1998-03-05'))),
|
||||
array(array('bymonth'=>array(1, 3)),array(date_create('1998-01-01'), date_create('1998-01-02'), date_create('1998-01-03'))),
|
||||
array(array('bymonthday'=>array(1, 3)),array(date_create('1997-09-03'), date_create('1997-10-01'), date_create('1997-10-03'))),
|
||||
array(array('bymonth'=>array(1, 3),'bymonthday'=>array(5, 7)),array(date_create('1998-01-05'), date_create('1998-01-07'), date_create('1998-03-05'))),
|
||||
array(array('byday'=>array('TU', 'TH')),array(date_create('1997-09-02'), date_create('1997-09-04'), date_create('1997-09-09'))),
|
||||
array(array('bymonth'=> array(1, 3), 'byday'=> array('TU', 'TH')),array(date_create('1998-01-01'), date_create('1998-01-06'), date_create('1998-01-08'))),
|
||||
array(array('bymonthday'=> array(1, 3), 'byday'=>array('TU', 'TH')),array(date_create('1998-01-01'), date_create('1998-02-03'), date_create('1998-03-03'))),
|
||||
array(array('bymonth'=>array(1, 3),'bymonthday'=>array(1, 3),'byday'=>array('TU', 'TH')),array(date_create('1998-01-01'), date_create('1998-03-03'), date_create('2001-03-01'))),
|
||||
// array(array('count'=>4,'byyearday'=>array(1, 100, 200, 365)),array(date_create('1997-12-31'), date_create('1998-01-01'), date_create('1998-04-10'), date_create('1998-07-19'))),
|
||||
// array(array('count'=>4,'byyearday'=>array(-365, -266, -166, -1)),array(date_create('1997-12-31'), date_create('1998-01-01'), date_create('1998-04-10'), date_create('1998-07-19'))),
|
||||
// array(array('count'=>4, 'bymonth'=>array(1, 7),'byyearday'=>array(1, 100, 200, 365)),array(date_create('1998-01-01'),date_create('1998-07-19'),date_create('1999-01-01'),date_create('1999-07-19'))),
|
||||
// array(array('count'=>4, 'bymonth' => array(1, 7), 'byyearday' => array(-365, -266, -166, -1)),array(date_create('1998-01-01'), date_create('1998-07-19'), date_create('1999-01-01'), date_create('1999-07-19'))),
|
||||
// array(array('byweekno' => 20), array(date_create('1998-05-11'), date_create('1998-05-12'), date_create('1998-05-13'))),
|
||||
// array(array('byweekno' => 1, 'byday' => 'MO'),array(date_create('1997-12-29'),date_create('1999-01-04'),date_create('2000-01-03'))),
|
||||
// array(array('byweekno' => 52, 'byday' => 'SU'), array(date_create('1997-12-28'), date_create('1998-12-27'), date_create('2000-01-02'))),
|
||||
// array(array('byweekno' => -1, 'byday' => 'SU'),array(date_create('1997-12-28'),date_create('1999-01-03'),date_create('2000-01-02'))),
|
||||
// array(array('byweekno'=>53,'byday'=>'MO'),array(date_create('1998-12-28'), date_create('2004-12-27'), date_create('2009-12-28')))
|
||||
);
|
||||
}
|
||||
/**
|
||||
@ -237,11 +237,11 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testDaily($rule, $occurrences)
|
||||
{
|
||||
$rule = new RRule(array_merge([
|
||||
$rule = new RRule(array_merge(array(
|
||||
'FREQ' => 'DAILY',
|
||||
'COUNT' => 3,
|
||||
'DTSTART' => '1997-09-02'
|
||||
], $rule));
|
||||
), $rule));
|
||||
$this->assertEquals($occurrences, $rule->getOccurrences());
|
||||
foreach ( $occurrences as $date ) {
|
||||
$this->assertTrue($rule->occursAt($date), $date->format('r'));
|
||||
@ -254,27 +254,27 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
// byhour=(6, 18),
|
||||
|
||||
// [date_create('1997-09-02'),
|
||||
// array(date_create('1997-09-02'),
|
||||
// date_create('1997-09-03'),
|
||||
// date_create('1997-09-03')])
|
||||
// date_create('1997-09-03')))
|
||||
|
||||
// def testDailyByMinute(self):
|
||||
// self.assertEqual(list(rrule(DAILY,
|
||||
|
||||
// byminute=(6, 18),
|
||||
|
||||
// [date_create('1997-09-02'),
|
||||
// array(date_create('1997-09-02'),
|
||||
// date_create('1997-09-02'),
|
||||
// date_create('1997-09-03')])
|
||||
// date_create('1997-09-03')))
|
||||
|
||||
// def testDailyBySecond(self):
|
||||
// self.assertEqual(list(rrule(DAILY,
|
||||
|
||||
// bysecond=(6, 18),
|
||||
|
||||
// [date_create('1997-09-02'),
|
||||
// array(date_create('1997-09-02'),
|
||||
// date_create('1997-09-02'),
|
||||
// date_create('1997-09-03')])
|
||||
// date_create('1997-09-03')))
|
||||
|
||||
// def testDailyByHourAndMinute(self):
|
||||
// self.assertEqual(list(rrule(DAILY,
|
||||
@ -282,9 +282,9 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
// byhour=(6, 18),
|
||||
// byminute=(6, 18),
|
||||
|
||||
// [date_create('1997-09-02'),
|
||||
// array(date_create('1997-09-02'),
|
||||
// date_create('1997-09-02'),
|
||||
// date_create('1997-09-03')])
|
||||
// date_create('1997-09-03')))
|
||||
|
||||
// def testDailyByHourAndSecond(self):
|
||||
// self.assertEqual(list(rrule(DAILY,
|
||||
@ -292,9 +292,9 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
// byhour=(6, 18),
|
||||
// bysecond=(6, 18),
|
||||
|
||||
// [date_create('1997-09-02'),
|
||||
// array(date_create('1997-09-02'),
|
||||
// date_create('1997-09-02'),
|
||||
// date_create('1997-09-03')])
|
||||
// date_create('1997-09-03')))
|
||||
|
||||
// def testDailyByMinuteAndSecond(self):
|
||||
// self.assertEqual(list(rrule(DAILY,
|
||||
@ -302,9 +302,9 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
// byminute=(6, 18),
|
||||
// bysecond=(6, 18),
|
||||
|
||||
// [date_create('1997-09-02'),
|
||||
// array(date_create('1997-09-02'),
|
||||
// date_create('1997-09-02'),
|
||||
// date_create('1997-09-02')])
|
||||
// date_create('1997-09-02')))
|
||||
|
||||
// def testDailyByHourAndMinuteAndSecond(self):
|
||||
// self.assertEqual(list(rrule(DAILY,
|
||||
@ -313,9 +313,9 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
// byminute=(6, 18),
|
||||
// bysecond=(6, 18),
|
||||
|
||||
// [date_create('1997-09-02'),
|
||||
// array(date_create('1997-09-02'),
|
||||
// date_create('1997-09-02'),
|
||||
// date_create('1997-09-02')])
|
||||
// date_create('1997-09-02')))
|
||||
|
||||
// def testDailyBySetPos(self):
|
||||
// self.assertEqual(list(rrule(DAILY,
|
||||
@ -324,9 +324,9 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
// byminute=(15, 45),
|
||||
// bysetpos=(3, -3),
|
||||
|
||||
// [date_create('1997-09-02'),
|
||||
// array(date_create('1997-09-02'),
|
||||
// date_create('1997-09-03'),
|
||||
// date_create('1997-09-03')])
|
||||
// date_create('1997-09-03')))
|
||||
|
||||
/**
|
||||
* Examples given in the RFC.
|
||||
@ -336,8 +336,8 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
return array(
|
||||
// Daily, for 10 occurrences.
|
||||
array(
|
||||
['freq' => 'daily', 'count' => 10, 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-02 09:00:00'),
|
||||
array('freq' => 'daily', 'count' => 10, 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-03 09:00:00'),
|
||||
date_create('1997-09-04 09:00:00'),
|
||||
date_create('1997-09-05 09:00:00'),
|
||||
@ -346,12 +346,12 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1997-09-08 09:00:00'),
|
||||
date_create('1997-09-09 09:00:00'),
|
||||
date_create('1997-09-10 09:00:00'),
|
||||
date_create('1997-09-11 09:00:00')]
|
||||
date_create('1997-09-11 09:00:00'))
|
||||
),
|
||||
// Daily until December 24, 1997
|
||||
array(
|
||||
['freq' => 'daily', 'dtstart' => '1997-09-02 09:00:00', 'until' => '1997-12-24 00:00:00'],
|
||||
[date_create('1997-09-02 09:00:00'), date_create('1997-09-03 09:00:00'),
|
||||
array('freq' => 'daily', 'dtstart' => '1997-09-02 09:00:00', 'until' => '1997-12-24 00:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'), date_create('1997-09-03 09:00:00'),
|
||||
date_create('1997-09-04 09:00:00'), date_create('1997-09-05 09:00:00'),
|
||||
date_create('1997-09-06 09:00:00'), date_create('1997-09-07 09:00:00'),
|
||||
date_create('1997-09-08 09:00:00'), date_create('1997-09-09 09:00:00'),
|
||||
@ -407,30 +407,30 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1997-12-16 09:00:00'), date_create('1997-12-17 09:00:00'),
|
||||
date_create('1997-12-18 09:00:00'), date_create('1997-12-19 09:00:00'),
|
||||
date_create('1997-12-20 09:00:00'), date_create('1997-12-21 09:00:00'),
|
||||
date_create('1997-12-22 09:00:00'), date_create('1997-12-23 09:00:00')]
|
||||
date_create('1997-12-22 09:00:00'), date_create('1997-12-23 09:00:00'))
|
||||
),
|
||||
// Every other day, 5 occurrences.
|
||||
array(
|
||||
['freq' => 'daily', 'interval' => 2, 'count' => 5, 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-02 09:00:00'),
|
||||
array('freq' => 'daily', 'interval' => 2, 'count' => 5, 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-04 09:00:00'),
|
||||
date_create('1997-09-06 09:00:00'),
|
||||
date_create('1997-09-08 09:00:00'),
|
||||
date_create('1997-09-10 09:00:00')]
|
||||
date_create('1997-09-10 09:00:00'))
|
||||
),
|
||||
// Every 10 days, 5 occurrences.
|
||||
array(
|
||||
['freq' => 'daily', 'interval' => 10, 'count' => 5, 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-02 09:00:00'),
|
||||
array('freq' => 'daily', 'interval' => 10, 'count' => 5, 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-12 09:00:00'),
|
||||
date_create('1997-09-22 09:00:00'),
|
||||
date_create('1997-10-02 09:00:00'),
|
||||
date_create('1997-10-12 09:00:00')]
|
||||
date_create('1997-10-12 09:00:00'))
|
||||
),
|
||||
// Everyday in January, for 3 years.
|
||||
array(
|
||||
['freq' => 'yearly', 'bymonth' => 1, 'byday' => 'MO,TU,WE,TH,FR,SA,SU', 'dtstart' => '1997-09-02 09:00:00', 'until' => '2000-01-31 09:00:00'],
|
||||
[date_create('1998-01-01 09:00:00'),
|
||||
array('freq' => 'yearly', 'bymonth' => 1, 'byday' => 'MO,TU,WE,TH,FR,SA,SU', 'dtstart' => '1997-09-02 09:00:00', 'until' => '2000-01-31 09:00:00'),
|
||||
array(date_create('1998-01-01 09:00:00'),
|
||||
date_create('1998-01-02 09:00:00'), date_create('1998-01-03 09:00:00'),
|
||||
date_create('1998-01-04 09:00:00'), date_create('1998-01-05 09:00:00'),
|
||||
date_create('1998-01-06 09:00:00'), date_create('1998-01-07 09:00:00'),
|
||||
@ -477,12 +477,12 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('2000-01-24 09:00:00'), date_create('2000-01-25 09:00:00'),
|
||||
date_create('2000-01-26 09:00:00'), date_create('2000-01-27 09:00:00'),
|
||||
date_create('2000-01-28 09:00:00'), date_create('2000-01-29 09:00:00'),
|
||||
date_create('2000-01-30 09:00:00'), date_create('2000-01-31 09:00:00')]
|
||||
date_create('2000-01-30 09:00:00'), date_create('2000-01-31 09:00:00'))
|
||||
),
|
||||
// Same thing, in another way
|
||||
array(
|
||||
['freq' => 'daily', 'bymonth' => 1, 'dtstart' => '1997-09-02 09:00:00', 'until' => '2000-01-31 09:00:00'],
|
||||
[date_create('1998-01-01 09:00:00'),
|
||||
array('freq' => 'daily', 'bymonth' => 1, 'dtstart' => '1997-09-02 09:00:00', 'until' => '2000-01-31 09:00:00'),
|
||||
array(date_create('1998-01-01 09:00:00'),
|
||||
date_create('1998-01-02 09:00:00'), date_create('1998-01-03 09:00:00'),
|
||||
date_create('1998-01-04 09:00:00'), date_create('1998-01-05 09:00:00'),
|
||||
date_create('1998-01-06 09:00:00'), date_create('1998-01-07 09:00:00'),
|
||||
@ -529,12 +529,12 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('2000-01-24 09:00:00'), date_create('2000-01-25 09:00:00'),
|
||||
date_create('2000-01-26 09:00:00'), date_create('2000-01-27 09:00:00'),
|
||||
date_create('2000-01-28 09:00:00'), date_create('2000-01-29 09:00:00'),
|
||||
date_create('2000-01-30 09:00:00'), date_create('2000-01-31 09:00:00')]
|
||||
date_create('2000-01-30 09:00:00'), date_create('2000-01-31 09:00:00'))
|
||||
),
|
||||
// Weekly for 10 occurrences:
|
||||
array(
|
||||
['freq' => 'weekly', 'count' => 10, 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-02 09:00:00'),
|
||||
array('freq' => 'weekly', 'count' => 10, 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-09 09:00:00'),
|
||||
date_create('1997-09-16 09:00:00'),
|
||||
date_create('1997-09-23 09:00:00'),
|
||||
@ -543,22 +543,22 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1997-10-14 09:00:00'),
|
||||
date_create('1997-10-21 09:00:00'),
|
||||
date_create('1997-10-28 09:00:00'),
|
||||
date_create('1997-11-04 09:00:00')]
|
||||
date_create('1997-11-04 09:00:00'))
|
||||
),
|
||||
// Every other week, 6 occurrences.
|
||||
array(
|
||||
['freq' => 'weekly', 'interval' => 2, 'count' => 6, 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-02 09:00:00'),
|
||||
array('freq' => 'weekly', 'interval' => 2, 'count' => 6, 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-16 09:00:00'),
|
||||
date_create('1997-09-30 09:00:00'),
|
||||
date_create('1997-10-14 09:00:00'),
|
||||
date_create('1997-10-28 09:00:00'),
|
||||
date_create('1997-11-11 09:00:00')]
|
||||
date_create('1997-11-11 09:00:00'))
|
||||
),
|
||||
// Weekly on Tuesday and Thursday for 5 weeks, week starting on Sunday.
|
||||
array(
|
||||
['freq' => 'weekly', 'count' => 10, 'wkst' => 'SU', 'byday' => 'TU,TH', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-02 09:00:00'),
|
||||
array('freq' => 'weekly', 'count' => 10, 'wkst' => 'SU', 'byday' => 'TU,TH', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-04 09:00:00'),
|
||||
date_create('1997-09-09 09:00:00'),
|
||||
date_create('1997-09-11 09:00:00'),
|
||||
@ -567,24 +567,24 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1997-09-23 09:00:00'),
|
||||
date_create('1997-09-25 09:00:00'),
|
||||
date_create('1997-09-30 09:00:00'),
|
||||
date_create('1997-10-02 09:00:00')]
|
||||
date_create('1997-10-02 09:00:00'))
|
||||
),
|
||||
// Every other week on Tuesday and Thursday, for 8 occurrences, week starting on Sunday
|
||||
array(
|
||||
['freq' => 'weekly', 'interval' => 2, 'count' => 8, 'wkst' => 'SU', 'byday' => 'TU,TH', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-02 09:00:00'),
|
||||
array('freq' => 'weekly', 'interval' => 2, 'count' => 8, 'wkst' => 'SU', 'byday' => 'TU,TH', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-04 09:00:00'),
|
||||
date_create('1997-09-16 09:00:00'),
|
||||
date_create('1997-09-18 09:00:00'),
|
||||
date_create('1997-09-30 09:00:00'),
|
||||
date_create('1997-10-02 09:00:00'),
|
||||
date_create('1997-10-14 09:00:00'),
|
||||
date_create('1997-10-16 09:00:00')]
|
||||
date_create('1997-10-16 09:00:00'))
|
||||
),
|
||||
// Monthly on the 1st Friday for ten occurrences.
|
||||
array(
|
||||
['freq' => 'monthly', 'count' => 10, 'byday' => '1FR', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-05 09:00:00'),
|
||||
array('freq' => 'monthly', 'count' => 10, 'byday' => '1FR', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-05 09:00:00'),
|
||||
date_create('1997-10-03 09:00:00'),
|
||||
date_create('1997-11-07 09:00:00'),
|
||||
date_create('1997-12-05 09:00:00'),
|
||||
@ -593,12 +593,12 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1998-03-06 09:00:00'),
|
||||
date_create('1998-04-03 09:00:00'),
|
||||
date_create('1998-05-01 09:00:00'),
|
||||
date_create('1998-06-05 09:00:00')]
|
||||
date_create('1998-06-05 09:00:00'))
|
||||
),
|
||||
// Every other month on the 1st and last Sunday of the month for 10 occurrences.
|
||||
array(
|
||||
['freq' => 'monthly', 'interval' => 2, 'count' => 10, 'byday' => '1SU,-1SU', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-07 09:00:00'),
|
||||
array('freq' => 'monthly', 'interval' => 2, 'count' => 10, 'byday' => '1SU,-1SU', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-07 09:00:00'),
|
||||
date_create('1997-09-28 09:00:00'),
|
||||
date_create('1997-11-02 09:00:00'),
|
||||
date_create('1997-11-30 09:00:00'),
|
||||
@ -607,50 +607,50 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1998-03-01 09:00:00'),
|
||||
date_create('1998-03-29 09:00:00'),
|
||||
date_create('1998-05-03 09:00:00'),
|
||||
date_create('1998-05-31 09:00:00')]
|
||||
date_create('1998-05-31 09:00:00'))
|
||||
),
|
||||
// Monthly on the second to last Monday of the month for 6 months.
|
||||
array(
|
||||
['freq' => 'monthly', 'count' => 6, 'byday' => '-2MO', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-22 09:00:00'),
|
||||
array('freq' => 'monthly', 'count' => 6, 'byday' => '-2MO', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-22 09:00:00'),
|
||||
date_create('1997-10-20 09:00:00'),
|
||||
date_create('1997-11-17 09:00:00'),
|
||||
date_create('1997-12-22 09:00:00'),
|
||||
date_create('1998-01-19 09:00:00'),
|
||||
date_create('1998-02-16 09:00:00')]
|
||||
date_create('1998-02-16 09:00:00'))
|
||||
),
|
||||
// Monthly on the third to the last day of the month, for 6 months.
|
||||
array(
|
||||
['freq' => 'monthly', 'count' => 6, 'bymonthday' => '-3', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-28 09:00:00'),
|
||||
array('freq' => 'monthly', 'count' => 6, 'bymonthday' => '-3', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-28 09:00:00'),
|
||||
date_create('1997-10-29 09:00:00'),
|
||||
date_create('1997-11-28 09:00:00'),
|
||||
date_create('1997-12-29 09:00:00'),
|
||||
date_create('1998-01-29 09:00:00'),
|
||||
date_create('1998-02-26 09:00:00')]
|
||||
date_create('1998-02-26 09:00:00'))
|
||||
),
|
||||
// Monthly on the 2nd and 15th of the month for 5 occurrences.
|
||||
array(
|
||||
['freq' => 'monthly', 'count' => 5, 'bymonthday' => '2,15', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-02 09:00:00'),
|
||||
array('freq' => 'monthly', 'count' => 5, 'bymonthday' => '2,15', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-15 09:00:00'),
|
||||
date_create('1997-10-02 09:00:00'),
|
||||
date_create('1997-10-15 09:00:00'),
|
||||
date_create('1997-11-02 09:00:00')]
|
||||
date_create('1997-11-02 09:00:00'))
|
||||
),
|
||||
// Monthly on the first and last day of the month for 3 occurrences.
|
||||
array(
|
||||
['freq' => 'monthly', 'count' => 5, 'bymonthday' => '-1,1', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-30 09:00:00'),
|
||||
array('freq' => 'monthly', 'count' => 5, 'bymonthday' => '-1,1', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-30 09:00:00'),
|
||||
date_create('1997-10-01 09:00:00'),
|
||||
date_create('1997-10-31 09:00:00'),
|
||||
date_create('1997-11-01 09:00:00'),
|
||||
date_create('1997-11-30 09:00:00')]
|
||||
date_create('1997-11-30 09:00:00'))
|
||||
),
|
||||
// Every 18 months on the 10th thru 15th of the month for 10 occurrences.
|
||||
array(
|
||||
['freq' => 'monthly', 'count' => 10, 'interval' => 18, 'bymonthday' => range(10,15), 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-10 09:00:00'),
|
||||
array('freq' => 'monthly', 'count' => 10, 'interval' => 18, 'bymonthday' => range(10,15), 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-10 09:00:00'),
|
||||
date_create('1997-09-11 09:00:00'),
|
||||
date_create('1997-09-12 09:00:00'),
|
||||
date_create('1997-09-13 09:00:00'),
|
||||
@ -659,53 +659,53 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1999-03-10 09:00:00'),
|
||||
date_create('1999-03-11 09:00:00'),
|
||||
date_create('1999-03-12 09:00:00'),
|
||||
date_create('1999-03-13 09:00:00')]
|
||||
date_create('1999-03-13 09:00:00'))
|
||||
),
|
||||
// Every Tuesday, every other month, 6 occurences.
|
||||
array(
|
||||
['freq' => 'monthly', 'count' => 6, 'interval' => 2, 'byday' => 'TU', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-02 09:00:00'),
|
||||
array('freq' => 'monthly', 'count' => 6, 'interval' => 2, 'byday' => 'TU', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-02 09:00:00'),
|
||||
date_create('1997-09-09 09:00:00'),
|
||||
date_create('1997-09-16 09:00:00'),
|
||||
date_create('1997-09-23 09:00:00'),
|
||||
date_create('1997-09-30 09:00:00'),
|
||||
date_create('1997-11-04 09:00:00')]
|
||||
date_create('1997-11-04 09:00:00'))
|
||||
),
|
||||
// Yearly in June and July for 10 occurrences.
|
||||
array(
|
||||
['freq' => 'yearly', 'count' => 10, 'bymonth' => '6,7', 'dtstart' => '1997-06-10 09:00:00'],
|
||||
[date_create('1997-06-10 09:00:00'),date_create('1997-07-10 09:00:00'),
|
||||
array('freq' => 'yearly', 'count' => 10, 'bymonth' => '6,7', 'dtstart' => '1997-06-10 09:00:00'),
|
||||
array(date_create('1997-06-10 09:00:00'),date_create('1997-07-10 09:00:00'),
|
||||
date_create('1998-06-10 09:00:00'),date_create('1998-07-10 09:00:00'),
|
||||
date_create('1999-06-10 09:00:00'),date_create('1999-07-10 09:00:00'),
|
||||
date_create('2000-06-10 09:00:00'),date_create('2000-07-10 09:00:00'),
|
||||
date_create('2001-06-10 09:00:00'),date_create('2001-07-10 09:00:00')]
|
||||
date_create('2001-06-10 09:00:00'),date_create('2001-07-10 09:00:00'))
|
||||
),
|
||||
// Every 3rd year on the 1st, 100th and 200th day for 4 occurrences.
|
||||
array(
|
||||
['freq' => 'yearly', 'count' => 4, 'interval' => '3', 'byyearday' => '1,100,200', 'dtstart' => '1997-01-01 09:00:00'],
|
||||
[date_create('1997-01-01 09:00:00'),
|
||||
array('freq' => 'yearly', 'count' => 4, 'interval' => '3', 'byyearday' => '1,100,200', 'dtstart' => '1997-01-01 09:00:00'),
|
||||
array(date_create('1997-01-01 09:00:00'),
|
||||
date_create('1997-04-10 09:00:00'),
|
||||
date_create('1997-07-19 09:00:00'),
|
||||
date_create('2000-01-01 09:00:00')]
|
||||
date_create('2000-01-01 09:00:00'))
|
||||
),
|
||||
// Every 20th Monday of the year, 3 occurrences.
|
||||
array(
|
||||
['freq' => 'yearly', 'count' => 3, 'byday' => '20MO', 'dtstart' => '1997-05-19 09:00:00'],
|
||||
[date_create('1997-05-19 09:00:00'),
|
||||
array('freq' => 'yearly', 'count' => 3, 'byday' => '20MO', 'dtstart' => '1997-05-19 09:00:00'),
|
||||
array(date_create('1997-05-19 09:00:00'),
|
||||
date_create('1998-05-18 09:00:00'),
|
||||
date_create('1999-05-17 09:00:00')]
|
||||
date_create('1999-05-17 09:00:00'))
|
||||
),
|
||||
// Monday of week number 20 (where the default start of the week is Monday), 3 occurrences.
|
||||
array(
|
||||
['freq' => 'yearly', 'count' => 3, 'byweekno' => 20, 'byday' => 'MO', 'dtstart' => '1997-05-12 09:00:00'],
|
||||
[date_create('1997-05-12 09:00:00'),
|
||||
array('freq' => 'yearly', 'count' => 3, 'byweekno' => 20, 'byday' => 'MO', 'dtstart' => '1997-05-12 09:00:00'),
|
||||
array(date_create('1997-05-12 09:00:00'),
|
||||
date_create('1998-05-11 09:00:00'),
|
||||
date_create('1999-05-17 09:00:00')]
|
||||
date_create('1999-05-17 09:00:00'))
|
||||
),
|
||||
// Every Thursday in March
|
||||
array(
|
||||
['freq' => 'yearly', 'byday' => 'TH', 'bymonth' => 3, 'dtstart' => '1997-03-13 09:00:00', 'until' => '2000-01-01'],
|
||||
[date_create('1997-03-13 09:00:00'),
|
||||
array('freq' => 'yearly', 'byday' => 'TH', 'bymonth' => 3, 'dtstart' => '1997-03-13 09:00:00', 'until' => '2000-01-01'),
|
||||
array(date_create('1997-03-13 09:00:00'),
|
||||
date_create('1997-03-20 09:00:00'),
|
||||
date_create('1997-03-27 09:00:00'),
|
||||
date_create('1998-03-05 09:00:00'),
|
||||
@ -715,12 +715,12 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1999-03-04 09:00:00'),
|
||||
date_create('1999-03-11 09:00:00'),
|
||||
date_create('1999-03-18 09:00:00'),
|
||||
date_create('1999-03-25 09:00:00')]
|
||||
date_create('1999-03-25 09:00:00'))
|
||||
),
|
||||
// Every Thursday, but only during June, July, and August
|
||||
array(
|
||||
['freq' => 'yearly', 'byday' => 'TH', 'bymonth' => [6,7,8], 'dtstart' => '1997-01-01 09:00:00', 'until' => '1999-01-01'],
|
||||
[date_create('1997-06-05 09:00:00'),
|
||||
array('freq' => 'yearly', 'byday' => 'TH', 'bymonth' => array(6,7,8), 'dtstart' => '1997-01-01 09:00:00', 'until' => '1999-01-01'),
|
||||
array(date_create('1997-06-05 09:00:00'),
|
||||
date_create('1997-06-12 09:00:00'),
|
||||
date_create('1997-06-19 09:00:00'),
|
||||
date_create('1997-06-26 09:00:00'),
|
||||
@ -745,20 +745,20 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1998-08-06 09:00:00'),
|
||||
date_create('1998-08-13 09:00:00'),
|
||||
date_create('1998-08-20 09:00:00'),
|
||||
date_create('1998-08-27 09:00:00')]
|
||||
date_create('1998-08-27 09:00:00'))
|
||||
),
|
||||
// Every Friday the 13th, 4 occurrences.
|
||||
array(
|
||||
['freq' => 'yearly', 'byday' => 'FR', 'bymonthday' => 13, 'count' => 4, 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1998-02-13 09:00:00'),
|
||||
array('freq' => 'yearly', 'byday' => 'FR', 'bymonthday' => 13, 'count' => 4, 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1998-02-13 09:00:00'),
|
||||
date_create('1998-03-13 09:00:00'),
|
||||
date_create('1998-11-13 09:00:00'),
|
||||
date_create('1999-08-13 09:00:00')]
|
||||
date_create('1999-08-13 09:00:00'))
|
||||
),
|
||||
// The first Saturday that follows the first Sunday of the month
|
||||
array(
|
||||
['freq' => 'monthly', 'byday' => 'SA', 'bymonthday' => [7,8,9,10,11,12,13], 'count' => 10, 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-09-13 09:00:00'),
|
||||
array('freq' => 'monthly', 'byday' => 'SA', 'bymonthday' => array(7,8,9,10,11,12,13), 'count' => 10, 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-09-13 09:00:00'),
|
||||
date_create('1997-10-11 09:00:00'),
|
||||
date_create('1997-11-08 09:00:00'),
|
||||
date_create('1997-12-13 09:00:00'),
|
||||
@ -767,28 +767,28 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
date_create('1998-03-07 09:00:00'),
|
||||
date_create('1998-04-11 09:00:00'),
|
||||
date_create('1998-05-09 09:00:00'),
|
||||
date_create('1998-06-13 09:00:00')]
|
||||
date_create('1998-06-13 09:00:00'))
|
||||
),
|
||||
// Every four years, the first Tuesday after a Monday in November, 3 occurrences (U.S. Presidential Election day):
|
||||
array(
|
||||
['freq' => 'yearly', 'interval' => 4, 'bymonth' => 11, 'byday' => 'TU', 'bymonthday' => [2,3,4,5,6,7,8], 'count' => 3, 'dtstart' => '1996-11-05 09:00:00'],
|
||||
[date_create('1996-11-05 09:00:00'),
|
||||
array('freq' => 'yearly', 'interval' => 4, 'bymonth' => 11, 'byday' => 'TU', 'bymonthday' => array(2,3,4,5,6,7,8), 'count' => 3, 'dtstart' => '1996-11-05 09:00:00'),
|
||||
array(date_create('1996-11-05 09:00:00'),
|
||||
date_create('2000-11-07 09:00:00'),
|
||||
date_create('2004-11-02 09:00:00')]
|
||||
date_create('2004-11-02 09:00:00'))
|
||||
),
|
||||
// The 3rd instance into the month of one of Tuesday, Wednesday or Thursday, for the next 3 months:
|
||||
array(
|
||||
['freq' => 'monthly', 'byday' => 'TU,WE,TH', 'bysetpos' => 3, 'count' => 3, 'dtstart' => '1997-09-04 09:00:00'],
|
||||
[date_create('1997-09-04 09:00:00'),
|
||||
array('freq' => 'monthly', 'byday' => 'TU,WE,TH', 'bysetpos' => 3, 'count' => 3, 'dtstart' => '1997-09-04 09:00:00'),
|
||||
array(date_create('1997-09-04 09:00:00'),
|
||||
date_create('1997-10-07 09:00:00'),
|
||||
date_create('1997-11-06 09:00:00')]
|
||||
date_create('1997-11-06 09:00:00'))
|
||||
),
|
||||
// The 2nd to last weekday of the month, 3 occurrences.
|
||||
array(
|
||||
['freq' => 'monthly', 'byday' => 'MO,TU,WE,TH,FR', 'bysetpos' => -2, 'count' => 3, 'dtstart' => '1997-09-29 09:00:00'],
|
||||
[date_create('1997-09-29 09:00:00'),
|
||||
array('freq' => 'monthly', 'byday' => 'MO,TU,WE,TH,FR', 'bysetpos' => -2, 'count' => 3, 'dtstart' => '1997-09-29 09:00:00'),
|
||||
array(date_create('1997-09-29 09:00:00'),
|
||||
date_create('1997-10-30 09:00:00'),
|
||||
date_create('1997-11-27 09:00:00')]
|
||||
date_create('1997-11-27 09:00:00'))
|
||||
),
|
||||
// todo HOURLY, MINUTELY, SECONDLY
|
||||
);
|
||||
@ -815,41 +815,41 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
['freq' => 'daily', 'count' => 3, 'byday' => 'TU,TH', 'dtstart' => '2007-01-01'],
|
||||
[date_create('2007-01-02'), date_create('2007-01-04'), date_create('2007-01-09')]
|
||||
array('freq' => 'daily', 'count' => 3, 'byday' => 'TU,TH', 'dtstart' => '2007-01-01'),
|
||||
array(date_create('2007-01-02'), date_create('2007-01-04'), date_create('2007-01-09'))
|
||||
),
|
||||
array(
|
||||
['freq' => 'weekly', 'count' => 3, 'byday' => 'TU,TH', 'dtstart' => '2007-01-01'],
|
||||
[date_create('2007-01-02'), date_create('2007-01-04'), date_create('2007-01-09')]
|
||||
array('freq' => 'weekly', 'count' => 3, 'byday' => 'TU,TH', 'dtstart' => '2007-01-01'),
|
||||
array(date_create('2007-01-02'), date_create('2007-01-04'), date_create('2007-01-09'))
|
||||
),
|
||||
array(
|
||||
['freq' => 'daily', 'count' => 3, 'byday' => 'TU,TH', 'dtstart' => '2007-01-01', 'bysetpos' => 1],
|
||||
[date_create('2007-01-02'), date_create('2007-01-04'), date_create('2007-01-09')]
|
||||
array('freq' => 'daily', 'count' => 3, 'byday' => 'TU,TH', 'dtstart' => '2007-01-01', 'bysetpos' => 1),
|
||||
array(date_create('2007-01-02'), date_create('2007-01-04'), date_create('2007-01-09'))
|
||||
),
|
||||
array(
|
||||
['freq' => 'weekly', 'count' => 3, 'byday' => 'TU,TH', 'dtstart' => '2007-01-01', 'bysetpos' => 1],
|
||||
[date_create('2007-01-02'), date_create('2007-01-09'), date_create('2007-01-16')]
|
||||
array('freq' => 'weekly', 'count' => 3, 'byday' => 'TU,TH', 'dtstart' => '2007-01-01', 'bysetpos' => 1),
|
||||
array(date_create('2007-01-02'), date_create('2007-01-09'), date_create('2007-01-16'))
|
||||
),
|
||||
// The week number 1 may be in the last year.
|
||||
array(
|
||||
['freq' => 'yearly', 'count' => 3, 'byweekno' => 1, 'byday' => 'MO', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-12-29 09:00:00'),
|
||||
array('freq' => 'yearly', 'count' => 3, 'byweekno' => 1, 'byday' => 'MO', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-12-29 09:00:00'),
|
||||
date_create('1999-01-04 09:00:00'),
|
||||
date_create('2000-01-03 09:00:00')]
|
||||
date_create('2000-01-03 09:00:00'))
|
||||
),
|
||||
// And the week numbers greater than 51 may be in the next year.
|
||||
array(
|
||||
['freq' => 'yearly', 'count' => 3, 'byweekno' => 52, 'byday' => 'SU', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1997-12-28 09:00:00'),
|
||||
array('freq' => 'yearly', 'count' => 3, 'byweekno' => 52, 'byday' => 'SU', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1997-12-28 09:00:00'),
|
||||
date_create('1998-12-27 09:00:00'),
|
||||
date_create('2000-01-02 09:00:00')]
|
||||
date_create('2000-01-02 09:00:00'))
|
||||
),
|
||||
// Only some years have week number 53
|
||||
array(
|
||||
['freq' => 'yearly', 'count' => 3, 'byweekno' => 53, 'byday' => 'MO', 'dtstart' => '1997-09-02 09:00:00'],
|
||||
[date_create('1998-12-28 09:00:00'),
|
||||
array('freq' => 'yearly', 'count' => 3, 'byweekno' => 53, 'byday' => 'MO', 'dtstart' => '1997-09-02 09:00:00'),
|
||||
array(date_create('1998-12-28 09:00:00'),
|
||||
date_create('2004-12-27 09:00:00'),
|
||||
date_create('2009-12-28 09:00:00')]
|
||||
date_create('2009-12-28 09:00:00'))
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -873,24 +873,24 @@ class RRuleTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
['FREQ' => 'YEARLY', 'DTSTART' => '1999-09-02'],
|
||||
['1999-09-01','1999-09-03']
|
||||
array('FREQ' => 'YEARLY', 'DTSTART' => '1999-09-02'),
|
||||
array('1999-09-01','1999-09-03')
|
||||
),
|
||||
array(
|
||||
['FREQ' => 'YEARLY', 'DTSTART' => '1999-09-02', 'UNTIL' => '2000-09-02'],
|
||||
['2001-09-02']
|
||||
array('FREQ' => 'YEARLY', 'DTSTART' => '1999-09-02', 'UNTIL' => '2000-09-02'),
|
||||
array('2001-09-02')
|
||||
),
|
||||
array(
|
||||
['FREQ' => 'YEARLY', 'DTSTART' => '1999-09-02', 'COUNT' => 3],
|
||||
['2010-09-02']
|
||||
array('FREQ' => 'YEARLY', 'DTSTART' => '1999-09-02', 'COUNT' => 3),
|
||||
array('2010-09-02')
|
||||
),
|
||||
array(
|
||||
['FREQ' => 'YEARLY', 'DTSTART' => '1999-09-02', 'INTERVAL' => 2],
|
||||
['2000-09-02', '2002-09-02']
|
||||
array('FREQ' => 'YEARLY', 'DTSTART' => '1999-09-02', 'INTERVAL' => 2),
|
||||
array('2000-09-02', '2002-09-02')
|
||||
),
|
||||
array(
|
||||
['FREQ' => 'MONTHLY', 'DTSTART' => '1999-09-02', 'INTERVAL' => 2],
|
||||
['1999-10-02', '1999-12-02']
|
||||
array('FREQ' => 'MONTHLY', 'DTSTART' => '1999-09-02', 'INTERVAL' => 2),
|
||||
array('1999-10-02', '1999-12-02')
|
||||
),
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user