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

recur() function not working correctly? #176

Open
telmof opened this issue Jul 25, 2016 · 0 comments
Open

recur() function not working correctly? #176

telmof opened this issue Jul 25, 2016 · 0 comments

Comments

@telmof
Copy link

telmof commented Jul 25, 2016

I'm using Later.js for recurring events. I'm trying to test the recur() function and it doesn't seem to be working properly, and I don't know why. Here's my example:

var schedule_hourly = later.schedule(later.parse.recur().every(x).hour()),
    start_hourly = moment(start_day + " " + start_time, 'YYYY/MM/DD HH:mm');
var occurrences_hourly = schedule_hourly.next(y, start_hourly);

for (var i = 0; i < occurrences_hourly.length; i++) {
    var execution_dates_hourly = [];
    execution_dates_hourly = moment(occurrences_hourly[i]).format('YYYY/MM/DD HH:mm');
    console.log(execution_dates_hourly);
}

Where:

  • x and y are values that I can change;
  • start_day is in the format YYYY/MM/DD;
  • start_time is in the format HH:mm.

With an initial date of 2016/07/20 10:00, x=2 and y=5 I get the following on the console:

2016/07/20 10:00
2016/07/20 12:00
2016/07/20 14:00
2016/07/20 16:00
2016/07/20 18:00

So it's working correctly. I get a repeating event every 2 hours, starting at 10:00 hours that repeats 5 times.

However, if I change the x to 8, I get this:

2016/07/20 16:00
2016/07/21 00:00
2016/07/21 08:00
2016/07/21 16:00
2016/07/22 00:00

Why does it start at 16:00 now? Shouldn't it start at 10:00 like before and go to 18:00 next?

@telmof telmof changed the title recur() function not working correctly recur() function not working correctly? Jul 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant