node-schedule 1.3.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -165,13 +165,13 @@ var j = schedule.scheduleJob(rule, function(){
165
165
 
166
166
  #### RecurrenceRule properties
167
167
 
168
- - `second`
169
- - `minute`
170
- - `hour`
171
- - `date`
172
- - `month`
168
+ - `second (0-59)`
169
+ - `minute (0-59)`
170
+ - `hour (0-23)`
171
+ - `date (1-31)`
172
+ - `month (0-11)`
173
173
  - `year`
174
- - `dayOfWeek`
174
+ - `dayOfWeek (0-6) Starting with Sunday`
175
175
 
176
176
  > **Note**: It's worth noting that the default value of a component of a recurrence rule is
177
177
  > `null` (except for second, which is 0 for familiarity with cron). *If we did not
@@ -204,11 +204,11 @@ var j = schedule.scheduleJob({ start: startTime, end: endTime, rule: '*/1 * * *
204
204
 
205
205
  ### Handle Jobs and Job Invocations
206
206
 
207
- There are some function to get informations for a Job and to handle the Job and
207
+ There are some function to get information for a Job and to handle the Job and
208
208
  Invocations.
209
209
 
210
210
 
211
- #### job.cancel(reshedule)
211
+ #### job.cancel(reschedule)
212
212
  You can invalidate any job with the `cancel()` method:
213
213
 
214
214
  ```js
@@ -217,7 +217,7 @@ j.cancel();
217
217
  All planned invocations will be canceled. When you set the parameter ***reschedule***
218
218
  to true then the Job is newly scheduled afterwards.
219
219
 
220
- #### job.cancelNext(reshedule)
220
+ #### job.cancelNext(reschedule)
221
221
  This method invalidates the next planned invocation or the job.
222
222
  When you set the parameter ***reschedule*** to true then the Job is newly scheduled
223
223
  afterwards.
package/lib/schedule.js CHANGED
@@ -188,10 +188,14 @@ Job.prototype.schedule = function(spec) {
188
188
  var end;
189
189
  var tz;
190
190
 
191
+ // save passed-in value before 'spec' is replaced
192
+ if (typeof spec === 'object' && 'tz' in spec) {
193
+ tz = spec.tz;
194
+ }
195
+
191
196
  if (typeof spec === 'object' && spec.rule) {
192
197
  start = spec.start || undefined;
193
198
  end = spec.end || undefined;
194
- tz = spec.tz;
195
199
  spec = spec.rule;
196
200
 
197
201
  if (start) {
@@ -398,6 +402,11 @@ RecurrenceRule.prototype.isValid = function() {
398
402
  };
399
403
 
400
404
  RecurrenceRule.prototype.nextInvocationDate = function(base) {
405
+ var next = this._nextInvocationDate(base);
406
+ return next ? next.toDate() : null;
407
+ };
408
+
409
+ RecurrenceRule.prototype._nextInvocationDate = function(base) {
401
410
  base = ((base instanceof CronDate) || (base instanceof Date)) ? base : (new Date());
402
411
  if (!this.recurs) {
403
412
  return null;
@@ -464,7 +473,7 @@ RecurrenceRule.prototype.nextInvocationDate = function(base) {
464
473
  break;
465
474
  }
466
475
 
467
- return next ? next.toDate() : null;
476
+ return next;
468
477
  };
469
478
 
470
479
  function recurMatch(val, matcher) {
@@ -493,7 +502,7 @@ function recurMatch(val, matcher) {
493
502
  function runOnDate(date, job) {
494
503
  var now = Date.now();
495
504
  var then = date.getTime();
496
-
505
+
497
506
  return lt.setTimeout(function() {
498
507
  if (then > Date.now())
499
508
  runOnDate(date, job);
@@ -574,7 +583,7 @@ function scheduleNextRecurrence(rule, job, prevDate, endDate) {
574
583
 
575
584
  prevDate = (prevDate instanceof CronDate) ? prevDate : new CronDate();
576
585
 
577
- var date = (rule instanceof RecurrenceRule) ? rule.nextInvocationDate(prevDate) : rule.next();
586
+ var date = (rule instanceof RecurrenceRule) ? rule._nextInvocationDate(prevDate) : rule.next();
578
587
  if (date === null) {
579
588
  return null;
580
589
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-schedule",
3
- "version": "1.3.0",
3
+ "version": "1.3.1",
4
4
  "description": "A cron-like and not-cron-like job scheduler for Node.",
5
5
  "keywords": [
6
6
  "schedule",
@@ -24,7 +24,7 @@
24
24
  "url": "https://github.com/node-schedule/node-schedule.git"
25
25
  },
26
26
  "dependencies": {
27
- "cron-parser": "^2.4.0",
27
+ "cron-parser": "^2.7.3",
28
28
  "long-timeout": "0.1.1",
29
29
  "sorted-array-functions": "^1.0.0"
30
30
  },