Skip to content

Commit

Permalink
Update dayOfWeek format to match crontab: Sunday 0-6 instead of 1-7.
Browse files Browse the repository at this point in the history
  • Loading branch information
danhbear committed Jul 24, 2012
1 parent 36eb441 commit e3204de
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -25,13 +25,13 @@ Available Cron patterns:
Ranges. E.g. 1-3,5 Ranges. E.g. 1-3,5
Steps. E.g. */2 Steps. E.g. */2


[Read up on cron patterns here](http://help.sap.com/saphelp_xmii120/helpdata/en/44/89a17188cc6fb5e10000000a155369/content.htm). [Read up on cron patterns here](http://crontab.org).


Another cron example Another cron example
========== ==========


var cronJob = require('cron').CronJob; var cronJob = require('cron').CronJob;
var job = new cronJob('00 30 11 * * 2-6', function(){ var job = new cronJob('00 30 11 * * 1-5', function(){
// Runs every weekday (Monday through Friday) // Runs every weekday (Monday through Friday)
// at 11:30:00 AM. It does not run on Saturday // at 11:30:00 AM. It does not run on Saturday
// or Sunday. // or Sunday.
Expand Down Expand Up @@ -60,7 +60,7 @@ For good measure


var cronJob = require('cron').CronJob; var cronJob = require('cron').CronJob;
var job = new cronJob({ var job = new cronJob({
cronTime: '00 30 11 * * 2-6', cronTime: '00 30 11 * * 1-5',
onTick: function() { onTick: function() {
// Runs every weekday (Monday through Friday) // Runs every weekday (Monday through Friday)
// at 11:30:00 AM. It does not run on Saturday // at 11:30:00 AM. It does not run on Saturday
Expand Down
6 changes: 3 additions & 3 deletions lib/cron.js
Expand Up @@ -26,10 +26,10 @@ function CronTime(source, zone) {
}; };


CronTime.map = ['second', 'minute', 'hour', 'dayOfMonth', 'month', 'dayOfWeek']; CronTime.map = ['second', 'minute', 'hour', 'dayOfMonth', 'month', 'dayOfWeek'];
CronTime.constraints = [ [0, 59], [0, 59], [0, 23], [1, 31], [0, 11], [1, 7] ]; CronTime.constraints = [ [0, 59], [0, 59], [0, 23], [1, 31], [0, 11], [0, 6] ];
CronTime.aliases = { CronTime.aliases = {
jan:0, feb:1, mar:2, apr:3, may:4, jun:5, jul:6, aug:7, sep:8, oct:9, nov:10, dec:11, jan:0, feb:1, mar:2, apr:3, may:4, jun:5, jul:6, aug:7, sep:8, oct:9, nov:10, dec:11,
sun:1, mon:2, tue:3, wed:4, thu:5, fri:6, sat:7 sun:0, mon:1, tue:2, wed:3, thu:4, fri:5, sat:6
}; };




Expand Down Expand Up @@ -107,7 +107,7 @@ CronTime.prototype = {
continue; continue;
} }


if (!(date.getDay()+1 in this.dayOfWeek)) { if (!(date.getDay() in this.dayOfWeek)) {
date.setDate(date.getDate()+1); date.setDate(date.getDate()+1);
date.setHours(0); date.setHours(0);
date.setMinutes(0); date.setMinutes(0);
Expand Down

0 comments on commit e3204de

Please sign in to comment.