How to display what time is left after the later.js text parser applied?
For example, I want to know it before the setInterval
started.
const later = require('later');
later.date.localTime();
const schedule = later.parse.text('at 12:40');
later.setInterval(() => {
console.log('executed!');
}, schedule);
There is .next() method which calculates the future occurrences.
Display the future occurrence
Input:
console.log(later.schedule(schedule).next());
Output:
2017-11-28T12:40:00.000Z
Display 10 future occurrences
Input
console.log(later.schedule(schedule).next(10));
Output
[ 2017-11-28T12:40:00.000Z,
2017-11-29T12:40:00.000Z,
2017-11-30T12:40:00.000Z,
2017-12-01T12:40:00.000Z,
2017-12-02T12:40:00.000Z,
2017-12-03T12:40:00.000Z,
2017-12-04T12:40:00.000Z,
2017-12-05T12:40:00.000Z,
2017-12-06T12:40:00.000Z,
2017-12-07T12:40:00.000Z ]