Skip to content

Commit

Permalink
Removed useless semicolon, cleaned up trailing whitespace and fixed a…
Browse files Browse the repository at this point in the history
… tiny readme issue.
  • Loading branch information
Ron Korving committed Aug 1, 2013
1 parent 99a8a6c commit e94588c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 32 deletions.
12 changes: 6 additions & 6 deletions README.md
@@ -1,7 +1,7 @@
node-cron
=========

[![Build Status](https://secure.travis-ci.org/ncb000gt/node-cron.png)](http://travis-ci.org/#!/ncb000gt/node-cron)
[![Build Status](https://secure.travis-ci.org/ncb000gt/node-cron.png)](http://travis-ci.org/#!/ncb000gt/node-cron)

Originally this project was a NodeJS fork of [James Padolsey's][jamespadolsey] [cron.js](http://github.com/padolsey/cron.js).

Expand Down Expand Up @@ -37,15 +37,15 @@ Usage (basic cron usage):
new cronJob('* * * * * *', function(){
console.log('You will see this message every second');
}, null, true, "America/Los_Angeles");


Available Cron patterns:
==========

Asterisk. E.g. *
Ranges. E.g. 1-3,5
Steps. E.g. */2

[Read up on cron patterns here](http://crontab.org).

Another cron example
Expand All @@ -58,7 +58,7 @@ Another cron example
// or Sunday.
}, function () {
// This function is executed when the job stops
},
},
true /* Start the job right now */,
timeZone /* Time zone of this job. */
);
Expand All @@ -71,7 +71,7 @@ Another example with Date
//runs once at the specified date.
}, function () {
// This function is executed when the job stops
},
},
true /* Start the job right now */,
timeZone /* Time zone of this job. */
);
Expand Down Expand Up @@ -113,7 +113,7 @@ Install

If you want to specify timezones, you'll need to install the [time](https://github.com/TooTallNate/node-time) module or place an entry for it in your package.json file.

`npm install time`
npm install time


API
Expand Down
52 changes: 26 additions & 26 deletions lib/cron.js
Expand Up @@ -23,7 +23,7 @@ function CronTime(source, zone) {
} else {
this._parse();
}
};
}

CronTime.map = ['second', 'minute', 'hour', 'dayOfMonth', 'month', 'dayOfWeek'];
CronTime.constraints = [ [0, 59], [0, 59], [0, 23], [1, 31], [0, 11], [0, 6] ];
Expand All @@ -42,10 +42,10 @@ CronTime.prototype = {
var date = (this.source instanceof CronDate) ? this.source : new CronDate();
if (this.zone && date.setTimezone)
date.setTimezone(this.zone);

//add 1 second so next time isn't now (can cause timeout to be 0)
if (!(this.realDate)) date.setSeconds(date.getSeconds() + 1);

if (this.realDate) {
return date;
}
Expand All @@ -59,7 +59,7 @@ CronTime.prototype = {
return Math.max(-1, this.sendAt().getTime() - CronDate.now());
},

/**
/**
* writes out a cron string
*/
toString: function() {
Expand All @@ -71,11 +71,11 @@ CronTime.prototype = {
*/
toJSON: function() {
return [
this._wcOrAll('second'),
this._wcOrAll('minute'),
this._wcOrAll('hour'),
this._wcOrAll('dayOfMonth'),
this._wcOrAll('month'),
this._wcOrAll('second'),
this._wcOrAll('minute'),
this._wcOrAll('hour'),
this._wcOrAll('dayOfMonth'),
this._wcOrAll('month'),
this._wcOrAll('dayOfWeek')
];
},
Expand All @@ -91,13 +91,13 @@ CronTime.prototype = {
if (this.realDate && start < new Date())
console.log("WARNING: Date in past. Will never be fired.");
if (this.realDate) return date;

//sanity check
//var i = 1000;
while(1) {
var diff = date - start;


if (!(date.getMonth() in this.month)) {
date.setMonth(date.getMonth()+1);
date.setDate(1);
Expand All @@ -119,27 +119,27 @@ CronTime.prototype = {
date.setMinutes(0);
continue;
}

if (!(date.getHours() in this.hour)) {
date.setHours(date.getHours() == 23 && diff > 24*60*60*1000 ? 0 : date.getHours()+1);
date.setMinutes(0);
continue;
}

if (!(date.getMinutes() in this.minute)) {
date.setMinutes(date.getMinutes() == 59 && diff > 60*60*1000 ? 0 : date.getMinutes()+1);
date.setSeconds(0);
continue;
}

if (!(date.getSeconds() in this.second)) {
date.setSeconds(date.getSeconds() == 59 && diff > 60*1000 ? 0 : date.getSeconds()+1);
continue;
}

break;
}

return date;
},

Expand Down Expand Up @@ -184,11 +184,11 @@ CronTime.prototype = {

throw new Error('Unknown alias: ' + alias);
}),
split = source.replace(/^\s\s*|\s\s*$/g, '').split(/\s+/),
split = source.replace(/^\s\s*|\s\s*$/g, '').split(/\s+/),
cur, i = 0, len = CronTime.map.length;

for (; i < CronTime.map.length; i++) {
// If the split source string doesn't contain all digits,
// If the split source string doesn't contain all digits,
// assume defaults for first n missing digits.
// This adds support for 5-digit standard cron syntax
cur = split[i - (len - split.length)] || CronTime.parseDefaults[i];
Expand All @@ -199,8 +199,8 @@ CronTime.prototype = {
/**
* Parse a field from the cron syntax.
*/
_parseField: function(field, type, constraints){
_parseField: function(field, type, constraints){

//var rangePattern = /^(\*)(?:\/(\d+))?$|(\d+)(?:-(\d+))?(?:\/(\d+))?(?:,|$)/g
var rangePattern = /^(\d+)(?:-(\d+))?(?:\/(\d+))?$/g,
typeObj = this[type],
Expand All @@ -210,8 +210,8 @@ CronTime.prototype = {

// * is a shortcut to [lower-upper] range
field = field.replace(/\*/g, low + '-' + high);
//commas separate information, so split based on those

//commas separate information, so split based on those
var allRanges = field.split(',');

for(var i = 0; i < allRanges.length; i++){
Expand All @@ -223,7 +223,7 @@ CronTime.prototype = {

// Positive integer lower than constraints[1]
upper = upper ? Math.min(high, ~~Math.abs(upper)) : lower;

// Count from the lower barrier to the upper
pointer = lower;

Expand All @@ -236,7 +236,7 @@ CronTime.prototype = {
} else {
throw new Error('Field (' + field + ') cannot be parsed');
}
}
}
}
};

Expand Down Expand Up @@ -280,7 +280,7 @@ CronJob.prototype = {
* Fire all callbacks registered.
*/
_callback: function() {
for (var i = (this._callbacks.length - 1); i >= 0; i--) {
for (var i = (this._callbacks.length - 1); i >= 0; i--) {

//send this so the callback can call this.stop();
this._callbacks[i].call(this.context, this.onComplete);
Expand Down

0 comments on commit e94588c

Please sign in to comment.