rrule icon indicating copy to clipboard operation
rrule copied to clipboard

Recurring weekdays fails when Fridays are included

Open jdardonp opened this issue 4 years ago • 0 comments

This issue is similar to https://github.com/jakubroztocil/rrule/issues/291 but hopefully will shed a little more light on the matter.

Given a pattern that needs to excecute every X weekdays... e.g. A class you need to give/take every 6 weekdays: Mon 16th, Tue 24th, Wed 1st, Thu 9th etc.

When you input it into rrule as: rule = new RRule({
freq: RRule.DAILY,
dtstart: new Date(Date.UTC(2021, 7, 17, 19, 18, 0)),
interval: 6,
byweekday: [RRule.MO, RRule.TU, RRule.WE, RRule.TH, RRule.FR] })

rule.toString() = DTSTART:20210817T191800Z RRULE:FREQ=DAILY;INTERVAL=6;WKST=MO;BYDAY=MO,TU,WE,TH,FR rule.toText() = every 6 weekdays

Actual Erroneous Output rule.all() 1 | Tue, | 17 | Aug | 2021 | 19:18:00 | GMT 2 | Mon, | 23 | Aug | 2021 | 19:18:00 | GMT 3 | Fri, | 10 | Sep | 2021 | 19:18:00 | GMT 4 | Thu, | 16 | Sep | 2021 | 19:18:00 | GMT 5 | Wed, | 22 | Sep | 2021 | 19:18:00 | GMT 6 | Tue, | 28 | Sep | 2021 | 19:18:00 | GMT 7 | Mon, | 04 | Oct | 2021 | 19:18:00 | GMT 8 | Fri, | 22 | Oct | 2021 | 19:18:00 | GMT 9 | Thu, | 28 | Oct | 2021 | 19:18:00 | GMT

The expected result should be: Tue 17 Aug Wed 25 Aug Thu 2 Sep Fri 10 Sep Mon 20 Sep As it should be taking 1 day out of every 6 week days (but only within the set M,T W, Th,Fr)

Two important clues that help identify the root of the problem:

  1. Analysing the pattern it seems to me that it is scheduling counting calendar days and only not selecting/marking the ones that land in a weekend. Currently it's doing this: Tue (day 1) SELECTED Wed (day 2) Thu (day 3) Fri (day 4) Sat (day 5) Sun (day 6) Mon (day 1) SELECTED Tue (day 2) Wed (day 3) Thu (day 4) Fri (day 5) Sat (day 6) Sun (day 1) SELECTED BUT FILTERED OUT BECAUSE IT’S A WEEKEND Mon (day 2) Tue (day 3) Wed (day 4) Thu (day 5) Fri (day 6) Sat (day 1) Sun (day 2) Mon (day 3) Tue (day 4) Wed (day 5) Thu (day 6) Fri (day 1) SELECTED -- The Pattern should have been doing this: Tue (day 1) SELECTED Wed (day 2) Thu (day 3) Fri (day 4) Sat ignored Sun ignored Mon (day 5) Tue (day 6) Wed (day 1) SELECTED Thu (day 2) Fri (day 3) Sat ignored Sun ignored Mon (day 4) Tue (day 5) Wed (day 1) SELECTED

I am using RRule in the demo app in the web https://jakubroztocil.github.io/rrule/# where the problem reproduces exactly as in the library.

My local time zone is GMT-6:00

jdardonp avatar Aug 18 '21 05:08 jdardonp