Skip to content

Recurrence rule (RRULE) support #5

@PhilflowIO

Description

@PhilflowIO

Problem

Recurrence rules (RRULE) have complex syntax and semantics. Current implementation treats them as simple strings which may lead to invalid rules.

RRULE Complexity

RRULE:FREQ=WEEKLY;BYDAY=MO,WE,FR;COUNT=10
RRULE:FREQ=MONTHLY;BYMONTHDAY=1,15;UNTIL=20251231T235959Z
RRULE:FREQ=YEARLY;BYMONTH=1;BYDAY=1MO

Current Behavior

// Accepts any string - may create invalid RRULE
updateFields(event, {
  'RRULE': 'FREQ=WEEKLY;BYDAY=MO,WE,FR'
});

Related Operations

  • Expanding recurring events
  • Handling EXDATE (exception dates)
  • RDATE (additional dates)
  • Modifying single occurrences

Philosophy

RRULE manipulation and expansion is complex business logic that doesn't belong in this utility library.

Recommendation

Users should:

  1. Use ical.js Recur class for RRULE manipulation
  2. Use application logic for recurrence expansion
  3. Use tsdav-utils only for non-recurrence properties

Workaround

Using ical.js for RRULE

import ICAL from 'ical.js';

// Create recurrence rule
const recur = new ICAL.Recur({
  freq: 'WEEKLY',
  byday: ['MO', 'WE', 'FR'],
  count: 10
});

const component = new ICAL.Component(ICAL.parse(event.data));
const vevent = component.getFirstSubcomponent('vevent');

// Set RRULE
vevent.updatePropertyWithValue('rrule', recur);

// Update other fields with tsdav-utils
const updated = updateFields(component.toString(), {
  'SUMMARY': 'Recurring Meeting'
});

Expanding Recurring Events

import ICAL from 'ical.js';

const component = new ICAL.Component(ICAL.parse(event.data));
const vevent = component.getFirstSubcomponent('vevent');
const event = new ICAL.Event(vevent);

// Expand recurrences
const expand = new ICAL.RecurExpansion({
  component: vevent,
  dtstart: event.startDate
});

const next10 = [];
for (let i = 0; i < 10; i++) {
  next10.push(expand.next());
}

Related

  • RFC 5545 Section 3.3.10 (Recurrence Rule)
  • RFC 5545 Section 3.8.5.2 (EXDATE)
  • RFC 5545 Section 3.8.5.3 (RDATE)
  • ical.js Recur documentation
  • ical.js RecurExpansion documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions