Skip to content

Sabre VObject Recur RRuleIterator

Evert Pot edited this page Sep 1, 2014 · 2 revisions

Sabre\VObject\Recur\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.

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

Properties

$startDate

protected \DateTime $startDate

The reference start date/time for the rrule.

All calculations are based on this initial date.

  • Visibility: protected

$currentDate

protected \DateTime $currentDate

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

  • Visibility: protected

$frequency

protected string $frequency

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

  • Visibility: protected

$count

protected integer $count

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

  • Visibility: protected

$interval

protected integer $interval = 1

The interval.

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

  • Visibility: protected

$until

protected \DateTime $until

The last instance of this recurrence, inclusively

  • Visibility: protected

$bySecond

protected array $bySecond

Which seconds to recur.

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

  • Visibility: protected

$byMinute

protected array $byMinute

Which minutes to recur

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

  • Visibility: protected

$byHour

protected array $byHour

Which hours to recur

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

  • Visibility: protected

$counter

protected integer $counter

The current item in the list.

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

  • Visibility: protected

$byDay

protected array $byDay

Which weekdays to recur.

This is an array of weekdays

This may also be preceeded 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.

  • Visibility: protected

$byMonthDay

protected array $byMonthDay

Which days of the month to recur

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.

  • Visibility: protected

$byYearDay

protected array $byYearDay

Which days of the year to recur.

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).

  • Visibility: protected

$byWeekNo

protected array $byWeekNo

Which week numbers to recur.

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.

  • Visibility: protected

$byMonth

protected array $byMonth

Which months to recur.

This is an array of integers from 1 to 12.

  • Visibility: protected

$bySetPos

protected array $bySetPos

Which items in an existing st to recur.

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.

  • Visibility: protected

$weekStart

protected string $weekStart = 'MO'

When the week starts.

  • Visibility: protected

$dayNames

protected array $dayNames = array(0 => 'Sunday', 1 => 'Monday', 2 => 'Tuesday', 3 => 'Wednesday', 4 => 'Thursday', 5 => 'Friday', 6 => 'Saturday')

Mappings between the day number and english day name.

  • Visibility: protected

$dayMap

protected array $dayMap = array('SU' => 0, 'MO' => 1, 'TU' => 2, 'WE' => 3, 'TH' => 4, 'FR' => 5, 'SA' => 6)

Simple mapping from iCalendar day names to day numbers

  • Visibility: protected

Methods

__construct

mixed Sabre\VObject\Recur\RRuleIterator::__construct(string|array $rrule, \DateTime $start)

Creates the Iterator

  • Visibility: public

Arguments

  • $rrule string|array
  • $start DateTime

current

mixed Sabre\VObject\Recur\RRuleIterator::current()
  • Visibility: public

key

integer Sabre\VObject\Recur\RRuleIterator::key()

Returns the current item number

  • Visibility: public

valid

boolean Sabre\VObject\Recur\RRuleIterator::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.

  • Visibility: public

rewind

void Sabre\VObject\Recur\RRuleIterator::rewind()

Resets the iterator

  • Visibility: public

next

void Sabre\VObject\Recur\RRuleIterator::next()

Goes on to the next iteration

  • Visibility: public

isInfinite

boolean Sabre\VObject\Recur\RRuleIterator::isInfinite()

Returns true if this recurring event never ends.

  • Visibility: public

fastForward

void Sabre\VObject\Recur\RRuleIterator::fastForward(\DateTime $dt)

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

  • Visibility: public

Arguments

  • $dt DateTime

nextHourly

void Sabre\VObject\Recur\RRuleIterator::nextHourly()

Does the processing for advancing the iterator for hourly frequency.

  • Visibility: protected

nextDaily

void Sabre\VObject\Recur\RRuleIterator::nextDaily()

Does the processing for advancing the iterator for daily frequency.

  • Visibility: protected

nextWeekly

void Sabre\VObject\Recur\RRuleIterator::nextWeekly()

Does the processing for advancing the iterator for weekly frequency.

  • Visibility: protected

nextMonthly

void Sabre\VObject\Recur\RRuleIterator::nextMonthly()

Does the processing for advancing the iterator for monthly frequency.

  • Visibility: protected

nextYearly

void Sabre\VObject\Recur\RRuleIterator::nextYearly()

Does the processing for advancing the iterator for yearly frequency.

  • Visibility: protected

parseRRule

void Sabre\VObject\Recur\RRuleIterator::parseRRule(string|array $rrule)

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

  • Visibility: protected

Arguments

  • $rrule string|array

getMonthlyOccurrences

array Sabre\VObject\Recur\RRuleIterator::getMonthlyOccurrences()

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

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

  • Visibility: protected

getHours

mixed Sabre\VObject\Recur\RRuleIterator::getHours()
  • Visibility: protected

getDays

mixed Sabre\VObject\Recur\RRuleIterator::getDays()
  • Visibility: protected

getMonths

mixed Sabre\VObject\Recur\RRuleIterator::getMonths()
  • Visibility: protected
Clone this wiki locally