-
Notifications
You must be signed in to change notification settings - Fork 84
RRuleInterface
Any RRule
or RSet
object will implement this interface and have the following methods.
(version >= 1.1)
Indicate whether or not the rule has an end (count or until), or is infinite.
Infinite rules cannot be counted, and you cannot get all occurrences as a array.
Returns the number of occurrences, for finite rule only. This method will throw a LogicException
if the rule has not COUNT
or UNTIL
part, as there is an infinity of occurrences.
A RRule
object implements the Countable
interface, meaning that you can call count($rrule)
or $rrule->count()
.
Returns an array of all occurrences, for finite rules only. This method will throw a LogicException
if the rule has not COUNT
or UNTIL
part, as there is an infinity of occurrences.
Returns an array of all occurrences between $begin
and $end
(included). Both dates can be given as a string understandable by PHP's DateTime
constructor (for example 2015-07-01 14:46:30
) a UNIX Timestamp (as int
) or a DateTime
object, or null
.
- If
$begin
isnull
this method will return all occurrences before$end
. - If
$end
isnull
this method will return all occurrences after$begin
. If the rule is infinite (noCOUNT
orUNTIL
) it will throw aLogicException
. - If both are
null
this method is the same asgetOccurrences()
Note: If you are working with events, remember that there is no notion of duration. In other words, this method will returns the events that start between $begin
and $end
, but not the events that started before $begin
and might still be ongoing due to their duration. If you want the later behavior, you should first subtract duration from $begin
, to get the occurrences between "begin - duration" and "end".
Returns true if $datetime
is an occurrence of the rule, or false otherwise. $datetime
can be a string understandable by PHP's DateTime
constructor (for example 2015-07-01 14:46:30
) a UNIX Timestamp (as int
) or a DateTime
object.
Note: If you are working with events, remember that there is no notion of duration. In other words, this method will tell you if a event starts as $datetime
, but not if an event is still ongoing at $datetime
. If you want the later behavior, you should call getOccurencesBetween()
with "datetime - duration" and "datetime".
The RRule interface extends the following interfaces: Iterator
, ArrayAccess
and Countable
.