1.0.0 • Published 7 years ago
cron-translate v1.0.0
cron-translate
Translate english to cron expressions
Usage
Install cron-translate
npm install --save cron-translateconst cronTranslate = require('cron-translate');
let cron = cronTranslate.toCron('every minute');Syntax
cron-translate allows to use some fields and operators to compose the expressions that are translatable to cron expressions
Fields
The allowed fields are second, minute, hour, day, month, week day, or the plurals seconds, minutes, hours, days, months, week days.
Operators
- every operator may be used in three ways:
every <field>: sets the field value to*. e.g:every day;every <value> <field>: sets the field value to*/<value>. e.g:every 10 minutes;every <field> <value>: sets the field value to<value>. e.g:every hour 2;
- on operator may be use as the
every <field> value:on <field> <value>: sets the field value to<value>. e.g:on hour 2;
- from to operator is used to create ranges.
from <field> <value1> to <value2>: It sets the field value<value1>-<value2>. e.g:from minute 2 to 10;
Values
The allowed values are:
- Numbers: for all fields.
- Names: for months and week days, full names and abreviations are allowed. e.g:
mondayandmonare the same.
Examples
Every usage
every secondis converted to* * * * * *;every minuteis converted to0 * * * * *;every houris converted to0 0 * * * *;every sundayis converted to0 0 0 * * sunday;every januaryis converted to0 0 0 * january *;every 2 minutesis converted to0 */2 * * * *;every day 10is converted to0 0 0 10 * *;
On usage
on minute 2is converted to0 2 * * * *;on satis converted to0 0 0 * * sat;
From to usage
from minute 2 to 30is converted to0 2-30 * * * *;
Combining expressions
The expressions may be combined to create complex cron expresions:
every 10 minutes from hour 2 to 8is converted to0 */10 2-8 * * *;every monday on hour 2 from minute 10 to 20is converted to0 10-20 2 * * monday;
1.0.0
7 years ago