Documentation

RRuleIterator
in package
implements Iterator

RRuleParser.

This class receives an RRULE string, and allows you to iterate to get a list of dates in that recurrence.

For instance, passing: FREQ=DAILY;LIMIT=5 will cause the iterator to contain 5 items, one for each day.

Tags
copyright

Copyright (C) fruux GmbH (https://fruux.com/)

author

Evert Pot (http://evertpot.com/)

license

http://sabre.io/license/ Modified BSD License

Interfaces, Classes and Traits

Iterator

Table of Contents

$byDay  : array<string|int, mixed>
Which weekdays to recur.
$byHour  : array<string|int, mixed>
Which hours to recur.
$byMinute  : array<string|int, mixed>
Which minutes to recur.
$byMonth  : array<string|int, mixed>
Which months to recur.
$byMonthDay  : array<string|int, mixed>
Which days of the month to recur.
$bySecond  : array<string|int, mixed>
Which seconds to recur.
$bySetPos  : array<string|int, mixed>
Which items in an existing st to recur.
$byWeekNo  : array<string|int, mixed>
Which week numbers to recur.
$byYearDay  : array<string|int, mixed>
Which days of the year to recur.
$count  : int
The number of recurrences, or 'null' if infinitely recurring.
$counter  : int
The current item in the list.
$currentDate  : DateTimeInterface
The date of the current iteration. You can get this by calling ->current().
$dayMap  : array<string|int, mixed>
Simple mapping from iCalendar day names to day numbers.
$dayNames  : array<string|int, mixed>
Mappings between the day number and english day name.
$frequency  : string
Frequency is one of: secondly, minutely, hourly, daily, weekly, monthly, yearly.
$interval  : int
The interval.
$startDate  : DateTimeInterface
The reference start date/time for the rrule.
$until  : DateTimeInterface|null
The last instance of this recurrence, inclusively.
$weekStart  : string
When the week starts.
__construct()  : mixed
Creates the Iterator.
current()  : mixed
fastForward()  : mixed
This method allows you to quickly go to the next occurrence after the specified date.
isInfinite()  : bool
Returns true if this recurring event never ends.
key()  : int
Returns the current item number.
next()  : mixed
Goes on to the next iteration.
rewind()  : mixed
Resets the iterator.
valid()  : bool
Returns whether the current item is a valid item for the recurrence iterator. This will return false if we've gone beyond the UNTIL or COUNT statements.
getDays()  : mixed
getHours()  : mixed
getMonthlyOccurrences()  : array<string|int, mixed>
Returns all the occurrences for a monthly frequency with a 'byDay' or 'byMonthDay' expansion for the current month.
getMonths()  : mixed
nextDaily()  : mixed
Does the processing for advancing the iterator for daily frequency.
nextHourly()  : mixed
Does the processing for advancing the iterator for hourly frequency.
nextMonthly()  : mixed
Does the processing for advancing the iterator for monthly frequency.
nextWeekly()  : mixed
Does the processing for advancing the iterator for weekly frequency.
nextYearly()  : mixed
Does the processing for advancing the iterator for yearly frequency.
parseRRule()  : mixed
This method receives a string from an RRULE property, and populates this class with all the values.

Properties

$byDay

Which weekdays to recur.

protected array<string|int, mixed> $byDay

This is an array of weekdays

This may also be preceded by a positive or negative integer. If present, this indicates the nth occurrence of a specific day within the monthly or yearly rrule. For instance, -2TU indicates the second-last tuesday of the month, or year.

$byHour

Which hours to recur.

protected array<string|int, mixed> $byHour

This is an array of integers (between 0 and 23)

$byMinute

Which minutes to recur.

protected array<string|int, mixed> $byMinute

This is an array of integers (between 0 and 59)

$byMonth

Which months to recur.

protected array<string|int, mixed> $byMonth

This is an array of integers from 1 to 12.

$byMonthDay

Which days of the month to recur.

protected array<string|int, mixed> $byMonthDay

This is an array of days of the months (1-31). The value can also be negative. -5 for instance means the 5th last day of the month.

$bySecond

Which seconds to recur.

protected array<string|int, mixed> $bySecond

This is an array of integers (between 0 and 60)

$bySetPos

Which items in an existing st to recur.

protected array<string|int, mixed> $bySetPos

These numbers work together with an existing by* rule. It specifies exactly which items of the existing by-rule to filter.

Valid values are 1 to 366 and -1 to -366. As an example, this can be used to recur the last workday of the month.

This would be done by setting frequency to 'monthly', byDay to 'MO,TU,WE,TH,FR' and bySetPos to -1.

$byWeekNo

Which week numbers to recur.

protected array<string|int, mixed> $byWeekNo

This is an array of integers from 1 to 53. The values can also be negative. -1 will always refer to the last week of the year.

$byYearDay

Which days of the year to recur.

protected array<string|int, mixed> $byYearDay

This is an array with days of the year (1 to 366). The values can also be negative. For instance, -1 will always represent the last day of the year. (December 31st).

$count

The number of recurrences, or 'null' if infinitely recurring.

protected int $count

$counter

The current item in the list.

protected int $counter = 0

You can get this number with the key() method.

$currentDate

The date of the current iteration. You can get this by calling ->current().

protected DateTimeInterface $currentDate

$dayMap

Simple mapping from iCalendar day names to day numbers.

protected array<string|int, mixed> $dayMap = ['SU' => 0, 'MO' => 1, 'TU' => 2, 'WE' => 3, 'TH' => 4, 'FR' => 5, 'SA' => 6]

$dayNames

Mappings between the day number and english day name.

protected array<string|int, mixed> $dayNames = [0 => 'Sunday', 1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday']

$frequency

Frequency is one of: secondly, minutely, hourly, daily, weekly, monthly, yearly.

protected string $frequency

$interval

The interval.

protected int $interval = 1

If for example frequency is set to daily, interval = 2 would mean every 2 days.

$startDate

The reference start date/time for the rrule.

protected DateTimeInterface $startDate

All calculations are based on this initial date.

$until

The last instance of this recurrence, inclusively.

protected DateTimeInterface|null $until

$weekStart

When the week starts.

protected string $weekStart = 'MO'

Methods

__construct()

Creates the Iterator.

public __construct(string|array<string|int, mixed> $rrule, DateTimeInterface $start) : mixed
Parameters
$rrule : string|array<string|int, mixed>
$start : DateTimeInterface
Return values
mixed

fastForward()

This method allows you to quickly go to the next occurrence after the specified date.

public fastForward(DateTimeInterface $dt) : mixed
Parameters
$dt : DateTimeInterface
Return values
mixed

isInfinite()

Returns true if this recurring event never ends.

public isInfinite() : bool
Return values
bool

key()

Returns the current item number.

public key() : int
Return values
int

next()

Goes on to the next iteration.

public next() : mixed
Return values
mixed

rewind()

Resets the iterator.

public rewind() : mixed
Return values
mixed

valid()

Returns whether the current item is a valid item for the recurrence iterator. This will return false if we've gone beyond the UNTIL or COUNT statements.

public valid() : bool
Return values
bool

getDays()

protected getDays() : mixed
Return values
mixed

getHours()

protected getHours() : mixed
Return values
mixed

getMonthlyOccurrences()

Returns all the occurrences for a monthly frequency with a 'byDay' or 'byMonthDay' expansion for the current month.

protected getMonthlyOccurrences() : array<string|int, mixed>

The returned list is an array of integers with the day of month (1-31).

Return values
array<string|int, mixed>

getMonths()

protected getMonths() : mixed
Return values
mixed

nextDaily()

Does the processing for advancing the iterator for daily frequency.

protected nextDaily() : mixed
Return values
mixed

nextHourly()

Does the processing for advancing the iterator for hourly frequency.

protected nextHourly() : mixed
Return values
mixed

nextMonthly()

Does the processing for advancing the iterator for monthly frequency.

protected nextMonthly() : mixed
Return values
mixed

nextWeekly()

Does the processing for advancing the iterator for weekly frequency.

protected nextWeekly() : mixed
Return values
mixed

nextYearly()

Does the processing for advancing the iterator for yearly frequency.

protected nextYearly() : mixed
Return values
mixed

parseRRule()

This method receives a string from an RRULE property, and populates this class with all the values.

protected parseRRule(string|array<string|int, mixed> $rrule) : mixed
Parameters
$rrule : string|array<string|int, mixed>
Return values
mixed

Search results