bunkat / 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.
http://bunkat.github.io/later/
MIT License
2.42k stars 245 forks source link

Minute Scheduling for Every 59 minutes is giving incorrect future schdules #223

Open yas1th opened 6 years ago

yas1th commented 6 years ago

var gt = later.parse.cron('0/50 1/1 ? '); var local = new Date("2018-1-29 11:45"); var curDate = new Date(); local.setMinutes(local.getMinutes() - local.getTimezoneOffset()); curDate.setMinutes(curDate.getMinutes() - curDate.getTimezoneOffset()); var arrNextMatchingSchedules = later.schedule(gt).next(5, local, new Date(2099, 12, 31)); console.log(arrNextMatchingSchedules);

I am recieving the results as shown below which is not expected.

Mon Jan 29 2018 17:20:00 GMT+0530 (India Standard Time), Mon Jan 29 2018 17:30:00 GMT+0530 (India Standard Time), Mon Jan 29 2018 18:20:00 GMT+0530 (India Standard Time), Mon Jan 29 2018 18:30:00 GMT+0530 (India Standard Time), Mon Jan 29 2018 19:20:00 GMT+0530 (India Standard Time

This is one of the scenarios which i am posting here but i have observed couple of scenarios in case of minutes where it is not as per expectation. I have gone through later.js code and debugged but since there were no comments i am unable to understand what is happening?

later.minutes function is having range variable for 60 and it returns a schedules array by splitiing the cron expression . suppose if i give 50 minutes it will set 50 minutes to one schedule and other 10 minutes which 60-50 as other one and again it resets it.

please help me to extend this logic for the above mentioned scenario.

yas1th commented 6 years ago

I have fixed the above issue by enhancing the later js code . I have added nextMinSchedules function to solve the above posted issue.