Permalink
Browse files

Update dayOfWeek format to match crontab: Sunday 0-6 instead of 1-7.

  • Loading branch information...
1 parent 36eb441 commit e3204ded3e56f7dac72772ce261db084e336a14b @danhbear danhbear committed Jul 24, 2012
Showing with 6 additions and 6 deletions.
  1. +3 −3 README.md
  2. +3 −3 lib/cron.js
View
@@ -25,13 +25,13 @@ Available Cron patterns:
Ranges. E.g. 1-3,5
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
==========
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)
// at 11:30:00 AM. It does not run on Saturday
// or Sunday.
@@ -60,7 +60,7 @@ For good measure
var cronJob = require('cron').CronJob;
var job = new cronJob({
- cronTime: '00 30 11 * * 2-6',
+ cronTime: '00 30 11 * * 1-5',
onTick: function() {
// Runs every weekday (Monday through Friday)
// at 11:30:00 AM. It does not run on Saturday
View
@@ -26,10 +26,10 @@ function CronTime(source, zone) {
};
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 = {
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
};
@@ -107,7 +107,7 @@ CronTime.prototype = {
continue;
}
- if (!(date.getDay()+1 in this.dayOfWeek)) {
+ if (!(date.getDay() in this.dayOfWeek)) {
date.setDate(date.getDate()+1);
date.setHours(0);
date.setMinutes(0);

0 comments on commit e3204de

Please sign in to comment.