-
Notifications
You must be signed in to change notification settings - Fork 244
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
Wrong value for next() #75
Comments
This is a common question, |
Thanks for the comment. |
In your case, you've specified that minute values of 0, 15, 30, and 45 should be considered valid (every 15 minutes). |
@bunkat you should compare the dates by subtracting them to see whether the time given is after the retrieved one, because I have this issue too and it's across multiple hours. |
Hello, Looking at the Later documentation (http://bunkat.github.io/later/parsers.html), it says:
If I have understood correctly what was said before, if a next request starts on a month that is January, April, July or October, the start date will be the first next date, no matter it points or not to the first second of the month. Is that correct? |
That's correct. |
OK, that's fine as long as it is predictable. So for the record, I have come up with the following way in order to find the next occurrence after a date: let schedule = later.schedule(/*a later schedule description*/);
let date = /*a javascript date*/;
let previousOccurrence = schedule.prev(1, date);
let nextOccurrence = schedule.next(2, previousOccurrence)[1];
/* nextOccurrence can be undefined */ Later seems to operate quite well with this but if there is a better way to obtain the next occurrence, please let me know. Perhaps this could be added to the documentation in the section Calculating instances? |
I also got to this first prev and second next workaround. :-) |
Here is a simple scenario:
var s = later.parse.cron("0 0/15 * * * *", true); //every 15 minutes
var date = later.schedule(s).next(1, Date.parse("2014-10-14T03:15:00.999Z")); //2014-10-14T03:15:00.999Z
After (or even at) 03:15:00, the next function should return 2014-10-14T03:30:00.999Z but it returns 2014-10-14T03:15:00.999Z instead.
The text was updated successfully, but these errors were encountered: