Saturnus is a cron parser for ES6, using Moment.js to parse into manageable dates.
npm install saturnus
You must know about cron and its expressions, well... sometimes it can be a pain parsing them by yourself. Specially if you only want to validate an ISO string. That's when
Saturnus comes into play.
This library is under heavy development, because (guess what?) us, "the creators", are using it for many projects so... we might as well share part of our efforts with the Node community. ;)
const Saturnus = ;//Don't worry I'm bot asynchronous and I'm non-blockinglet chronos = '* * * * *';//But if you need me on the fly...let buildingCron = ;buildingCron//Every five seconds//At minute 15//From 12 to 3 p.m.every //Any day of the weekday//In February, April, June and August//Finish building
When returning a date, we use Moment.js, so it can be easier to manipulate.
And knowing that, just a glimpse at the methods and you're ready to go.
When creating a parsed expression, you can use various options to change its behaviour. The defaults are shown below:
let options =throw: false //Throw errors in real time (bad for callbacks)startDate: Date //When to start validatingendDate: '3000-12-31T23:59' //When to stop recognizing dateslocale: 'en' //Locale for prettify;let chronos = '* * * * *';
If you use
throw:false, be aware that the attibute
isValid will be set to
let options =throw: false;let chronos = '*';chronosisValid //false