rrule
rrule copied to clipboard
cannot add 'UNTIL' to RRuleSet
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.
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
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)
})
I face to same issue, and I found a workaround.
RRuleSet
has immutableRRule
. 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