Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
syedkhairi opened this issue Nov 9, 2022 · 1 comment
Open
Labels
question Further information is requested

Comments

@syedkhairi
Copy link

syedkhairi commented Nov 9, 2022

What would you like to discuss?

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

Checklist

  • [ y] I have read the documentation.

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

@syedkhairi syedkhairi added the question Further information is requested label Nov 9, 2022
@eXaminator
Copy link

I came across the same issue. One thing that helps as an easy workaround for others that come across this question would be to just pass Number.POSITIVE_INFINITY as the first argument of next() or prev(). Keep in mind that you'll probably crash your app if you forget to pass in an end date or if the given interval contains a LOT of ocurrences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants