breejs / later

*Maintained fork of Later.* A javascript library for defining recurring schedules and calculating future (or past) occurrences for them. Includes support for using English phrases and Cron schedules. Works in Node and in the browser.
https://breejs.github.io/later/
MIT License
134 stars 13 forks source link

[discussion] How to get all occurrences between start and end date? #29

Open syedkhairi opened 1 year ago

syedkhairi commented 1 year ago

What would you like to discuss?

How to get all the dates of occurrences between a defined start and end date?

Checklist

The documentation shows: later.schedule(schedule).next(count, start, end)

What if I want to find out all possible occurrences between two dates for example:

let sched = later.schedule(later.parse.text("every 2 days on Monday"));
let start = new Date('November 9, 2022 03:24:00');
let end = new Date('December 17, 2022 03:24:00');
let occurrences = sched.next(5, start, end);
console.log(occurrences);

So instead of; let occurrences = sched.next(5, start, end); is there a way to get all the occurrences between the two dates without limiting them to 5 dates.

I can do a workaround of a loop to check with end date, but I thought there might be a way already.

Thanks