Class RecurExpansion

Primary class for expanding recurring rules. Can take multiple rrules, rdates, exdate(s) and iterate (in order) over each next occurrence.

Once initialized this class can also be serialized saved and continue iteration from the last point.

NOTE: it is intended that this class is to be used with ICAL.Event which handles recurrence exceptions.

Example

// assuming event is a parsed ical component
var event;

var expand = new ICAL.RecurExpansion({
component: event,
dtstart: event.getFirstPropertyValue('dtstart')
});

// remember there are infinite rules so it is a good idea to limit the scope of the iterations
// then resume later on.

// next is always an ICAL.Time or null
var next;

while (someCondition && (next = expand.next())) {
// do something with next
}

// save instance for later
var json = JSON.stringify(expand);

//...

// NOTE: if the component's properties have changed you will need to rebuild the class and start
// over. This only works when the component's recurrence info is the same.
var expand = new ICAL.RecurExpansion(JSON.parse(json));

Alias

ICAL.RecurExpansion

Hierarchy

  • RecurExpansion

Constructors

  • Creates a new ICAL.RecurExpansion instance.

    The options object can be filled with the specified initial values. It can also contain additional members, as a result of serializing a previous expansion state, as shown in the example.

    Parameters

    • options: RecurExpansionOptions

      Recurrence expansion options

    Returns RecurExpansion

    Alias

    ICAL.RecurExpansion

Properties

complete: boolean = false

True when iteration is fully completed.

dtstart: Time

Start date of recurring rules.

exDate?: Time

Current negative date.

exDateInc: number = 0

Current position in exDates array

exDates?: Time[]

Array of exdate instances.

last: Time

Last expanded time

ruleDate?: Time

Current additional date.

ruleDateInc: number = 0

Current position in ruleDates array.

ruleDates?: Time[]

Array of rdate instances.

ruleIterators: RecurIterator[]

Array of rrule iterators.

Methods

  • Private

    Extract all dates from the properties in the given component. The properties will be filtered by the property name.

    Parameters

    • component: Component

      The component to search in

    • propertyName: string

      The property name to search for

    Returns Time[]

    The extracted dates.

  • Private

    Initialize the recurrence expansion.

    Parameters

    • component: Component

      The component to initialize from.

    Returns void

  • Initialize the recurrence expansion from the data object. The options object may also contain additional members, see the ICAL.RecurExpansion constructor for more details.

    Parameters

    • options: RecurExpansionOptions

      Recurrence expansion options

    Returns void

  • Converts object into a serialize-able format. This format can be passed back into the expansion to resume iteration.

    Returns Record<string, any>

Generated using TypeDoc