cron-parser
Advanced tools
Comparing version 0.3.5 to 0.3.6
'use strict'; | ||
var monthCount = 12; | ||
var normalDaySpec = [ | ||
31, // January | ||
28, // February | ||
31, // March | ||
30, // April | ||
31, // May | ||
30, // June | ||
31, // July | ||
31, // August | ||
30, // September | ||
31, // October | ||
30, // November | ||
31 // December | ||
]; | ||
var leapDaySpec = [ | ||
31, // January | ||
29, // February | ||
31, // March | ||
30, // April | ||
31, // May | ||
30, // June | ||
31, // July | ||
31, // August | ||
30, // September | ||
31, // October | ||
30, // November | ||
31 // December | ||
]; | ||
// provide a year-specific day spec | ||
function daySpec(year){ | ||
return ((year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) ? leapDaySpec : normalDaySpec); | ||
} | ||
Date.prototype.addYear = function() { | ||
@@ -44,55 +8,19 @@ this.setFullYear(this.getFullYear() + 1); | ||
Date.prototype.addMonth = function() { | ||
var m = this.getMonth() + 1; | ||
if (m === monthCount) { | ||
m = 0; | ||
this.addYear(); | ||
} | ||
this.setMonth(m); | ||
this.setMonth(this.getMonth() + 1); | ||
}; | ||
Date.prototype.addDay = function() { | ||
var spec = daySpec(this.getFullYear()); | ||
var d = this.getDate() + 1; | ||
if (d > spec[this.getMonth() + 1]) { | ||
d = 1; | ||
this.addMonth(); | ||
} | ||
this.setDate(d); | ||
this.setDate(this.getDate() + 1); | ||
}; | ||
Date.prototype.addHour = function() { | ||
var h = this.getHours() + 1; | ||
if (h === 24) { | ||
h = 0; | ||
this.addDay(); | ||
} | ||
this.setHours(h); | ||
this.setHours(this.getHours() + 1); | ||
}; | ||
Date.prototype.addMinute = function() { | ||
var m = this.getMinutes() + 1; | ||
if (m === 60) { | ||
m = 0; | ||
this.addHour(); | ||
} | ||
this.setMinutes(m); | ||
this.setMinutes(this.getMinutes() + 1); | ||
}; | ||
Date.prototype.addSecond = function() { | ||
var s = this.getSeconds() + 1; | ||
if (s === 60) { | ||
s = 0; | ||
this.addMinute(); | ||
} | ||
this.setSeconds(s); | ||
this.setSeconds(this.getSeconds() + 1); | ||
}; |
{ | ||
"name": "cron-parser", | ||
"version": "0.3.5", | ||
"version": "0.3.6", | ||
"description": "Node.js library for parsing crontab instructions", | ||
@@ -5,0 +5,0 @@ "main": "lib/parser.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
61505
21
938