mirror of
https://github.com/rlanvin/php-rrule.git
synced 2025-02-26 15:54:14 +01:00
Implement getOccurrencesBetween()
This commit is contained in:
parent
b1000a4afd
commit
38df1fc962
@ -155,7 +155,7 @@ class RRule implements \Iterator, \ArrayAccess, \Countable
|
||||
protected $timeset = null;
|
||||
|
||||
// cache variables
|
||||
public $total = null;
|
||||
protected $total = null;
|
||||
protected $cache = array();
|
||||
|
||||
// Public interface
|
||||
@ -520,8 +520,16 @@ class RRule implements \Iterator, \ArrayAccess, \Countable
|
||||
*/
|
||||
public function getOccurrencesBetween($begin, $end)
|
||||
{
|
||||
$begin = self::parseDate($begin);
|
||||
$end = self::parseDate($end);
|
||||
if ( $begin !== null ) {
|
||||
$begin = self::parseDate($begin);
|
||||
}
|
||||
|
||||
if ( $end !== null ) {
|
||||
$end = self::parseDate($end);
|
||||
}
|
||||
elseif ( ! $this->count && ! $this->until ) {
|
||||
throw new \LogicException('Cannot get all occurrences of an infinite recurrence rule.');
|
||||
}
|
||||
|
||||
$iterator = $this;
|
||||
if ( $this->total !== null ) {
|
||||
@ -530,10 +538,10 @@ class RRule implements \Iterator, \ArrayAccess, \Countable
|
||||
|
||||
$res = array();
|
||||
foreach ( $iterator as $occurrence ) {
|
||||
if ( $occurrence < $begin ) {
|
||||
if ( $begin !== null && $occurrence < $begin ) {
|
||||
continue;
|
||||
}
|
||||
if ( $occurrence > $end ) {
|
||||
if ( $end !== null && $occurrence > $end ) {
|
||||
break;
|
||||
}
|
||||
$res[] = $occurrence;
|
||||
|
Loading…
x
Reference in New Issue
Block a user