jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.

Home Page:https://jkbrzt.github.io/rrule

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Given an RRuleSet, how can we modify a single event in a recurrence

gavin-traba opened this issue · comments

Not quite an issue but a question around documentation. Didn't find anything when looking through existing issues. Want to also acknowledge maybe RRuleSet is not the right class to use, and potentially I should just use RRule.

Given an RRuleSet like

rruleSet.rrule(
  new RRule({
    freq: RRule.WEEKLY,
    byweekday: [RRule.MO,  RRule.TU, RRule.WE,  RRule.TH, RRule.FR],
    interval: 1,
    dtstart: datetime(2024, 3, 15, 9, 30),
  })
)

and i want to modify one of the events in this rule for example:

Fri, | 15 | Mar | 2024 | 9:30:00 | GMT 
Mon, | 18 | Mar | 2024 | 9:30:00 | GMT  // <-- this one i want to happen at 10:30:00 instead
Tue, | 19 | Mar | 2024 | 9:30:00 | GMT
Wed, | 20 | Mar | 2024 | 9:30:00 | GMT
Thu, | 21 | Mar | 2024 | 9:30:00 | GMT
Fri, | 22 | Mar | 2024 | 9:30:00 | GMT
Mon, | 25 | Mar | 2024 | 9:30:00 | GMT
Tue, | 26 | Mar | 2024 | 9:30:00 | GMT
Wed, | 27 | Mar | 2024 | 9:30:00 | GMT
Thu, | 28 | Mar | 2024 | 9:30:00 | GMT
Fri, | 29 | Mar | 2024 | 9:30:00 | GMT

Is this possible with the existing API?

EXDATE works great for canceling dates entirely, but modifying is a little more unclear to me 🤔

Hello, you can exclude a date then add a new one like so

const ruleSet = new RRuleSet()
ruleSet.rrule(RRule.fromString(event.rrule))

// Exclude this date from the rrule
ruleSet.exdate(getDatetime(eventLog.eventAt))

// Add a new date to the rrule
ruleSet.rdate(getDatetime(patchData.eventAt))

You can try this if you want to remove an exdate at some point #541