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

Bad next on 'every 1 hours' #229

Open pjbrinck opened 6 years ago

pjbrinck commented 6 years ago

Run this

    let date = new Date();
    console.log(later.schedule(later.parse.text('every 1 hours')).prev(2, date));
    console.log(later.schedule(later.parse.text('every 1 hours')).next(2, date));
    console.log(later.schedule(later.parse.text('every 30 minutes')).prev(2, date));
    console.log(later.schedule(later.parse.text('every 30 minutes')).next(2, date));

and notice the odd current time in entry on of line two

[ 2018-04-25T08:00:00.000Z, 2018-04-25T07:00:00.000Z ]
[ 2018-04-25T08:52:48.611Z, 2018-04-25T09:00:00.000Z ]
[ 2018-04-25T08:30:00.000Z, 2018-04-25T08:00:00.000Z ]
[ 2018-04-25T09:00:00.000Z, 2018-04-25T09:30:00.000Z ]