Comparing version 1.2.1 to 1.3.0
@@ -15,3 +15,3 @@ (function (root, factory) { | ||
function CronTime(source, zone) { | ||
function CronTime(source, zone, utcOffset) { | ||
this.source = source; | ||
@@ -27,2 +27,4 @@ | ||
if (utcOffset) this.utcOffset = utcOffset; | ||
var that = this; | ||
@@ -117,2 +119,5 @@ timeUnits.map(function(timeUnit){ | ||
if (this.utcOffset) | ||
date = date.utcOffset(this.utcOffset); | ||
if (this.realDate) | ||
@@ -376,3 +381,3 @@ return date; | ||
function CronJob(cronTime, onTick, onComplete, startNow, timeZone, context, runOnInit) { | ||
function CronJob(cronTime, onTick, onComplete, startNow, timeZone, context, runOnInit, utcOffset) { | ||
var _cronTime = cronTime; | ||
@@ -388,2 +393,3 @@ if (typeof cronTime != 'string' && arguments.length == 1) { | ||
_cronTime = cronTime.cronTime; | ||
utcOffset = cronTime.utcOffset; | ||
} | ||
@@ -394,3 +400,3 @@ | ||
this.onComplete = command2function(onComplete); | ||
this.cronTime = new CronTime(_cronTime, timeZone); | ||
this.cronTime = new CronTime(_cronTime, timeZone, utcOffset); | ||
@@ -525,4 +531,4 @@ addCallback.call(this, command2function(onTick)); | ||
exports.job = function(cronTime, onTick, onComplete) { | ||
return new CronJob(cronTime, onTick, onComplete); | ||
exports.job = function(cronTime, onTick, onComplete, startNow, timeZone, context, runOnInit) { | ||
return new CronJob(cronTime, onTick, onComplete, startNow, timeZone, context, runOnInit); | ||
} | ||
@@ -529,0 +535,0 @@ |
{ | ||
"name": "cron", | ||
"description": "Cron jobs for your node", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"author": "Nick Campbell <nicholas.j.campbell@gmail.com> (http://github.com/ncb000gt)", | ||
"bugs" : { | ||
"url" : "http://github.com/ncb000gt/node-cron/issues" | ||
"bugs": { | ||
"url": "http://github.com/kelektiv/node-cron/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "http://github.com/ncb000gt/node-cron.git" | ||
"url": "http://github.com/kelektiv/node-cron.git" | ||
}, | ||
@@ -38,4 +38,5 @@ "main": "lib/cron", | ||
"Gregg Zigler <greggzigler@gmail.com> (https://github.com/greggzigler)", | ||
"Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)" | ||
"Jordan Abderrachid <jabderrachid@gmail.com> (https://github.com/jordanabderrachid)", | ||
"Masakazu Matsushita <matsukaz@gmail.com> (matsukaz)" | ||
] | ||
} |
@@ -12,3 +12,3 @@ node-cron | ||
Additionally, this library goes beyond the basic cron syntax and allows you to supply a Date object. This will be used as the trigger for your callback. Cron syntax is still an acceptable CronTime format. Although the Cron patterns suported here extend on the standard Unix format to support seconds digits, leaving it off will default to 0 and match the Unix behavior. | ||
Additionally, this library goes beyond the basic cron syntax and allows you to supply a Date object. This will be used as the trigger for your callback. Cron syntax is still an acceptable CronTime format. Although the Cron patterns supported here extend on the standard Unix format to support seconds digits, leaving it off will default to 0 and match the Unix behavior. | ||
@@ -140,2 +140,36 @@ If You Are Submitting Bugs/Issues | ||
How to check if a job is running | ||
========== | ||
```javascript | ||
var cron = require('cron'); | ||
var job1 = new cron.CronJob({ | ||
cronTime: '* * * * *', | ||
onTick: function() { | ||
console.log('job 1 ticked'); | ||
}, | ||
start: false, | ||
timeZone: 'America/Los_Angeles' | ||
}); | ||
var job2 = new cron.CronJob({ | ||
cronTime: '* * * * *', | ||
onTick: function() { | ||
console.log('job 2 ticked'); | ||
}, | ||
start: false, | ||
timeZone: 'America/Los_Angeles' | ||
}); | ||
console.log('job1 status', job1.running); // job1 status undefined | ||
console.log('job2 status', job2.running); // job2 status undefined | ||
job1.start(); // job 1 started | ||
console.log('job1 status', job1.running); // job1 status true | ||
console.log('job2 status', job2.running); // job2 status undefined | ||
``` | ||
Install | ||
@@ -160,5 +194,5 @@ ========== | ||
* `start` - [OPTIONAL] - Specifies whether to start the job just before exiting the constructor. By default this is set to false. If left at default you will need to call `job.start()` in order to start the job (assuming `job` is the variable you set the cronjob to). This does not immediately fire your `onTick` function, it just gives you more control over the behavior of your jobs. | ||
* `timeZone` - [OPTIONAL] - Specify the timezone for the execution. This will modify the actual time relative to your timezone. If the timezone is invalid, an error is thrown. | ||
* `timeZone` - [OPTIONAL] - Specify the timezone for the execution. This will modify the actual time relative to your timezone. If the timezone is invalid, an error is thrown. You can check all timezones available at [Moment Timezone Website](http://momentjs.com/timezone/). | ||
* `context` - [OPTIONAL] - The context within which to execute the onTick method. This defaults to the cronjob itself allowing you to call `this.stop()`. However, if you change this you'll have access to the functions and values within your context object. | ||
* `runOnInit` - [OPTIONAL] - This will immediately fire your `onTick` function as soon as the requisit initialization has happened. This option is set to `false` by default for backwards compatability. | ||
* `runOnInit` - [OPTIONAL] - This will immediately fire your `onTick` function as soon as the requisit initialization has happened. This option is set to `false` by default for backwards compatibility. | ||
* `start` - Runs your job. | ||
@@ -165,0 +199,0 @@ * `stop` - Stops your job. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
231
24335
8
525