Saturnus
Saturnus
is a cron parser for ES6, using Moment.js to parse into manageable dates.
Installation
npm install saturnus
Introduction
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. ;)
Quickstart
const Saturnus = require('saturnus');
let chronos = new Saturnus('* * * * *');
let buildingCron = new Saturnus();
buildingCron.parse()
.every().step(5).second()
.at(15).minute()
.between(12, 15).hours()
.every.weekday()
.between(2,9).step(2).months()
.exec()
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.
Configuration
When creating a parsed expression, you can use various options to change its behaviour. The defaults are shown below:
let options = {
throw: false,
startDate: Date.now(),
endDate: '3000-12-31T23:59',
locale: 'en',
};
let chronos = new Saturnus('* * * * *');
If you use throw:false
, be aware that the attibute isValid
will be set to false
.
let options = {
throw: false,
};
let chronos = new Saturnus('*');
chronos.isValid
For the complete docs be sure to visit the wiki.