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

Constructor

new RecurExpansion(options)

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:
NameTypeDescription
optionsObject

Recurrence expansion options

Properties
NameTypeAttributesDescription
dtstartICAL.Time

Start time of the event

componentICAL.Component<optional>

Component for expansion, required if not resuming.

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

Members

complete :Boolean

True when iteration is fully completed.

Type:
  • Boolean

dtstart :ICAL.Time

Start date of recurring rules.

last :ICAL.Time

Last expanded time

Methods

fromData(options)

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

Parameters:
NameTypeDescription
optionsObject

Recurrence expansion options

Properties
NameTypeAttributesDescription
dtstartICAL.Time

Start time of the event

componentICAL.Component<optional>

Component for expansion, required if not resuming.

next() → {ICAL.Time}

Retrieve the next occurrence in the series.

Returns:
Type: 
ICAL.Time

toJSON() → {Object}

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

Returns:
Type: 
Object