Open michaeltoohig opened 5 years ago
I think this is a legitimate bug, but fixing it will probably take something of a rewrite.
The problem starts when you call RRuleSet.all
. Since you've passed an iterator function to stop iterations at 10, you've exposed this bug. What RRuleSet.all
is actually doing is iterating through the first rrule, which is unlimited, and reaching your quota of 10 with only the first rrule. If you didn't pass an iterator, but instead used UNTIL
or COUNT
properties to limit the rrule, you'd see results from both rules in your result set, since all()
iterates through all of the first rrule, then all of the second, etc., then finally sorts all the resulting dates together once they're built. In order to fix this bug, we'd have to find the next date of all of the rrules, then pass the nearest one to the iterator.
I added UNTIL
to each of the rrule strings and instead searched the rruleset
using between
which does work as I wanted.
I can live with that. I don't really need the all
search; between now and a few months ahead from now is fine for what I'm doing.
var r1 = "DTSTART:20190228T141000\nRRULE:FREQ=DAILY;BYDAY=TH;BYHOUR=12;UNTIL=20190528T141000"
var r2 = "DTSTART:20190227T105000\nRRULE:FREQ=DAILY;BYDAY=SA;BYHOUR=12;UNTIL=20190528T141000"
var set = new rrule.RRuleSet()
set.rrule(new rrule.rrulestr(r1))
set.rrule(new rrule.rrulestr(r2))
var dates = set.between(new Date(Date.UTC(2019, 2, 4)), new Date(Date.UTC(2019, 5, 3)))
console.log(dates)
I also wanted to thank you for your quick response and helpful description of what is going on and caused the error.
I think this is a legitimate bug, but fixing it will probably take something of a rewrite.
The problem starts when you call
RRuleSet.all
. Since you've passed an iterator function to stop iterations at 10, you've exposed this bug. WhatRRuleSet.all
is actually doing is iterating through the first rrule, which is unlimited, and reaching your quota of 10 with only the first rrule. If you didn't pass an iterator, but instead usedUNTIL
orCOUNT
properties to limit the rrule, you'd see results from both rules in your result set, sinceall()
iterates through all of the first rrule, then all of the second, etc., then finally sorts all the resulting dates together once they're built. In order to fix this bug, we'd have to find the next date of all of the rrules, then pass the nearest one to the iterator.
Hi @davidgoli thanks for explaining what is going on, would like to ask if there is any status update on this? This seems to be pretty important, even in the cases where the first rrule is not infinite but have many many occurrences.
This seems to be the expected behaviour when using rruleSet.all() most of the time, unless perhaps the documentation mentions that rruleSet.all is not guaranteed to be ordered?
Lastly, would this affect dates / occurrences added via rrulset.rdate() ? I assume it will also be affected? Thanks!
Reporting an issue
Thank you for taking an interest in
rrule
! Please include the following in your report:rrule
you are using$ date
from the command line of the machine showing the bug)Code
I have been trying to use
rruleset
but only the firstrrule
is calculated when using.all
Expected Output
A list of all rrule events included in both rrule strings
r1
andr2
.Actual Output
Only the
r1
string given to therruleset
is calculated. Switching the order of ther1
andr2
are given torruleset
will calculate the output ofr2
.Version
2.6.0 is installed via
npm
OS
I am using WSL (debian stretch).
Timezone
running the
date
returnsbut my timezone is +11