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.34k stars 513 forks source link

Call to after in a past date don't work for rrule without DTSTART #428

Open rittme opened 4 years ago

rittme commented 4 years ago

Reporting an issue

Thank you for taking an interest in rrule! Please include the following in your report:

When calling after with a date in the past, on a rrule without DTSTART, the result is not the expected:

const now = new Date('2020-03-01T10:30:00.000Z');
const rule = RRule.fromString('RRULE:FREQ=MONTHLY;INTERVAL=1;BYMONTHDAY=1');
const ruleWithDTSTART = RRule.fromString('RRULE:FREQ=MONTHLY;INTERVAL=1;DTSTART=20200101T103000Z');
const next = rule.after(now);
const nextWithDTSTART = ruleWithDTSTART.after(now);

In this example, from my understanding the value of next and nextWithDTSTART should be the same.

But in reality:

next => 2020-11-01T05:22:21.000Z
nextWithDTSTART => 2020-04-01T10:30:00.000Z

When the rule doesn't have a DTSTART, a date in the past passed to after is ignored, and the current date is used. I believe the result of both calls should be the same.