Skip to content

RRuleIterator

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.

  • Full name: \Sabre\VObject\Recur\RRuleIterator
  • This class implements: \Iterator

Constants

Constant Visibility Type Value
dateUpperLimit public 253402300799

Properties

startDate

The reference start date/time for the rrule.

protected \DateTimeInterface $startDate

All calculations are based on this initial date.


currentDate

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

protected \DateTimeInterface $currentDate

hourJump

The number of hours that the next occurrence of an event jumped forward, usually because summer time started and the requested time-of-day like 0230 did not exist on that day. And so the event was scheduled 1 hour later at 0330.

protected $hourJump

frequency

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

protected string $frequency

count

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

protected int $count

interval

The interval.

protected int $interval

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


until

The last instance of this recurrence, inclusively.

protected \DateTimeInterface|null $until

bySecond

Which seconds to recur.

protected array $bySecond

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


byMinute

Which minutes to recur.

protected array $byMinute

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


byHour

Which hours to recur.

protected array $byHour

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


counter

The current item in the list.

protected int $counter

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


byDay

Which weekdays to recur.

protected array $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.


byMonthDay

Which days of the month to recur.

protected array $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.


byYearDay

Which days of the year to recur.

protected array $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).


byWeekNo

Which week numbers to recur.

protected array $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.


byMonth

Which months to recur.

protected array $byMonth

This is an array of integers from 1 to 12.


bySetPos

Which items in an existing st to recur.

protected array $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.


weekStart

When the week starts.

protected string $weekStart

dayNames

Mappings between the day number and english day name.

protected array $dayNames

dayMap

Simple mapping from iCalendar day names to day numbers.

protected array $dayMap

Methods

__construct

Creates the Iterator.

public __construct(string|array $rrule, \DateTimeInterface $start): mixed

Parameters:

Parameter Type Description
$rrule string|array
$start \DateTimeInterface

current

public current(): mixed

key

Returns the current item number.

public key(): int

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

rewind

Resets the iterator.

public rewind(): void

next

Goes on to the next iteration.

public next(): void

isInfinite

Returns true if this recurring event never ends.

public isInfinite(): bool

fastForward

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

public fastForward(\DateTimeInterface $dt): mixed

Parameters:

Parameter Type Description
$dt \DateTimeInterface

startTime

Gets the original start time of the RRULE.

protected startTime(): string

The value is formatted as a string with 24-hour:minute:second


advanceTheDate

Advances currentDate by the interval.

protected advanceTheDate(string $interval): void

The time is set from the original startDate. If the recurrence is on a day when summer time started, then the time on that day may have jumped forward, for example, from 0230 to 0330. Using the original time means that the next recurrence will be calculated based on the original start time and the day/week/month/year interval. So the start time of the next occurrence can correctly revert to 0230.

Parameters:

Parameter Type Description
$interval string

adjustForTimeJumpsOfHourlyEvent

Does the processing for adjusting the time of multi-hourly events when summer time starts.

protected adjustForTimeJumpsOfHourlyEvent(\DateTimeInterface $previousEventDateTime): void

Parameters:

Parameter Type Description
$previousEventDateTime \DateTimeInterface

nextHourly

Does the processing for advancing the iterator for hourly frequency.

protected nextHourly(): mixed

nextDaily

Does the processing for advancing the iterator for daily frequency.

protected nextDaily(): mixed

nextWeekly

Does the processing for advancing the iterator for weekly frequency.

protected nextWeekly(): mixed

nextMonthly

Does the processing for advancing the iterator for monthly frequency.

protected nextMonthly(): mixed

nextYearly

Does the processing for advancing the iterator for yearly frequency.

protected nextYearly(): mixed

parseRRule

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

protected parseRRule(string|array $rrule): mixed

Parameters:

Parameter Type Description
$rrule string|array

getMonthlyOccurrences

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

protected getMonthlyOccurrences(): array

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


getHours

protected getHours(): mixed

getDays

protected getDays(): mixed

getMonths

protected getMonths(): mixed


Automatically generated on 2025-03-18