rrule icon indicating copy to clipboard operation
rrule copied to clipboard

cannot add 'UNTIL' to RRuleSet

Open zachi opened this issue 3 years ago • 3 comments

hi, after spending good amount of hours... couldn't find a way to add 'UNTIL' date to rrule with EXDATE. for ex this rrule 'EXDATE;TZID=Asia/Jerusalem:20201124T150000\nRRULE:FREQ=WEEKLY' basically i want to deserialize it to an object add 'until', and serialize it again to get the result. 'EXDATE;TZID=Asia/Jerusalem:20201124T150000\nRRULE:FREQ=WEEKLY;UNTIL=20210329T060000Z' the only way to parse rrules with EXDATE is rrulestr. but then it cannot get the 'until'. i actually found a hackie way to change it through rrulestr('...')._rrule[0].origOptions.untill. but it is not the way to do so. i've have tried so many options that i truly believe there is no way to do it...

any idea?

thanks Zachi.

zachi avatar Apr 12 '21 15:04 zachi

I don’t think that is possible for RRuleSet. Until is for RRule. I would suggest to try rrulestr once. If you are setting until externally then it gives you direct rruleset with until in created rrule

swapnilnandgave avatar May 18 '21 10:05 swapnilnandgave

I face to same issue, and I found a workaround. RRuleSet has immutable RRule. So, we have to reinstantiate RRuleSet with each properties.

const baseRRuleSet = rrulestr('str without until')

const rRuleSet = new RRuleSet()
// set RRule into RRuleSet
baseRRuleSet.rrules().forEach((rRule) => {
  rRuleSet.rrule(
    new RRule({
      ...rRule.options,
      until,
    })
  )
})
// extends exdates
baseRRuleSet.exdates().forEach((exdate) => {
  rRuleSet.exdate(exdate)
})

motoya-k avatar May 02 '22 09:05 motoya-k

I face to same issue, and I found a workaround. RRuleSet has immutable RRule. So, we have to reinstantiate RRuleSet with each properties.

const baseRRuleSet = rrulestr('str without until')

const rRuleSet = new RRuleSet()
// set RRule into RRuleSet
baseRRuleSet.rrules().forEach((rRule) => {
  rRuleSet.rrule(
    new RRule({
      ...rRule.options,
      until,
    })
  )
})
// extends exdates
baseRRuleSet.exdates().forEach((exdate) => {
  rRuleSet.exdate(exdate)
})

..rRule.options should be ...Rule.origOptions

ali80 avatar Aug 12 '22 08:08 ali80