Skip to content

Sabre VObject RecurrenceIterator

Evert Pot edited this page Jun 6, 2013 · 5 revisions

Sabre\VObject\RecurrenceIterator

This class is used to determine new for a recurring event, when the next events occur.

This iterator may loop infinitely in the future, therefore it is important that if you use this class, you set hard limits for the amount of iterations you want to handle.

Note that currently there is not full support for the entire iCalendar specification, as it's very complex and contains a lot of permutations that's not yet used very often in software.

For the focus has been on features as they actually appear in Calendaring software, but this may well get expanded as needed / on demand

The following RRULE properties are supported * UNTIL * INTERVAL * COUNT * FREQ=DAILY * BYDAY * BYHOUR * FREQ=WEEKLY * BYDAY * BYHOUR * WKST * FREQ=MONTHLY * BYMONTHDAY * BYDAY * BYSETPOS * FREQ=YEARLY * BYMONTH * BYMONTHDAY (only if BYMONTH is also set) * BYDAY (only if BYMONTH is also set)

Anything beyond this is 'undefined', which means that it may get ignored, or you may get unexpected results. The effect is that in some applications the specified recurrence may look incorrect, or is missing.

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

Properties

$startDate

public \Sabre\VObject\DateTime $startDate

The initial event date

  • Visibility: public

$endDate

public \Sabre\VObject\DateTime $endDate

The end-date of the initial event

  • Visibility: public

$currentDate

public \Sabre\VObject\DateTime $currentDate

The 'current' recurrence.

This will be increased for every iteration.

  • Visibility: public

$exceptionDates

public array $exceptionDates = array()

List of dates that are excluded from the rules.

This list contains the items that have been overriden by the EXDATE property.

  • Visibility: public

$baseEvent

public \Sabre\VObject\Component\VEvent $baseEvent

Base event

  • Visibility: public

$overriddenDates

public array $overriddenDates = array()

List of dates that are overridden by other events.

Similar to $overriddenEvents, but this just contains the original dates.

  • Visibility: public

$overriddenEvents

public array $overriddenEvents = array()

list of events that are 'overridden'.

This is an array of Component\VEvent objects.

  • Visibility: public

$frequency

public string $frequency

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

  • Visibility: public

$until

public \Sabre\VObject\DateTime $until

The last instance of this recurrence, inclusively

  • Visibility: public

$count

public int $count

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

  • Visibility: public

$interval

public int $interval = 1

The interval.

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

  • Visibility: public

$bySecond

public array $bySecond

Which seconds to recur.

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

  • Visibility: public

$byMinute

public array $byMinute

Which minutes to recur

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

  • Visibility: public

$byHour

public array $byHour

Which hours to recur

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

  • Visibility: public

$byDay

public 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: public

$byMonthDay

public 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: public

$byYearDay

public 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: public

$byWeekNo

public 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: public

$byMonth

public array $byMonth

Which months to recur

This is an array of integers from 1 to 12.

  • Visibility: public

$bySetPos

public 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: public

$weekStart

public string $weekStart = 'MO'

When a week starts

  • Visibility: public

$counter

public int $counter

The current item in the list

  • Visibility: public

$dayMap

private 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: private

$dayNames

private 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: private

$currentOverriddenEvent

private \Sabre\VObject\Component $currentOverriddenEvent

If the current iteration of the event is an overriden event, this property will hold the VObject

  • Visibility: private

$nextDate

private \Sabre\VObject\DateTime $nextDate

This property may contain the date of the next not-overridden event.

This date is calculated sometimes a bit early, before overridden events are evaluated.

  • Visibility: private

Methods

__construct

mixed Sabre\VObject\RecurrenceIterator::__construct(\Sabre\VObject\Component $vcal, string|null $uid)

Creates the iterator

You should pass a VCALENDAR component, as well as the UID of the event we're going to traverse.

  • Visibility: public

Arguments

current

\Sabre\VObject\DateTime Sabre\VObject\RecurrenceIterator::current()

Returns the current item in the list

  • Visibility: public

getDtStart

\Sabre\VObject\DateTime Sabre\VObject\RecurrenceIterator::getDtStart()

This method returns the startdate for the current iteration of the event.

  • Visibility: public

getDtEnd

\Sabre\VObject\DateTime Sabre\VObject\RecurrenceIterator::getDtEnd()

This method returns the enddate for the current iteration of the event.

  • Visibility: public

getEventObject

\Sabre\VObject\Component\VEvent Sabre\VObject\RecurrenceIterator::getEventObject()

Returns a VEVENT object with the updated start and end date.

Any recurrence information is removed, and this function may return an 'overridden' event instead.

This method always returns a cloned instance.

  • Visibility: public

key

int Sabre\VObject\RecurrenceIterator::key()

Returns the current item number

  • Visibility: public

valid

bool Sabre\VObject\RecurrenceIterator::valid()

Whether or not there is a 'next item'

  • Visibility: public

rewind

void Sabre\VObject\RecurrenceIterator::rewind()

Resets the iterator

  • Visibility: public

fastForward

void Sabre\VObject\RecurrenceIterator::fastForward(\Sabre\VObject\DateTime $dt)

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

Note that this checks the current 'endDate', not the 'stardDate'. This means that if you forward to January 1st, the iterator will stop at the first event that ends after January 1st.

  • Visibility: public

Arguments

  • $dt Sabre\VObject\DateTime

isInfinite

bool Sabre\VObject\RecurrenceIterator::isInfinite()

Returns true if this recurring event never ends.

  • Visibility: public

next

void Sabre\VObject\RecurrenceIterator::next()

Goes on to the next iteration

  • Visibility: public

nextHourly

void Sabre\VObject\RecurrenceIterator::nextHourly()

Does the processing for advancing the iterator for hourly frequency.

  • Visibility: protected

nextDaily

void Sabre\VObject\RecurrenceIterator::nextDaily()

Does the processing for advancing the iterator for daily frequency.

  • Visibility: protected

nextWeekly

void Sabre\VObject\RecurrenceIterator::nextWeekly()

Does the processing for advancing the iterator for weekly frequency.

  • Visibility: protected

nextMonthly

void Sabre\VObject\RecurrenceIterator::nextMonthly()

Does the processing for advancing the iterator for monthly frequency.

  • Visibility: protected

nextYearly

void Sabre\VObject\RecurrenceIterator::nextYearly()

Does the processing for advancing the iterator for yearly frequency.

  • Visibility: protected

getMonthlyOccurrences

array Sabre\VObject\RecurrenceIterator::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\RecurrenceIterator::getHours()
  • Visibility: protected

getDays

mixed Sabre\VObject\RecurrenceIterator::getDays()
  • Visibility: protected
Clone this wiki locally