Skip to main content
A newer version of this page is available. .

OccurrenceCalculator Class

Enables you to calculate the occurrences for a given recurrent appointment.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v20.2.Core.dll


public abstract class OccurrenceCalculator

The following members accept/return OccurrenceCalculator objects:


Use the OccurrenceCalculator object to calculate occurrences for a predefined time interval, as illustrated in the code sample below.


The calculated appointments do not contain custom fields. This behavior is by design; it increases performance.

If you need to construct the actual recurrence appointment series with both standard and custom appointment fields, then you have to use the AppointmentPatternExpander.Expand method from the DevExpress.XtraScheduler.Native namespace. Create a new AppointmentPatternExpander instance using the Appointment.RecurrencePattern value of your appointment, and then call the Expand method to get the appointments collection.


The following code sample retrieves the recurrence pattern of the first appointment in the scheduler’s collection and replaces all occurrences with appointments of AppointmentType.Normal type. It utilizes the OccurrenceCalculator.CalcOccurrences method to calculate items in the recurrent series.

// Calculate occurrences for the first recurrent series.
Appointment pattern = schedulerStorage1.Appointments.Items.FirstOrDefault(item => item.Type == AppointmentType.Pattern);
if (pattern == null) return;
OccurrenceCalculator calc = OccurrenceCalculator.CreateInstance(pattern.RecurrenceInfo);
TimeInterval processedInterval = new TimeInterval(DateTime.Today, DateTime.Today.AddDays(7));
AppointmentBaseCollection calculatedOccurrences = calc.CalcOccurrences(processedInterval, pattern);

// Create normal appointments in place of occurrences.
for (int i = 0; i < calculatedOccurrences.Count; i++) {
    Appointment resultAppointment = schedulerStorage1.CreateAppointment(AppointmentType.Normal);
    resultAppointment.Subject = String.Format("Occurrence {0} - {1}", calculatedOccurrences[i].Subject, i);
    resultAppointment.Description = calculatedOccurrences[i].Description;
    resultAppointment.Start = calculatedOccurrences[i].Start;
    resultAppointment.End = calculatedOccurrences[i].End;

// Remove the pattern and occurrences.

The following code snippets (auto-collected from DevExpress Examples) contain references to the OccurrenceCalculator class.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.


See Also