jkbrzt / rrule

JavaScript library for working with recurrence rules for calendar dates as defined in the iCalendar RFC and more.
https://jkbrzt.github.io/rrule
Other
3.31k stars 512 forks source link

Dates on month and day of DTSTART that are after UNTIL date are included in output #584

Open informedfunction opened 1 year ago

informedfunction commented 1 year ago

For an rrule that starts on Sept 1 2022 and has an UNTIL value of July 1 2023, the between() method outputs Sept 1 2023, which is after the UNTIL date. Sept 1 is also outputted in 2024, 2025, and onward indefinitely.

Code sample:

const rules = rrulestr(DTSTART=20220901T080000\nRRULE:FREQ=MONTHLY;BYMONTHDAY=1;UNTIL=20230701T235959)
const recurrenceDates = rules
          .between(
            currentDateRange[0], // June 15 2023
            currentDateRange[1] // Sept 15 2023
         )
joaquinwojcik commented 1 year ago

Your rule isn't correct. You have something (\nRRULE:) that's preventing the rule from being completely parsed.

DTSTART=20220901T080000\nRRULE:FREQ=MONTHLY;BYMONTHDAY=1;UNTIL=20230701T235959

If you replace \nRRULE: for a semicolon it works perfectly.

DTSTART=20220901T080000;FREQ=MONTHLY;BYMONTHDAY=1;UNTIL=20230701T235959

image

https://codesandbox.io/s/proud-frog-h25np6?file=/src/App.js:356-427