cron-parser
Advanced tools
Comparing version 2.4.1 to 2.4.2
@@ -5,3 +5,3 @@ { | ||
"description": "Node.js library for parsing crontab instructions", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"keywords": ["cron", "crontab", "parser"], | ||
@@ -8,0 +8,0 @@ "dependencies": {}, |
@@ -23,3 +23,4 @@ 'use strict'; | ||
this._options = options; | ||
this._tz = options.tz; | ||
this._utc = options.utc || false; | ||
this._tz = this._utc ? 'UTC' : options.tz; | ||
this._currentDate = new CronDate(options.currentDate, this._tz); | ||
@@ -31,3 +32,2 @@ this._startDate = options.startDate ? new CronDate(options.startDate, this._tz) : null; | ||
this._hasIterated = false; | ||
this._utc = options.utc || false; | ||
@@ -226,8 +226,6 @@ // Map fields | ||
if (atoms.length > 1) { | ||
if (field !== 'dayOfWeek') { | ||
var pattern = /\D/g; | ||
atoms.sort(function (a, b) { | ||
return parseInt(a.replace(pattern, ''), 10) - parseInt(b.replace(pattern, ''), 10); | ||
}); | ||
} | ||
var pattern = /\D/g; | ||
atoms.sort(function (a, b) { | ||
return parseInt(a.replace(pattern, ''), 10) - parseInt(b.replace(pattern, ''), 10); | ||
}); | ||
@@ -392,6 +390,2 @@ for (var i = 0, c = atoms.length; i < c; i++) { | ||
var method = function(name) { | ||
return !this._utc ? name : ('getUTC' + name.slice(3)); | ||
}.bind(this); | ||
var currentDate = new CronDate(this._currentDate, this._tz); | ||
@@ -426,4 +420,4 @@ var startDate = this._startDate; | ||
var dayOfMonthMatch = matchSchedule(currentDate[method('getDate')](), this._fields.dayOfMonth); | ||
var dayOfWeekMatch = matchSchedule(currentDate[method('getDay')](), this._fields.dayOfWeek); | ||
var dayOfMonthMatch = matchSchedule(currentDate.getDate(), this._fields.dayOfMonth); | ||
var dayOfWeekMatch = matchSchedule(currentDate.getDay(), this._fields.dayOfWeek); | ||
@@ -434,8 +428,8 @@ var isDayOfMonthWildcardMatch = isWildcardRange(this._fields.dayOfMonth, CronExpression.constraints[3]); | ||
var currentHour = currentDate[method('getHours')](); | ||
var currentHour = currentDate.getHours(); | ||
// Validate days in month if explicit value is given | ||
if (!isMonthWildcardMatch) { | ||
var currentYear = currentDate[method('getFullYear')](); | ||
var currentMonth = currentDate[method('getMonth')]() + 1; | ||
var currentYear = currentDate.getFullYear(); | ||
var currentMonth = currentDate.getMonth() + 1; | ||
var previousMonth = currentMonth === 1 ? 11 : currentMonth - 1; | ||
@@ -486,3 +480,3 @@ var daysInPreviousMonth = CronExpression.daysInMonth[previousMonth - 1]; | ||
// Match month | ||
if (!matchSchedule(currentDate[method('getMonth')]() + 1, this._fields.month)) { | ||
if (!matchSchedule(currentDate.getMonth() + 1, this._fields.month)) { | ||
currentDate[dateMathVerb + 'Month'](); | ||
@@ -511,3 +505,3 @@ continue; | ||
// Match minute | ||
if (!matchSchedule(currentDate[method('getMinutes')](), this._fields.minute)) { | ||
if (!matchSchedule(currentDate.getMinutes(), this._fields.minute)) { | ||
this._applyTimezoneShift(currentDate, dateMathVerb + 'Minute'); | ||
@@ -518,3 +512,3 @@ continue; | ||
// Match second | ||
if (!matchSchedule(currentDate[method('getSeconds')](), this._fields.second)) { | ||
if (!matchSchedule(currentDate.getSeconds(), this._fields.second)) { | ||
this._applyTimezoneShift(currentDate, dateMathVerb + 'Second'); | ||
@@ -521,0 +515,0 @@ continue; |
{ | ||
"name": "cron-parser", | ||
"version": "2.4.1", | ||
"version": "2.4.2", | ||
"description": "Node.js library for parsing crontab instructions", | ||
@@ -14,3 +14,3 @@ "main": "lib/parser.js", | ||
"type": "git", | ||
"url": "git+ssh://git@github.com:harrisiirak/cron-parser.git" | ||
"url": "https://github.com/harrisiirak/cron-parser.git" | ||
}, | ||
@@ -17,0 +17,0 @@ "keywords": [ |
@@ -129,2 +129,2 @@ cron-parser | ||
* *utc* - Enable UTC | ||
* *tz* - Timezone string | ||
* *tz* - Timezone string. It won't be used in case `utc` is enabled |
Sorry, the diff of this file is not supported yet
124219
15
888