@breejs/later
Advanced tools
Comparing version 4.1.0 to 4.2.0
@@ -5,3 +5,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.later = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
"description": "Maintained fork of later. Determine later (or previous) occurrences of recurring schedules", | ||
"version": "4.0.2", | ||
"version": "4.1.0", | ||
"author": "BunKat <bill@levelstory.com>", | ||
@@ -14,5 +14,5 @@ "bugs": { | ||
"BunKat <bill@levelstory.com>", | ||
"Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)" | ||
"Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
"yrambler2001 <yrambler2001@gmail.com> (https://yrambler2001.me/)" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -23,22 +23,22 @@ "@babel/cli": "^7.10.5", | ||
"@babel/preset-env": "^7.11.0", | ||
"@commitlint/cli": "latest", | ||
"@commitlint/config-conventional": "latest", | ||
"@commitlint/cli": "^18.4.3", | ||
"@commitlint/config-conventional": "^18.4.3", | ||
"babelify": "^10.0.0", | ||
"benchmark": "*", | ||
"benchmark": "^2.1.4", | ||
"browserify": "^16.5.2", | ||
"codecov": "latest", | ||
"cross-env": "latest", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^7.7.0", | ||
"eslint-config-xo-lass": "latest", | ||
"eslint-config-xo-lass": "^2.0.1", | ||
"eslint-plugin-compat": "^3.8.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"fixpack": "latest", | ||
"husky": "latest", | ||
"lint-staged": "latest", | ||
"mocha": "*", | ||
"nyc": "latest", | ||
"remark-cli": "latest", | ||
"remark-preset-github": "latest", | ||
"fixpack": "^4.0.0", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^15.1.0", | ||
"mocha": "^10.2.0", | ||
"nyc": "^15.1.0", | ||
"remark-cli": "11", | ||
"remark-preset-github": "^4.0.4", | ||
"rimraf": "^5.0.5", | ||
"semver": "^7.3.2", | ||
"should": ">=13.2.3", | ||
"should": "^13.2.3", | ||
"sinon": "^11.1.2", | ||
@@ -162,4 +162,4 @@ "tinyify": "^3.0.0", | ||
"build:lib": "babel --config-file ./.lib.babelrc src --out-dir lib", | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||
"lint": "yarn run lint:js && yarn run lint:md && yarn run lint:lib && yarn run lint:dist", | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov", | ||
"lint": "npm run lint:js && npm run lint:md && npm run lint:lib && npm run lint:dist", | ||
"lint:dist": "eslint --no-inline-config -c .dist.eslintrc dist", | ||
@@ -171,5 +171,5 @@ "lint:js": "xo", | ||
"nyc": "cross-env NODE_ENV=test nyc mocha test/**/*-test.js --reporter dot", | ||
"pretest": "yarn run build && yarn run lint", | ||
"test": "cross-env NODE_ENV=test mocha test/**/*-test.js --reporter dot", | ||
"test-coverage": "cross-env NODE_ENV=test nyc yarn run test" | ||
"pretest": "npm run build && npm run lint", | ||
"test": "cross-env NODE_ENV=test mocha test/**/*-test.js --reporter dot --exit", | ||
"test-coverage": "cross-env NODE_ENV=test nyc npm run test" | ||
}, | ||
@@ -228,3 +228,2 @@ "unpkg": "dist/later.min.js", | ||
var pkg = require('../package.json'); | ||
var later = { | ||
@@ -234,3 +233,2 @@ version: pkg.version | ||
later.array = {}; | ||
later.array.sort = function (array, zeroIsLast) { | ||
@@ -240,3 +238,2 @@ array.sort(function (a, b) { | ||
}); | ||
if (zeroIsLast && array[0] === 0) { | ||
@@ -246,3 +243,2 @@ array.push(array.shift()); | ||
}; | ||
later.array.next = function (value, values, extent) { | ||
@@ -252,10 +248,7 @@ var cur; | ||
var nextIdx = 0; | ||
for (var i = values.length - 1; i > -1; --i) { | ||
cur = values[i]; | ||
if (cur === value) { | ||
return cur; | ||
} | ||
if (cur > value || cur === 0 && zeroIsLargest && extent[1] > value) { | ||
@@ -265,9 +258,6 @@ nextIdx = i; | ||
} | ||
break; | ||
} | ||
return values[nextIdx]; | ||
}; | ||
later.array.nextInvalid = function (value, values, extent) { | ||
@@ -281,16 +271,11 @@ var min = extent[0]; | ||
var start = next; | ||
while (next === (values[i] || zeroValue)) { | ||
next++; | ||
if (next > max) { | ||
next = min; | ||
} | ||
i++; | ||
if (i === length) { | ||
i = 0; | ||
} | ||
if (next === start) { | ||
@@ -300,6 +285,4 @@ return undefined; | ||
} | ||
return next; | ||
}; | ||
later.array.prev = function (value, values, extent) { | ||
@@ -310,10 +293,7 @@ var cur; | ||
var previousIdx = length - 1; | ||
for (var i = 0; i < length; i++) { | ||
cur = values[i]; | ||
if (cur === value) { | ||
return cur; | ||
} | ||
if (cur < value || cur === 0 && zeroIsLargest && extent[1] < value) { | ||
@@ -323,9 +303,6 @@ previousIdx = i; | ||
} | ||
break; | ||
} | ||
return values[previousIdx]; | ||
}; | ||
later.array.prevInvalid = function (value, values, extent) { | ||
@@ -339,16 +316,11 @@ var min = extent[0]; | ||
var start = next; | ||
while (next === (values[i] || zeroValue)) { | ||
next--; | ||
if (next < min) { | ||
next = max; | ||
} | ||
i--; | ||
if (i === -1) { | ||
i = length - 1; | ||
} | ||
if (next === start) { | ||
@@ -358,6 +330,4 @@ return undefined; | ||
} | ||
return next; | ||
}; | ||
later.day = later.D = { | ||
@@ -376,7 +346,5 @@ name: 'day', | ||
var max = later.DAYS_IN_MONTH[month - 1]; | ||
if (month === 2 && later.dy.extent(d)[1] === 366) { | ||
max += 1; | ||
} | ||
return d.DExtent = [1, max]; | ||
@@ -427,3 +395,2 @@ }, | ||
var next = later.date.next(later.Y.val(month), later.M.val(month), value === 0 ? later.D.extent(month)[1] - 6 : 1 + 7 * (value - 1)); | ||
if (next.getTime() <= d.getTime()) { | ||
@@ -433,3 +400,2 @@ month = later.M.next(d, later.M.val(d) + 1); | ||
} | ||
return next; | ||
@@ -525,7 +491,5 @@ }, | ||
var next = later.date.next(later.Y.val(d), later.M.val(d), later.D.val(d) + (value <= later.h.val(d) ? 1 : 0), value); | ||
if (!later.date.isUTC && next.getTime() <= d.getTime()) { | ||
next = later.date.next(later.Y.val(next), later.M.val(next), later.D.val(next), value + 1); | ||
} | ||
return next; | ||
@@ -561,7 +525,5 @@ }, | ||
var next = new Date(d.getTime() + inc * later.MIN - s * later.SEC); | ||
if (!later.date.isUTC && next.getTime() <= d.getTime()) { | ||
next = new Date(d.getTime() + (inc + 120) * later.MIN - s * later.SEC); | ||
} | ||
return next; | ||
@@ -623,7 +585,5 @@ }, | ||
var next = new Date(d.getTime() + inc * later.SEC); | ||
if (!later.date.isUTC && next.getTime() <= d.getTime()) { | ||
next = new Date(d.getTime() + (inc + 7200) * later.SEC); | ||
} | ||
return next; | ||
@@ -657,7 +617,5 @@ }, | ||
var next = later.date.next(later.Y.val(d), later.M.val(d), later.D.val(d) + (value <= later.t.val(d) ? 1 : 0), 0, 0, value); | ||
if (!later.date.isUTC && next.getTime() < d.getTime()) { | ||
next = later.date.next(later.Y.val(next), later.M.val(next), later.D.val(next), later.h.val(next), later.m.val(next), value + 7200); | ||
} | ||
return next; | ||
@@ -731,7 +689,5 @@ }, | ||
var year = later.date.nextRollover(wyThur, value, later.wy, later.Y); | ||
if (later.wy.val(year) !== 1) { | ||
year = later.dw.next(year, 2); | ||
} | ||
var wyMax = later.wy.extent(year)[1]; | ||
@@ -745,7 +701,5 @@ var wyStart = later.wy.start(year); | ||
var year = later.date.prevRollover(wyThur, value, later.wy, later.Y); | ||
if (later.wy.val(year) !== 1) { | ||
year = later.dw.next(year, 2); | ||
} | ||
var wyMax = later.wy.extent(year)[1]; | ||
@@ -808,3 +762,2 @@ var wyEnd = later.wy.end(year); | ||
later.modifier = {}; | ||
later.modifier.after = later.modifier.a = function (constraint, values) { | ||
@@ -832,3 +785,2 @@ var value = values[0]; | ||
}; | ||
later.modifier.before = later.modifier.b = function (constraint, values) { | ||
@@ -856,3 +808,2 @@ var value = values[values.length - 1]; | ||
}; | ||
later.compile = function (schedDef) { | ||
@@ -862,3 +813,2 @@ var constraints = []; | ||
var tickConstraint; | ||
for (var key in schedDef) { | ||
@@ -876,3 +826,2 @@ var nameParts = key.split('_'); | ||
} | ||
constraints.sort(function (a, b) { | ||
@@ -884,11 +833,11 @@ var ra = a.constraint.range; | ||
tickConstraint = constraints[constraintsLength - 1].constraint; | ||
function compareFn(dir) { | ||
return dir === 'next' ? function (a, b) { | ||
if (!a || !b) return true; | ||
return a.getTime() > b.getTime(); | ||
} : function (a, b) { | ||
if (!a || !b) return true; | ||
return b.getTime() > a.getTime(); | ||
}; | ||
} | ||
return { | ||
@@ -900,15 +849,9 @@ start: function start(dir, startDate) { | ||
var done; | ||
while (maxAttempts-- && !done && next) { | ||
done = true; | ||
for (var i = 0; i < constraintsLength; i++) { | ||
var _constraint = constraints[i].constraint; | ||
var curValue = _constraint.val(next); | ||
var extent = _constraint.extent(next); | ||
var newValue = nextValue(curValue, constraints[i].vals, extent); | ||
if (!_constraint.isValid(next, newValue)) { | ||
@@ -921,7 +864,5 @@ next = _constraint[dir](next, newValue); | ||
} | ||
if (next !== later.NEVER) { | ||
next = dir === 'next' ? tickConstraint.start(next) : tickConstraint.end(next); | ||
} | ||
return next; | ||
@@ -933,16 +874,10 @@ }, | ||
var compare = compareFn(dir); | ||
for (var i = constraintsLength - 1; i >= 0; i--) { | ||
var _constraint2 = constraints[i].constraint; | ||
var curValue = _constraint2.val(startDate); | ||
var extent = _constraint2.extent(startDate); | ||
var newValue = nextValue(curValue, constraints[i].vals, extent); | ||
var next; | ||
if (newValue !== undefined) { | ||
next = _constraint2[dir](startDate, newValue); | ||
if (next && (!result || compare(result, next))) { | ||
@@ -953,3 +888,2 @@ result = next; | ||
} | ||
return result; | ||
@@ -965,3 +899,2 @@ }, | ||
}; | ||
later.schedule = function (sched) { | ||
@@ -974,11 +907,8 @@ if (!sched) throw new Error('Missing schedule definition.'); | ||
var exceptionsLength = sched.exceptions ? sched.exceptions.length : 0; | ||
for (var i = 0; i < schedulesLength; i++) { | ||
schedules.push(later.compile(sched.schedules[i])); | ||
} | ||
for (var j = 0; j < exceptionsLength; j++) { | ||
exceptions.push(later.compile(sched.exceptions[j])); | ||
} | ||
function getInstances(dir, count, startDate, endDate, isRange) { | ||
@@ -1001,3 +931,2 @@ var compare = compareFn(dir); | ||
setRangeStarts(dir, exceptions, exceptStarts, startDate); | ||
while (maxAttempts-- && loopCount && (next = findNext(schedStarts, compare))) { | ||
@@ -1007,6 +936,4 @@ if (endDate && compare(next, endDate)) { | ||
} | ||
if (exceptionsLength) { | ||
updateRangeStarts(dir, exceptions, exceptStarts, next); | ||
if (end = calcRangeOverlap(dir, exceptStarts, next)) { | ||
@@ -1017,3 +944,2 @@ updateNextStarts(dir, schedules, schedStarts, end); | ||
} | ||
if (isRange) { | ||
@@ -1023,3 +949,2 @@ var maxEndDate = calcMaxEndDate(exceptStarts, compare); | ||
var r = isForward ? [new Date(Math.max(startDate, next)), end ? new Date(endDate ? Math.min(end, endDate) : end) : undefined] : [end ? new Date(endDate ? Math.max(endDate, end.getTime() + later.SEC) : end.getTime() + later.SEC) : undefined, new Date(Math.min(startDate, next.getTime() + later.SEC))]; | ||
if (lastResult && r[rStart].getTime() === lastResult[rEnd].getTime()) { | ||
@@ -1032,3 +957,2 @@ lastResult[rEnd] = r[rEnd]; | ||
} | ||
if (!end) break; | ||
@@ -1040,6 +964,4 @@ updateNextStarts(dir, schedules, schedStarts, end); | ||
} | ||
loopCount--; | ||
} | ||
for (var _i = 0, length = results.length; _i < length; _i++) { | ||
@@ -1049,6 +971,4 @@ var result = results[_i]; | ||
} | ||
return results.length === 0 ? later.NEVER : count === 1 ? results[0] : results; | ||
} | ||
function cleanDate(d) { | ||
@@ -1058,6 +978,4 @@ if (d instanceof Date && !isNaN(d.valueOf())) { | ||
} | ||
return undefined; | ||
} | ||
function setNextStarts(dir, schedArray, startsArray, startDate) { | ||
@@ -1068,6 +986,4 @@ for (var _i2 = 0, length = schedArray.length; _i2 < length; _i2++) { | ||
} | ||
function updateNextStarts(dir, schedArray, startsArray, startDate) { | ||
var compare = compareFn(dir); | ||
for (var _i3 = 0, length = schedArray.length; _i3 < length; _i3++) { | ||
@@ -1079,9 +995,6 @@ if (startsArray[_i3] && !compare(startsArray[_i3], startDate)) { | ||
} | ||
function setRangeStarts(dir, schedArray, rangesArray, startDate) { | ||
var compare = compareFn(dir); | ||
for (var _i4 = 0, length = schedArray.length; _i4 < length; _i4++) { | ||
var nextStart = schedArray[_i4].start(dir, startDate); | ||
if (!nextStart) { | ||
@@ -1094,10 +1007,7 @@ rangesArray[_i4] = later.NEVER; | ||
} | ||
function updateRangeStarts(dir, schedArray, rangesArray, startDate) { | ||
var compare = compareFn(dir); | ||
for (var _i5 = 0, length = schedArray.length; _i5 < length; _i5++) { | ||
if (rangesArray[_i5] && !compare(rangesArray[_i5][0], startDate)) { | ||
var nextStart = schedArray[_i5].start(dir, startDate); | ||
if (!nextStart) { | ||
@@ -1111,3 +1021,2 @@ rangesArray[_i5] = later.NEVER; | ||
} | ||
function tickStarts(dir, schedArray, startsArray, startDate) { | ||
@@ -1120,14 +1029,10 @@ for (var _i6 = 0, length = schedArray.length; _i6 < length; _i6++) { | ||
} | ||
function getStart(schedArray, startsArray, startDate, minEndDate) { | ||
var result; | ||
for (var _i7 = 0, length = startsArray.length; _i7 < length; _i7++) { | ||
if (startsArray[_i7] && startsArray[_i7].getTime() === startDate.getTime()) { | ||
var start = schedArray[_i7].tickStart(startDate); | ||
if (minEndDate && start < minEndDate) { | ||
return minEndDate; | ||
} | ||
if (!result || start > result) { | ||
@@ -1138,13 +1043,9 @@ result = start; | ||
} | ||
return result; | ||
} | ||
function calcRangeOverlap(dir, rangesArray, startDate) { | ||
var compare = compareFn(dir); | ||
var result; | ||
for (var _i8 = 0, length = rangesArray.length; _i8 < length; _i8++) { | ||
var range = rangesArray[_i8]; | ||
if (range && !compare(range[0], startDate) && (!range[1] || compare(range[1], startDate))) { | ||
@@ -1156,9 +1057,6 @@ if (!result || compare(range[1], result)) { | ||
} | ||
return result; | ||
} | ||
function calcMaxEndDate(exceptsArray, compare) { | ||
var result; | ||
for (var _i9 = 0, length = exceptsArray.length; _i9 < length; _i9++) { | ||
@@ -1169,20 +1067,14 @@ if (exceptsArray[_i9] && (!result || compare(result, exceptsArray[_i9][0]))) { | ||
} | ||
return result; | ||
} | ||
function calcEnd(dir, schedArray, startsArray, startDate, maxEndDate) { | ||
var compare = compareFn(dir); | ||
var result; | ||
for (var _i10 = 0, length = schedArray.length; _i10 < length; _i10++) { | ||
var start = startsArray[_i10]; | ||
if (start && start.getTime() === startDate.getTime()) { | ||
var end = schedArray[_i10].end(dir, start); | ||
if (maxEndDate && (!end || compare(end, maxEndDate))) { | ||
return maxEndDate; | ||
} | ||
if (!result || compare(end, result)) { | ||
@@ -1193,17 +1085,15 @@ result = end; | ||
} | ||
return result; | ||
} | ||
function compareFn(dir) { | ||
return dir === 'next' ? function (a, b) { | ||
return !b || a.getTime() > b.getTime(); | ||
if (!a || !b) return true; | ||
return a.getTime() > b.getTime(); | ||
} : function (a, b) { | ||
return !a || b.getTime() > a.getTime(); | ||
if (!a || !b) return true; | ||
return b.getTime() > a.getTime(); | ||
}; | ||
} | ||
function findNext(array, compare) { | ||
var next = array[0]; | ||
for (var _i11 = 1, length = array.length; _i11 < length; _i11++) { | ||
@@ -1214,6 +1104,4 @@ if (array[_i11] && compare(next, array[_i11])) { | ||
} | ||
return next; | ||
} | ||
return { | ||
@@ -1237,15 +1125,11 @@ isValid: function isValid(d) { | ||
}; | ||
later.setTimeout = function (fn, sched, timezone) { | ||
var s = later.schedule(sched); | ||
var t; | ||
if (fn) { | ||
scheduleTimeout(); | ||
} | ||
function scheduleTimeout() { | ||
var date = new Date(); | ||
var now = date.getTime(); | ||
var next = function () { | ||
@@ -1255,17 +1139,15 @@ if (!timezone || ['local', 'system'].includes(timezone)) { | ||
} | ||
var localOffsetMillis = date.getTimezoneOffset() * 6e4; | ||
var offsetMillis = getOffset(date, timezone); | ||
var localOffsetMillis = date.getTimezoneOffset() * 6e4; | ||
var offsetMillis = getOffset(date, timezone); // Specified timezone has the same offset as local timezone. | ||
// Specified timezone has the same offset as local timezone. | ||
// ie. America/New_York = America/Nassau = GMT-4 | ||
if (offsetMillis === localOffsetMillis) { | ||
return s.next(2, now); | ||
} // Offsets differ, adjust current time to match what | ||
} | ||
// Offsets differ, adjust current time to match what | ||
// it should've been for the specified timezone. | ||
var adjustedNow = new Date(now + localOffsetMillis - offsetMillis); | ||
return (s.next(2, adjustedNow) || | ||
/* istanbul ignore next */ | ||
[]).map(function (sched) { | ||
return (s.next(2, adjustedNow) || /* istanbul ignore next */[]).map(function (sched) { | ||
// adjust scheduled times to match their intended timezone | ||
@@ -1277,3 +1159,2 @@ // ie. scheduled = 2021-08-22T11:30:00.000-04:00 => America/New_York | ||
}(); | ||
if (!next[0]) { | ||
@@ -1283,13 +1164,9 @@ t = undefined; | ||
} | ||
var diff = next[0].getTime() - now; | ||
if (diff < 1e3) { | ||
diff = next[1] ? next[1].getTime() - now : 1e3; | ||
} | ||
t = diff < 2147483647 ? setTimeout(fn, diff) : setTimeout(scheduleTimeout, 2147483647); | ||
} // scheduleTimeout() | ||
return { | ||
@@ -1305,3 +1182,2 @@ isDone: function isDone() { | ||
later.setInterval = function (fn, sched, timezone) { | ||
@@ -1311,6 +1187,4 @@ if (!fn) { | ||
} | ||
var t = later.setTimeout(scheduleTimeout, sched, timezone); | ||
var done = t.isDone(); | ||
function scheduleTimeout() { | ||
@@ -1323,3 +1197,2 @@ /* istanbul ignore else */ | ||
} | ||
return { | ||
@@ -1336,5 +1209,3 @@ isDone: function isDone() { | ||
later.date = {}; | ||
later.date.timezone = function (useLocalTime) { | ||
@@ -1357,11 +1228,8 @@ later.date.build = useLocalTime ? function (Y, M, D, h, m, s) { | ||
}; | ||
later.date.UTC = function () { | ||
later.date.timezone(false); | ||
}; | ||
later.date.localTime = function () { | ||
later.date.timezone(true); | ||
}; | ||
later.date.UTC(); | ||
@@ -1375,7 +1243,5 @@ later.SEC = 1e3; | ||
later.NEVER = 0; | ||
later.date.next = function (Y, M, D, h, m, s) { | ||
return later.date.build(Y, M !== undefined ? M - 1 : 0, D !== undefined ? D : 1, h || 0, m || 0, s || 0); | ||
}; | ||
later.date.nextRollover = function (d, value, constraint, period) { | ||
@@ -1386,3 +1252,2 @@ var cur = constraint.val(d); | ||
}; | ||
later.date.prev = function (Y, M, D, h, m, s) { | ||
@@ -1397,3 +1262,2 @@ var length = arguments.length; | ||
}; | ||
later.date.prevRollover = function (d, value, constraint, period) { | ||
@@ -1403,5 +1267,3 @@ var cur = constraint.val(d); | ||
}; | ||
later.parse = {}; | ||
later.parse.cron = function (expr, hasSeconds) { | ||
@@ -1447,11 +1309,8 @@ var NAMES = { | ||
}; | ||
function getValue(value, offset, max) { | ||
return isNaN(value) ? NAMES[value] || null : Math.min(Number(value) + (offset || 0), max || 9999); | ||
} | ||
function cloneSchedule(sched) { | ||
var clone = {}; | ||
var field; | ||
for (field in sched) { | ||
@@ -1462,13 +1321,9 @@ if (field !== 'dc' && field !== 'd') { | ||
} | ||
return clone; | ||
} | ||
function add(sched, name, min, max, inc) { | ||
var i = min; | ||
if (!sched[name]) { | ||
sched[name] = []; | ||
} | ||
while (i <= max) { | ||
@@ -1478,6 +1333,4 @@ if (!sched[name].includes(i)) { | ||
} | ||
i += inc || 1; | ||
} | ||
sched[name].sort(function (a, b) { | ||
@@ -1487,3 +1340,2 @@ return a - b; | ||
} | ||
function addHash(schedules, curSched, value, hash) { | ||
@@ -1494,11 +1346,8 @@ if (curSched.d && !curSched.dc || curSched.dc && !curSched.dc.includes(hash)) { | ||
} | ||
add(curSched, 'd', value, value); | ||
add(curSched, 'dc', hash, hash); | ||
} | ||
function addWeekday(s, curSched, value) { | ||
var except1 = {}; | ||
var except2 = {}; | ||
if (value === 1) { | ||
@@ -1519,7 +1368,5 @@ add(curSched, 'D', 1, 3); | ||
} | ||
s.exceptions.push(except1); | ||
s.exceptions.push(except2); | ||
} | ||
function addRange(item, curSched, name, min, max, offset) { | ||
@@ -1529,3 +1376,2 @@ var incSplit = item.split('/'); | ||
var range = incSplit[0]; | ||
if (range !== '*' && range !== '0') { | ||
@@ -1536,6 +1382,4 @@ var rangeSplit = range.split('-'); | ||
} | ||
add(curSched, name, min, max, inc); | ||
} | ||
function parse(item, s, name, min, max, offset) { | ||
@@ -1546,7 +1390,5 @@ var value; | ||
var curSched = schedules[schedules.length - 1]; | ||
if (item === 'L') { | ||
item = min - 1; | ||
} | ||
if ((value = getValue(item, offset, max)) !== null) { | ||
@@ -1565,11 +1407,8 @@ add(curSched, name, value, value); | ||
} | ||
function isHash(item) { | ||
return item.includes('#') || item.indexOf('L') > 0; | ||
} | ||
function itemSorter(a, b) { | ||
return isHash(a) && !isHash(b) ? 1 : a - b; | ||
} | ||
function parseExpr(expr) { | ||
@@ -1585,7 +1424,5 @@ var schedule = { | ||
var items; | ||
for (field in FIELDS) { | ||
f = FIELDS[field]; | ||
component = components[f[0]]; | ||
if (component && component !== '*' && component !== '?') { | ||
@@ -1595,4 +1432,3 @@ items = component.split(',').sort(itemSorter); | ||
var _items = items, | ||
length = _items.length; | ||
length = _items.length; | ||
for (i = 0; i < length; i++) { | ||
@@ -1603,6 +1439,4 @@ parse(items[i], schedule, field, f[1], f[2], f[3]); | ||
} | ||
return schedule; | ||
} | ||
function prepareExpr(expr) { | ||
@@ -1612,7 +1446,5 @@ var prepared = expr.toUpperCase(); | ||
} | ||
var e = prepareExpr(expr); | ||
return parseExpr(hasSeconds ? e : '0 ' + e); | ||
}; | ||
later.parse.recur = function () { | ||
@@ -1625,5 +1457,3 @@ var schedules = []; | ||
var values; | ||
var _every; | ||
var modifier; | ||
@@ -1634,6 +1464,4 @@ var applyMin; | ||
var last; | ||
function add(name, min, max) { | ||
name = modifier ? name + '_' + modifier : name; | ||
if (!cur) { | ||
@@ -1643,16 +1471,11 @@ curArray.push({}); | ||
} | ||
if (!cur[name]) { | ||
cur[name] = []; | ||
} | ||
curName = cur[name]; | ||
if (_every) { | ||
values = []; | ||
for (i = min; i <= max; i += _every) { | ||
values.push(i); | ||
} | ||
last = { | ||
@@ -1665,10 +1488,7 @@ n: name, | ||
} | ||
values = applyMin ? [min] : applyMax ? [max] : values; | ||
var _values = values, | ||
length = _values.length; | ||
length = _values.length; | ||
for (i = 0; i < length; i += 1) { | ||
var value = values[i]; | ||
if (!curName.includes(value)) { | ||
@@ -1678,6 +1498,4 @@ curName.push(value); | ||
} | ||
values = _every = modifier = applyMin = applyMax = 0; | ||
} | ||
return { | ||
@@ -1715,7 +1533,5 @@ schedules: schedules, | ||
var split = values[_i12].split(':'); | ||
if (split.length < 3) split.push(0); | ||
values[_i12] = Number(split[0]) * 3600 + Number(split[1]) * 60 + Number(split[2]); | ||
} | ||
add('t'); | ||
@@ -1780,3 +1596,2 @@ return this; | ||
} | ||
add('fd'); | ||
@@ -1818,3 +1633,2 @@ return this; | ||
}; | ||
later.parse.text = function (string) { | ||
@@ -1891,3 +1705,2 @@ var recur = later.parse.recur; | ||
}; | ||
function t(start, end, text, type) { | ||
@@ -1901,3 +1714,2 @@ return { | ||
} | ||
function peek(expected) { | ||
@@ -1914,3 +1726,2 @@ var scanTokens = Array.isArray(expected) ? expected : [expected]; | ||
start = pos; | ||
while (!token || token.type === whiteSpace) { | ||
@@ -1922,7 +1733,5 @@ length_ = -1; | ||
var length = scanTokens.length; | ||
for (i = 0; i < length; i++) { | ||
scanToken = scanTokens[i]; | ||
m = scanToken.exec(curInput); | ||
if (m && m.index === 0 && m[0].length > length_) { | ||
@@ -1933,3 +1742,2 @@ length_ = m[0].length; | ||
} | ||
if (token.type === whiteSpace) { | ||
@@ -1939,6 +1747,4 @@ start = token.endPos; | ||
} | ||
return token; | ||
} | ||
function scan(expectedToken) { | ||
@@ -1949,3 +1755,2 @@ var token = peek(expectedToken); | ||
} | ||
function parseThroughExpr(tokenType) { | ||
@@ -1955,20 +1760,14 @@ var start = Number(parseTokenValue(tokenType)); | ||
var nums = []; | ||
for (var i = start; i <= end; i++) { | ||
nums.push(i); | ||
} | ||
return nums; | ||
} | ||
function parseRanges(tokenType) { | ||
var nums = parseThroughExpr(tokenType); | ||
while (checkAndParse(TOKENTYPES.and)) { | ||
nums = nums.concat(parseThroughExpr(tokenType)); | ||
} | ||
return nums; | ||
} | ||
function parseEvery(r) { | ||
@@ -1979,3 +1778,2 @@ var number; | ||
var end; | ||
if (checkAndParse(TOKENTYPES.weekend)) { | ||
@@ -1989,3 +1787,2 @@ r.on(NAMES.sun, NAMES.sat).dayOfWeek(); | ||
period = parseTimePeriod(r); | ||
if (checkAndParse(TOKENTYPES.start)) { | ||
@@ -1997,3 +1794,2 @@ number = parseTokenValue(TOKENTYPES.rank); | ||
start = parseTokenValue(TOKENTYPES.rank); | ||
if (checkAndParse(TOKENTYPES.and)) { | ||
@@ -2006,3 +1802,2 @@ end = parseTokenValue(TOKENTYPES.rank); | ||
} | ||
function parseOnThe(r) { | ||
@@ -2016,6 +1811,4 @@ if (checkAndParse(TOKENTYPES.first)) { | ||
} | ||
parseTimePeriod(r); | ||
} | ||
function parseScheduleExpr(string_) { | ||
@@ -2026,6 +1819,4 @@ pos = 0; | ||
var r = recur(); | ||
while (pos < input.length && error < 0) { | ||
var token = parseToken([TOKENTYPES.every, TOKENTYPES.after, TOKENTYPES.before, TOKENTYPES.onthe, TOKENTYPES.on, TOKENTYPES.of, TOKENTYPES.in, TOKENTYPES.at, TOKENTYPES.and, TOKENTYPES.except, TOKENTYPES.also]); | ||
switch (token.type) { | ||
@@ -2035,3 +1826,2 @@ case TOKENTYPES.every: | ||
break; | ||
case TOKENTYPES.after: | ||
@@ -2045,5 +1835,3 @@ if (peek(TOKENTYPES.time).type !== undefined) { | ||
} | ||
break; | ||
case TOKENTYPES.before: | ||
@@ -2057,41 +1845,29 @@ if (peek(TOKENTYPES.time).type !== undefined) { | ||
} | ||
break; | ||
case TOKENTYPES.onthe: | ||
parseOnThe(r); | ||
break; | ||
case TOKENTYPES.on: | ||
r.on(parseRanges(TOKENTYPES.dayName)).dayOfWeek(); | ||
break; | ||
case TOKENTYPES.of: | ||
r.on(parseRanges(TOKENTYPES.monthName)).month(); | ||
break; | ||
case TOKENTYPES.in: | ||
r.on(parseRanges(TOKENTYPES.yearIndex)).year(); | ||
break; | ||
case TOKENTYPES.at: | ||
r.on(parseTokenValue(TOKENTYPES.time)).time(); | ||
while (checkAndParse(TOKENTYPES.and)) { | ||
r.on(parseTokenValue(TOKENTYPES.time)).time(); | ||
} | ||
break; | ||
case TOKENTYPES.and: | ||
break; | ||
case TOKENTYPES.also: | ||
r.and(); | ||
break; | ||
case TOKENTYPES.except: | ||
r.except(); | ||
break; | ||
default: | ||
@@ -2101,3 +1877,2 @@ error = pos; | ||
} | ||
return { | ||
@@ -2109,6 +1884,4 @@ schedules: r.schedules, | ||
} | ||
function parseTimePeriod(r) { | ||
var timePeriod = parseToken([TOKENTYPES.second, TOKENTYPES.minute, TOKENTYPES.hour, TOKENTYPES.dayOfYear, TOKENTYPES.dayOfWeek, TOKENTYPES.dayInstance, TOKENTYPES.day, TOKENTYPES.month, TOKENTYPES.year, TOKENTYPES.weekOfMonth, TOKENTYPES.weekOfYear]); | ||
switch (timePeriod.type) { | ||
@@ -2118,63 +1891,46 @@ case TOKENTYPES.second: | ||
break; | ||
case TOKENTYPES.minute: | ||
r.minute(); | ||
break; | ||
case TOKENTYPES.hour: | ||
r.hour(); | ||
break; | ||
case TOKENTYPES.dayOfYear: | ||
r.dayOfYear(); | ||
break; | ||
case TOKENTYPES.dayOfWeek: | ||
r.dayOfWeek(); | ||
break; | ||
case TOKENTYPES.dayInstance: | ||
r.dayOfWeekCount(); | ||
break; | ||
case TOKENTYPES.day: | ||
r.dayOfMonth(); | ||
break; | ||
case TOKENTYPES.weekOfMonth: | ||
r.weekOfMonth(); | ||
break; | ||
case TOKENTYPES.weekOfYear: | ||
r.weekOfYear(); | ||
break; | ||
case TOKENTYPES.month: | ||
r.month(); | ||
break; | ||
case TOKENTYPES.year: | ||
r.year(); | ||
break; | ||
default: | ||
error = pos; | ||
} | ||
return timePeriod; | ||
} | ||
function checkAndParse(tokenType) { | ||
var found = peek(tokenType).type === tokenType; | ||
if (found) { | ||
scan(tokenType); | ||
} | ||
return found; | ||
} | ||
function parseToken(tokenType) { | ||
var t = scan(tokenType); | ||
if (t.type) { | ||
@@ -2185,13 +1941,9 @@ t.text = convertString(t.text, tokenType); | ||
} | ||
return t; | ||
} | ||
function parseTokenValue(tokenType) { | ||
return parseToken(tokenType).text; | ||
} | ||
function convertString(string_, tokenType) { | ||
var output = string_; | ||
switch (tokenType) { | ||
@@ -2212,3 +1964,2 @@ case TOKENTYPES.time: | ||
var min = parts[2].trim(); | ||
if (parts[3] === 'pm' && hour < 12) { | ||
@@ -2219,11 +1970,8 @@ hour += 12; | ||
} | ||
hour = String(hour); | ||
output = (hour.length === 1 ? '0' : '') + hour + ':' + min; | ||
break; | ||
case TOKENTYPES.rank: | ||
output = Number.parseInt(/^\d+/.exec(string_)[0], 10); | ||
break; | ||
case TOKENTYPES.monthName: | ||
@@ -2234,9 +1982,6 @@ case TOKENTYPES.dayName: | ||
} | ||
return output; | ||
} | ||
return parseScheduleExpr(string.toLowerCase()); | ||
}; | ||
function getOffset(date, zone) { | ||
@@ -2255,3 +2000,2 @@ var d = date.toLocaleString('en-US', { | ||
module.exports = later; | ||
@@ -2258,0 +2002,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).later=e()}}((function(){var e={version:"4.0.2",array:{}};return e.array.sort=function(e,t){e.sort((function(e,t){return Number(e)-Number(t)})),t&&0===e[0]&&e.push(e.shift())},e.array.next=function(e,t,n){for(var r,a=0!==n[0],i=0,u=t.length-1;u>-1;--u){if((r=t[u])===e)return r;if(!(r>e||0===r&&a&&n[1]>e))break;i=u}return t[i]},e.array.nextInvalid=function(e,t,n){for(var r=n[0],a=n[1],i=t.length,u=0===t[i-1]&&0!==r?a:0,o=e,f=t.indexOf(e),d=o;o===(t[f]||u);)if(++o>a&&(o=r),++f===i&&(f=0),o===d)return;return o},e.array.prev=function(e,t,n){for(var r,a=t.length,i=0!==n[0],u=a-1,o=0;o<a;o++){if((r=t[o])===e)return r;if(!(r<e||0===r&&i&&n[1]<e))break;u=o}return t[u]},e.array.prevInvalid=function(e,t,n){for(var r=n[0],a=n[1],i=t.length,u=0===t[i-1]&&0!==r?a:0,o=e,f=t.indexOf(e),d=o;o===(t[f]||u);)if(--o<r&&(o=a),-1==--f&&(f=i-1),o===d)return;return o},e.day=e.D={name:"day",range:86400,val:function(t){return t.D||(t.D=e.date.getDate.call(t))},isValid:function(t,n){return e.D.val(t)===(n||e.D.extent(t)[1])},extent:function(t){if(t.DExtent)return t.DExtent;var n=e.M.val(t),r=e.DAYS_IN_MONTH[n-1];return 2===n&&366===e.dy.extent(t)[1]&&(r+=1),t.DExtent=[1,r]},start:function(t){return t.DStart||(t.DStart=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)))},end:function(t){return t.DEnd||(t.DEnd=e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t)))},next:function(t,n){n=n>e.D.extent(t)[1]?1:n;var r=e.date.nextRollover(t,n,e.D,e.M),a=e.D.extent(r)[1];return n=n>a?1:n||a,e.date.next(e.Y.val(r),e.M.val(r),n)},prev:function(t,n){var r=e.date.prevRollover(t,n,e.D,e.M),a=e.D.extent(r)[1];return e.date.prev(e.Y.val(r),e.M.val(r),n>a?a:n||a)}},e.dayOfWeekCount=e.dc={name:"day of week count",range:604800,val:function(t){return t.dc||(t.dc=Math.floor((e.D.val(t)-1)/7)+1)},isValid:function(t,n){return e.dc.val(t)===n||0===n&&e.D.val(t)>e.D.extent(t)[1]-7},extent:function(t){return t.dcExtent||(t.dcExtent=[1,Math.ceil(e.D.extent(t)[1]/7)])},start:function(t){return t.dcStart||(t.dcStart=e.date.next(e.Y.val(t),e.M.val(t),Math.max(1,7*(e.dc.val(t)-1)+1||1)))},end:function(t){return t.dcEnd||(t.dcEnd=e.date.prev(e.Y.val(t),e.M.val(t),Math.min(7*e.dc.val(t),e.D.extent(t)[1])))},next:function(t,n){n=n>e.dc.extent(t)[1]?1:n;var r=e.date.nextRollover(t,n,e.dc,e.M);n=n>e.dc.extent(r)[1]?1:n;var a=e.date.next(e.Y.val(r),e.M.val(r),0===n?e.D.extent(r)[1]-6:1+7*(n-1));return a.getTime()<=t.getTime()?(r=e.M.next(t,e.M.val(t)+1),e.date.next(e.Y.val(r),e.M.val(r),0===n?e.D.extent(r)[1]-6:1+7*(n-1))):a},prev:function(t,n){var r=e.date.prevRollover(t,n,e.dc,e.M),a=e.dc.extent(r)[1];return n=n>a?a:n||a,e.dc.end(e.date.prev(e.Y.val(r),e.M.val(r),1+7*(n-1)))}},e.dayOfWeek=e.dw=e.d={name:"day of week",range:86400,val:function(t){return t.dw||(t.dw=e.date.getDay.call(t)+1)},isValid:function(t,n){return e.dw.val(t)===(n||7)},extent:function(){return[1,7]},start:function(t){return e.D.start(t)},end:function(t){return e.D.end(t)},next:function(t,n){return n=n>7?1:n||7,e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)+(n-e.dw.val(t))+(n<=e.dw.val(t)?7:0))},prev:function(t,n){return n=n>7?7:n||7,e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t)+(n-e.dw.val(t))+(n>=e.dw.val(t)?-7:0))}},e.dayOfYear=e.dy={name:"day of year",range:86400,val:function(t){return t.dy||(t.dy=Math.ceil(1+(e.D.start(t).getTime()-e.Y.start(t).getTime())/e.DAY))},isValid:function(t,n){return e.dy.val(t)===(n||e.dy.extent(t)[1])},extent:function(t){var n=e.Y.val(t);return t.dyExtent||(t.dyExtent=[1,n%4?365:366])},start:function(t){return e.D.start(t)},end:function(t){return e.D.end(t)},next:function(t,n){n=n>e.dy.extent(t)[1]?1:n;var r=e.date.nextRollover(t,n,e.dy,e.Y),a=e.dy.extent(r)[1];return n=n>a?1:n||a,e.date.next(e.Y.val(r),e.M.val(r),n)},prev:function(t,n){var r=e.date.prevRollover(t,n,e.dy,e.Y),a=e.dy.extent(r)[1];return n=n>a?a:n||a,e.date.prev(e.Y.val(r),e.M.val(r),n)}},e.hour=e.h={name:"hour",range:3600,val:function(t){return t.h||(t.h=e.date.getHour.call(t))},isValid:function(t,n){return e.h.val(t)===n},extent:function(){return[0,23]},start:function(t){return t.hStart||(t.hStart=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t)))},end:function(t){return t.hEnd||(t.hEnd=e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t)))},next:function(t,n){n=n>23?0:n;var r=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)+(n<=e.h.val(t)?1:0),n);return!e.date.isUTC&&r.getTime()<=t.getTime()&&(r=e.date.next(e.Y.val(r),e.M.val(r),e.D.val(r),n+1)),r},prev:function(t,n){return n=n>23?23:n,e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t)+(n>=e.h.val(t)?-1:0),n)}},e.minute=e.m={name:"minute",range:60,val:function(t){return t.m||(t.m=e.date.getMin.call(t))},isValid:function(t,n){return e.m.val(t)===n},extent:function(e){return[0,59]},start:function(t){return t.mStart||(t.mStart=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t),e.m.val(t)))},end:function(t){return t.mEnd||(t.mEnd=e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t),e.m.val(t)))},next:function(t,n){var r=e.m.val(t),a=e.s.val(t),i=n>59?60-r:n<=r?60-r+n:n-r,u=new Date(t.getTime()+i*e.MIN-a*e.SEC);return!e.date.isUTC&&u.getTime()<=t.getTime()&&(u=new Date(t.getTime()+(i+120)*e.MIN-a*e.SEC)),u},prev:function(t,n){return n=n>59?59:n,e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t)+(n>=e.m.val(t)?-1:0),n)}},e.month=e.M={name:"month",range:2629740,val:function(t){return t.M||(t.M=e.date.getMonth.call(t)+1)},isValid:function(t,n){return e.M.val(t)===(n||12)},extent:function(){return[1,12]},start:function(t){return t.MStart||(t.MStart=e.date.next(e.Y.val(t),e.M.val(t)))},end:function(t){return t.MEnd||(t.MEnd=e.date.prev(e.Y.val(t),e.M.val(t)))},next:function(t,n){return n=n>12?1:n||12,e.date.next(e.Y.val(t)+(n>e.M.val(t)?0:1),n)},prev:function(t,n){return n=n>12?12:n||12,e.date.prev(e.Y.val(t)-(n>=e.M.val(t)?1:0),n)}},e.second=e.s={name:"second",range:1,val:function(t){return t.s||(t.s=e.date.getSec.call(t))},isValid:function(t,n){return e.s.val(t)===n},extent:function(){return[0,59]},start:function(e){return e},end:function(e){return e},next:function(t,n){var r=e.s.val(t),a=n>59?60-r:n<=r?60-r+n:n-r,i=new Date(t.getTime()+a*e.SEC);return!e.date.isUTC&&i.getTime()<=t.getTime()&&(i=new Date(t.getTime()+(a+7200)*e.SEC)),i},prev:function(t,n,r){return n=n>59?59:n,e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t),e.m.val(t)+(n>=e.s.val(t)?-1:0),n)}},e.time=e.t={name:"time",range:1,val:function(t){return t.t||(t.t=3600*e.h.val(t)+60*e.m.val(t)+e.s.val(t))},isValid:function(t,n){return e.t.val(t)===n},extent:function(){return[0,86399]},start:function(e){return e},end:function(e){return e},next:function(t,n){n=n>86399?0:n;var r=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)+(n<=e.t.val(t)?1:0),0,0,n);return!e.date.isUTC&&r.getTime()<t.getTime()&&(r=e.date.next(e.Y.val(r),e.M.val(r),e.D.val(r),e.h.val(r),e.m.val(r),n+7200)),r},prev:function(t,n){return n=n>86399?86399:n,e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)+(n>=e.t.val(t)?-1:0),0,0,n)}},e.weekOfMonth=e.wm={name:"week of month",range:604800,val:function(t){return t.wm||(t.wm=(e.D.val(t)+(e.dw.val(e.M.start(t))-1)+(7-e.dw.val(t)))/7)},isValid:function(t,n){return e.wm.val(t)===(n||e.wm.extent(t)[1])},extent:function(t){return t.wmExtent||(t.wmExtent=[1,(e.D.extent(t)[1]+(e.dw.val(e.M.start(t))-1)+(7-e.dw.val(e.M.end(t))))/7])},start:function(t){return t.wmStart||(t.wmStart=e.date.next(e.Y.val(t),e.M.val(t),Math.max(e.D.val(t)-e.dw.val(t)+1,1)))},end:function(t){return t.wmEnd||(t.wmEnd=e.date.prev(e.Y.val(t),e.M.val(t),Math.min(e.D.val(t)+(7-e.dw.val(t)),e.D.extent(t)[1])))},next:function(t,n){n=n>e.wm.extent(t)[1]?1:n;var r=e.date.nextRollover(t,n,e.wm,e.M),a=e.wm.extent(r)[1];return n=n>a?1:n||a,e.date.next(e.Y.val(r),e.M.val(r),Math.max(1,7*(n-1)-(e.dw.val(r)-2)))},prev:function(t,n){var r=e.date.prevRollover(t,n,e.wm,e.M),a=e.wm.extent(r)[1];return n=n>a?a:n||a,e.wm.end(e.date.next(e.Y.val(r),e.M.val(r),Math.max(1,7*(n-1)-(e.dw.val(r)-2))))}},e.weekOfYear=e.wy={name:"week of year (ISO)",range:604800,val:function(t){if(t.wy)return t.wy;var n=e.dw.next(e.wy.start(t),5),r=e.dw.next(e.Y.prev(n,e.Y.val(n)-1),5);return t.wy=1+Math.ceil((n.getTime()-r.getTime())/e.WEEK)},isValid:function(t,n){return e.wy.val(t)===(n||e.wy.extent(t)[1])},extent:function(t){if(t.wyExtent)return t.wyExtent;var n=e.dw.next(e.wy.start(t),5),r=e.dw.val(e.Y.start(n)),a=e.dw.val(e.Y.end(n));return t.wyExtent=[1,5===r||5===a?53:52]},start:function(t){return t.wyStart||(t.wyStart=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)-(e.dw.val(t)>1?e.dw.val(t)-2:6)))},end:function(t){return t.wyEnd||(t.wyEnd=e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t)+(e.dw.val(t)>1?8-e.dw.val(t):0)))},next:function(t,n){n=n>e.wy.extent(t)[1]?1:n;var r=e.dw.next(e.wy.start(t),5),a=e.date.nextRollover(r,n,e.wy,e.Y);1!==e.wy.val(a)&&(a=e.dw.next(a,2));var i=e.wy.extent(a)[1],u=e.wy.start(a);return n=n>i?1:n||i,e.date.next(e.Y.val(u),e.M.val(u),e.D.val(u)+7*(n-1))},prev:function(t,n){var r=e.dw.next(e.wy.start(t),5),a=e.date.prevRollover(r,n,e.wy,e.Y);1!==e.wy.val(a)&&(a=e.dw.next(a,2));var i=e.wy.extent(a)[1],u=e.wy.end(a);return n=n>i?i:n||i,e.wy.end(e.date.next(e.Y.val(u),e.M.val(u),e.D.val(u)+7*(n-1)))}},e.year=e.Y={name:"year",range:31556900,val:function(t){return t.Y||(t.Y=e.date.getYear.call(t))},isValid:function(t,n){return e.Y.val(t)===n},extent:function(){return[1970,2099]},start:function(t){return t.YStart||(t.YStart=e.date.next(e.Y.val(t)))},end:function(t){return t.YEnd||(t.YEnd=e.date.prev(e.Y.val(t)))},next:function(t,n){return n>e.Y.val(t)&&n<=e.Y.extent()[1]?e.date.next(n):e.NEVER},prev:function(t,n){return n<e.Y.val(t)&&n>=e.Y.extent()[0]?e.date.prev(n):e.NEVER}},e.fullDate=e.fd={name:"full date",range:1,val:function(e){return e.fd||(e.fd=e.getTime())},isValid:function(t,n){return e.fd.val(t)===n},extent:function(){return[0,3250368e7]},start:function(e){return e},end:function(e){return e},next:function(t,n){return e.fd.val(t)<n?new Date(n):e.NEVER},prev:function(t,n){return e.fd.val(t)>n?new Date(n):e.NEVER}},e.modifier={},e.modifier.after=e.modifier.a=function(e,t){var n=t[0];return{name:"after "+e.name,range:(e.extent(new Date)[1]-n)*e.range,val:e.val,isValid:function(e,t){return this.val(e)>=n},extent:e.extent,start:e.start,end:e.end,next:function(t,r){return r!=n&&(r=e.extent(t)[0]),e.next(t,r)},prev:function(t,r){return r=r===n?e.extent(t)[1]:n-1,e.prev(t,r)}}},e.modifier.before=e.modifier.b=function(e,t){var n=t[t.length-1];return{name:"before "+e.name,range:e.range*(n-1),val:e.val,isValid:function(e,t){return this.val(e)<n},extent:e.extent,start:e.start,end:e.end,next:function(t,r){return r=r===n?e.extent(t)[0]:n,e.next(t,r)},prev:function(t,r){return r=r===n?n-1:e.extent(t)[1],e.prev(t,r)}}},e.compile=function(t){var n,r=[],a=0;for(var i in t){var u=i.split("_"),o=u[0],f=u[1],d=t[i],l=f?e.modifier[f](e[o],d):e[o];r.push({constraint:l,vals:d}),a++}return r.sort((function(e,t){var n=e.constraint.range,r=t.constraint.range;return r<n?-1:r>n?1:0})),n=r[a-1].constraint,{start:function(t,i){for(var u,o=i,f=e.array[t],d=1e3;d--&&!u&&o;){u=!0;for(var l=0;l<a;l++){var c=r[l].constraint,v=c.val(o),s=c.extent(o),m=f(v,r[l].vals,s);if(!c.isValid(o,m)){o=c[t](o,m),u=!1;break}}}return o!==e.NEVER&&(o="next"===t?n.start(o):n.end(o)),o},end:function(t,n){for(var i,u=e.array[t+"Invalid"],o=function(e){return"next"===e?function(e,t){return e.getTime()>t.getTime()}:function(e,t){return t.getTime()>e.getTime()}}(t),f=a-1;f>=0;f--){var d,l=r[f].constraint,c=l.val(n),v=l.extent(n),s=u(c,r[f].vals,v);void 0!==s&&(!(d=l[t](n,s))||i&&!o(i,d)||(i=d))}return i},tick:function(t,r){return new Date("next"===t?n.end(r).getTime()+e.SEC:n.start(r).getTime()-e.SEC)},tickStart:function(e){return n.start(e)}}},e.schedule=function(t){if(!t)throw new Error("Missing schedule definition.");if(!t.schedules)throw new Error("Definition must include at least one schedule.");for(var n=[],r=t.schedules.length,a=[],i=t.exceptions?t.exceptions.length:0,u=0;u<r;u++)n.push(e.compile(t.schedules[u]));for(var o=0;o<i;o++)a.push(e.compile(t.exceptions[o]));function f(t,r,u,o,f){var g,p,D,M=w(t),b=r,Y=1e3,k=[],E=[],T=[],O="next"===t,N=O?0:1,S=O?1:0;if(!(u=u?new Date(u):new Date)||!u.getTime())throw new Error("Invalid start date.");for(function(e,t,n,r){for(var a=0,i=t.length;a<i;a++)n[a]=t[a].start(e,r)}(t,n,k,u),function(t,n,r,a){w(t);for(var i=0,u=n.length;i<u;i++){var o=n[i].start(t,a);r[i]=o?[o,n[i].end(t,o)]:e.NEVER}}(t,a,E,u);Y--&&b&&(g=y(k,M))&&(!o||!M(g,o));)if(i&&(c(t,a,E,g),p=m(t,E,g)))l(t,n,k,p);else{if(f){var R=h(E,M);p=x(t,n,k,g,R);var C=O?[new Date(Math.max(u,g)),p?new Date(o?Math.min(p,o):p):void 0]:[p?new Date(o?Math.max(o,p.getTime()+e.SEC):p.getTime()+e.SEC):void 0,new Date(Math.min(u,g.getTime()+e.SEC))];if(D&&C[N].getTime()===D[S].getTime()?(D[S]=C[S],b++):(D=C,T.push(D)),!p)break;l(t,n,k,p)}else T.push(O?new Date(Math.max(u,g)):s(n,k,g,o)),v(t,n,k,g);b--}for(var V=0,I=T.length;V<I;V++){var U=T[V];T[V]="[object Array]"===Object.prototype.toString.call(U)?[d(U[0]),d(U[1])]:d(U)}return 0===T.length?e.NEVER:1===r?T[0]:T}function d(e){if(e instanceof Date&&!isNaN(e.valueOf()))return new Date(e)}function l(e,t,n,r){for(var a=w(e),i=0,u=t.length;i<u;i++)n[i]&&!a(n[i],r)&&(n[i]=t[i].start(e,r))}function c(t,n,r,a){for(var i=w(t),u=0,o=n.length;u<o;u++)if(r[u]&&!i(r[u][0],a)){var f=n[u].start(t,a);r[u]=f?[f,n[u].end(t,f)]:e.NEVER}}function v(e,t,n,r){for(var a=0,i=t.length;a<i;a++)n[a]&&n[a].getTime()===r.getTime()&&(n[a]=t[a].start(e,t[a].tick(e,r)))}function s(e,t,n,r){for(var a,i=0,u=t.length;i<u;i++)if(t[i]&&t[i].getTime()===n.getTime()){var o=e[i].tickStart(n);if(r&&o<r)return r;(!a||o>a)&&(a=o)}return a}function m(e,t,n){for(var r,a=w(e),i=0,u=t.length;i<u;i++){var o=t[i];!o||a(o[0],n)||o[1]&&!a(o[1],n)||r&&!a(o[1],r)||(r=o[1])}return r}function h(e,t){for(var n,r=0,a=e.length;r<a;r++)!e[r]||n&&!t(n,e[r][0])||(n=e[r][0]);return n}function x(e,t,n,r,a){for(var i,u=w(e),o=0,f=t.length;o<f;o++){var d=n[o];if(d&&d.getTime()===r.getTime()){var l=t[o].end(e,d);if(a&&(!l||u(l,a)))return a;i&&!u(l,i)||(i=l)}}return i}function w(e){return"next"===e?function(e,t){return!t||e.getTime()>t.getTime()}:function(e,t){return!e||t.getTime()>e.getTime()}}function y(e,t){for(var n=e[0],r=1,a=e.length;r<a;r++)e[r]&&t(n,e[r])&&(n=e[r]);return n}return{isValid:function(t){return f("next",1,t,t)!==e.NEVER},next:function(e,t,n){return f("next",e||1,t,n)},prev:function(e,t,n){return f("prev",e||1,t,n)},nextRange:function(e,t,n){return f("next",e||1,t,n,!0)},prevRange:function(e,t,n){return f("prev",e||1,t,n,!0)}}},e.setTimeout=function(t,n,r){var a,i=e.schedule(n);return t&&function e(){var n=new Date,u=n.getTime(),o=function(){if(!r||["local","system"].includes(r))return i.next(2,u);var e=6e4*n.getTimezoneOffset(),t=function(e,t){var n=e.toLocaleString("en-US",{hour12:!1,timeZone:t,timeZoneName:"short"}).match(/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/).map((function(e){return 1===e.length?"0"+e:e})),r=new Date("".concat(n[3],"-").concat(n[1],"-").concat(n[2],"T").concat(n[4].replace("24","00"),":").concat(n[5],":").concat(n[6],"Z"));return e.getTime()-r.getTime()}(n,r);if(t===e)return i.next(2,u);var a=new Date(u+e-t);return(i.next(2,a)||[]).map((function(n){return new Date(n.getTime()+t-e)}))}();if(o[0]){var f=o[0].getTime()-u;f<1e3&&(f=o[1]?o[1].getTime()-u:1e3),a=f<2147483647?setTimeout(t,f):setTimeout(e,2147483647)}else a=void 0}(),{isDone:function(){return!a},clear:function(){clearTimeout(a)}}},e.setInterval=function(t,n,r){if(t){var a=e.setTimeout((function u(){i||(t(),a=e.setTimeout(u,n,r))}),n,r),i=a.isDone();return{isDone:function(){return a.isDone()},clear:function(){i=!0,a.clear()}}}},e.date={},e.date.timezone=function(t){e.date.build=t?function(e,t,n,r,a,i){return new Date(e,t,n,r,a,i)}:function(e,t,n,r,a,i){return new Date(Date.UTC(e,t,n,r,a,i))};var n=t?"get":"getUTC",r=Date.prototype;e.date.getYear=r[n+"FullYear"],e.date.getMonth=r[n+"Month"],e.date.getDate=r[n+"Date"],e.date.getDay=r[n+"Day"],e.date.getHour=r[n+"Hours"],e.date.getMin=r[n+"Minutes"],e.date.getSec=r[n+"Seconds"],e.date.isUTC=!t},e.date.UTC=function(){e.date.timezone(!1)},e.date.localTime=function(){e.date.timezone(!0)},e.date.UTC(),e.SEC=1e3,e.MIN=60*e.SEC,e.HOUR=60*e.MIN,e.DAY=24*e.HOUR,e.WEEK=7*e.DAY,e.DAYS_IN_MONTH=[31,28,31,30,31,30,31,31,30,31,30,31],e.NEVER=0,e.date.next=function(t,n,r,a,i,u){return e.date.build(t,void 0!==n?n-1:0,void 0!==r?r:1,a||0,i||0,u||0)},e.date.nextRollover=function(t,n,r,a){var i=r.val(t),u=r.extent(t)[1];return(n||u)<=i||n>u?new Date(a.end(t).getTime()+e.SEC):a.start(t)},e.date.prev=function(t,n,r,a,i,u){var o=arguments.length;return n=o<2?11:n-1,r=o<3?e.D.extent(e.date.next(t,n+1))[1]:r,a=o<4?23:a,i=o<5?59:i,u=o<6?59:u,e.date.build(t,n,r,a,i,u)},e.date.prevRollover=function(e,t,n,r){return t>=n.val(e)||!t?r.start(r.prev(e,r.val(e)-1)):r.start(e)},e.parse={},e.parse.cron=function(e,t){var n={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12,SUN:1,MON:2,TUE:3,WED:4,THU:5,FRI:6,SAT:7},r={"* * * * * *":"0/1 * * * * *","@YEARLY":"0 0 1 1 *","@ANNUALLY":"0 0 1 1 *","@MONTHLY":"0 0 1 * *","@WEEKLY":"0 0 * * 0","@DAILY":"0 0 * * *","@HOURLY":"0 * * * *"},a={s:[0,0,59],m:[1,0,59],h:[2,0,23],D:[3,1,31],M:[4,1,12],Y:[6,1970,2099],d:[5,1,7,1]};function i(e,t,r){return isNaN(e)?n[e]||null:Math.min(Number(e)+(t||0),r||9999)}function u(e,t,n,r,a){var i=n;for(e[t]||(e[t]=[]);i<=r;)e[t].includes(i)||e[t].push(i),i+=a||1;e[t].sort((function(e,t){return e-t}))}function o(e,t,n,r){(t.d&&!t.dc||t.dc&&!t.dc.includes(r))&&(e.push(function(e){var t,n={};for(t in e)"dc"!==t&&"d"!==t&&(n[t]=e[t].slice(0));return n}(t)),t=e[e.length-1]),u(t,"d",n,n),u(t,"dc",r,r)}function f(e){return e.includes("#")||e.indexOf("L")>0}function d(e,t){return f(e)&&!f(t)?1:e-t}var l=function(e){var t=e.toUpperCase();return r[t]||t}(e);return function(e){var t,r,f,l,c,v,s,m,h,x,w,y,g,p,D={schedules:[{}],exceptions:[]},M=e.replace(/(\s)+/g," ").split(" ");for(t in a)if((f=M[(r=a[t])[0]])&&"*"!==f&&"?"!==f){var b,Y=(l=f.split(",").sort(d)).length;for(b=0;b<Y;b++)c=l[b],v=D,s=t,m=r[1],h=r[2],x=r[3],w=void 0,y=void 0,g=void 0,p=void 0,g=v.schedules,p=g[g.length-1],"L"===c&&(c=m-1),null!==(w=i(c,x,h))?u(p,s,w,w):null!==(w=i(c.replace("W",""),x,h))?function(e,t,r){var a={},i={};1===r?(u(t,"D",1,3),u(t,"d",n.MON,n.FRI),u(a,"D",2,2),u(a,"d",n.TUE,n.FRI),u(i,"D",3,3),u(i,"d",n.TUE,n.FRI)):(u(t,"D",r-1,r+1),u(t,"d",n.MON,n.FRI),u(a,"D",r-1,r-1),u(a,"d",n.MON,n.THU),u(i,"D",r+1,r+1),u(i,"d",n.TUE,n.FRI)),e.exceptions.push(a),e.exceptions.push(i)}(v,p,w):null!==(w=i(c.replace("L",""),x,h))?o(g,p,w,m-1):2===(y=c.split("#")).length?o(g,p,w=i(y[0],x,h),i(y[1])):function(e,t,n,r,a,o){var f=e.split("/"),d=Number(f[1]),l=f[0];if("*"!==l&&"0"!==l){var c=l.split("-");r=i(c[0],o,a),a=i(c[1],o,a)||a}u(t,n,r,a,d)}(c,p,s,m,h,x)}return D}(t?l:"0 "+l)},e.parse.recur=function(){var t,n,r,a,i,u,o,f,d,l=[],c=[],v=l;function s(e,l,c){if(e=i?e+"_"+i:e,t||(v.push({}),t=v[0]),t[e]||(t[e]=[]),n=t[e],a){for(r=[],f=l;f<=c;f+=a)r.push(f);d={n:e,x:a,c:n.length,m:c}}var s=(r=u?[l]:o?[c]:r).length;for(f=0;f<s;f+=1){var m=r[f];n.includes(m)||n.push(m)}r=a=i=u=o=0}return{schedules:l,exceptions:c,on:function(){return r=Array.isArray(arguments[0])?arguments[0]:arguments,this},every:function(e){return a=e||1,this},after:function(e){return i="a",r=[e],this},before:function(e){return i="b",r=[e],this},first:function(){return u=1,this},last:function(){return o=1,this},time:function(){for(var e=0,t=r.length;e<t;e++){var n=r[e].split(":");n.length<3&&n.push(0),r[e]=3600*Number(n[0])+60*Number(n[1])+Number(n[2])}return s("t"),this},second:function(){return s("s",0,59),this},minute:function(){return s("m",0,59),this},hour:function(){return s("h",0,23),this},dayOfMonth:function(){return s("D",1,o?0:31),this},dayOfWeek:function(){return s("d",1,7),this},onWeekend:function(){return r=[1,7],this.dayOfWeek()},onWeekday:function(){return r=[2,3,4,5,6],this.dayOfWeek()},dayOfWeekCount:function(){return s("dc",1,o?0:5),this},dayOfYear:function(){return s("dy",1,o?0:366),this},weekOfMonth:function(){return s("wm",1,o?0:5),this},weekOfYear:function(){return s("wy",1,o?0:53),this},month:function(){return s("M",1,12),this},year:function(){return s("Y",1970,2450),this},fullDate:function(){for(var e=0,t=r.length;e<t;e++)r[e]=r[e].getTime();return s("fd"),this},customModifier:function(t,n){if(!e.modifier[t])throw new Error("Custom modifier "+t+" not recognized!");return i=t,r=Array.isArray(arguments[1])?arguments[1]:[arguments[1]],this},customPeriod:function(t){var n=e[t];if(!n)throw new Error("Custom time period "+t+" not recognized!");return s(t,n.extent(new Date)[0],n.extent(new Date)[1]),this},startingOn:function(e){return this.between(e,d.m)},between:function(e,n){return t[d.n]=t[d.n].splice(0,d.c),a=d.x,s(d.n,e,n),this},and:function(){return t=v[v.push({})-1],this},except:function(){return v=c,t=null,this}}},e.parse.text=function(t){var n,r=e.parse.recur,a=0,i="",u={eof:/^$/,rank:/^((\d+)(st|nd|rd|th)?)\b/,time:/^(((0?[1-9]|1[0-2]):[0-5]\d(\s)?(am|pm))|((0?\d|1\d|2[0-3]):[0-5]\d))\b/,dayName:/^((sun|mon|tue(s)?|wed(nes)?|thu(r(s)?)?|fri|sat(ur)?)(day)?)\b/,monthName:/^(jan(uary)?|feb(ruary)?|ma((r(ch)?)?|y)|apr(il)?|ju(ly|ne)|aug(ust)?|oct(ober)?|(sept|nov|dec)(ember)?)\b/,yearIndex:/^(\d{4})\b/,every:/^every\b/,after:/^after\b/,before:/^before\b/,second:/^(s|sec(ond)?(s)?)\b/,minute:/^(m|min(ute)?(s)?)\b/,hour:/^(h|hour(s)?)\b/,day:/^(day(s)?( of the month)?)\b/,dayInstance:/^day instance\b/,dayOfWeek:/^day(s)? of the week\b/,dayOfYear:/^day(s)? of the year\b/,weekOfYear:/^week(s)?( of the year)?\b/,weekOfMonth:/^week(s)? of the month\b/,weekday:/^weekday\b/,weekend:/^weekend\b/,month:/^month(s)?\b/,year:/^year(s)?\b/,between:/^between (the)?\b/,start:/^(start(ing)? (at|on( the)?)?)\b/,at:/^(at|@)\b/,and:/^(,|and\b)/,except:/^(except\b)/,also:/(also)\b/,first:/^(first)\b/,last:/^last\b/,in:/^in\b/,of:/^of\b/,onthe:/^on the\b/,on:/^on\b/,through:/(-|^(to|through)\b)/},o={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12,sun:1,mon:2,tue:3,wed:4,thu:5,fri:6,sat:7,"1st":1,fir:1,"2nd":2,sec:2,"3rd":3,thi:3,"4th":4,for:4};function f(e,t,n,r){return{startPos:e,endPos:t,text:n,type:r}}function d(e){var t,n,r,u,o,d,l=Array.isArray(e)?e:[e],c=/\s+/;for(l.push(c),o=a;!t||t.type===c;){var v;d=-1,n=i.slice(Math.max(0,o)),t=f(o,o,i.split(c)[0]);var s=l.length;for(v=0;v<s;v++)(r=(u=l[v]).exec(n))&&0===r.index&&r[0].length>d&&(t=f(o,o+(d=r[0].length),n.slice(0,Math.max(0,d)),u));t.type===c&&(o=t.endPos)}return t}function l(e){var t=d(e);return a=t.endPos,t}function c(e){for(var t=Number(y(e)),n=x(u.through)?Number(y(e)):t,r=[],a=t;a<=n;a++)r.push(a);return r}function v(e){for(var t=c(e);x(u.and);)t=t.concat(c(e));return t}function s(e){var t,n,r,a;x(u.weekend)?e.on(o.sun,o.sat).dayOfWeek():x(u.weekday)?e.on(o.mon,o.tue,o.wed,o.thu,o.fri).dayOfWeek():(t=y(u.rank),e.every(t),n=h(e),x(u.start)?(t=y(u.rank),e.startingOn(t),w(n.type)):x(u.between)&&(r=y(u.rank),x(u.and)&&(a=y(u.rank),e.between(r,a))))}function m(e){x(u.first)?e.first():x(u.last)?e.last():e.on(v(u.rank)),h(e)}function h(e){var t=w([u.second,u.minute,u.hour,u.dayOfYear,u.dayOfWeek,u.dayInstance,u.day,u.month,u.year,u.weekOfMonth,u.weekOfYear]);switch(t.type){case u.second:e.second();break;case u.minute:e.minute();break;case u.hour:e.hour();break;case u.dayOfYear:e.dayOfYear();break;case u.dayOfWeek:e.dayOfWeek();break;case u.dayInstance:e.dayOfWeekCount();break;case u.day:e.dayOfMonth();break;case u.weekOfMonth:e.weekOfMonth();break;case u.weekOfYear:e.weekOfYear();break;case u.month:e.month();break;case u.year:e.year();break;default:n=a}return t}function x(e){var t=d(e).type===e;return t&&l(e),t}function w(e){var t=l(e);return t.type?t.text=function(e,t){var n=e;switch(t){case u.time:var r=e.split(/(:|am|pm)/),a=Number.parseInt(r[0],10),i=r[2].trim();"pm"===r[3]&&a<12?a+=12:"am"===r[3]&&12===a&&(a-=12),n=(1===(a=String(a)).length?"0":"")+a+":"+i;break;case u.rank:n=Number.parseInt(/^\d+/.exec(e)[0],10);break;case u.monthName:case u.dayName:n=o[e.slice(0,3)]}return n}(t.text,e):n=a,t}function y(e){return w(e).text}return function(e){a=0,i=e,n=-1;for(var t=r();a<i.length&&n<0;)switch(w([u.every,u.after,u.before,u.onthe,u.on,u.of,u.in,u.at,u.and,u.except,u.also]).type){case u.every:s(t);break;case u.after:void 0!==d(u.time).type?(t.after(y(u.time)),t.time()):(t.after(y(u.rank)),h(t));break;case u.before:void 0!==d(u.time).type?(t.before(y(u.time)),t.time()):(t.before(y(u.rank)),h(t));break;case u.onthe:m(t);break;case u.on:t.on(v(u.dayName)).dayOfWeek();break;case u.of:t.on(v(u.monthName)).month();break;case u.in:t.on(v(u.yearIndex)).year();break;case u.at:for(t.on(y(u.time)).time();x(u.and);)t.on(y(u.time)).time();break;case u.and:break;case u.also:t.and();break;case u.except:t.except();break;default:n=a}return{schedules:t.schedules,exceptions:t.exceptions,error:n}}(t.toLowerCase())},e})); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).later=e()}}((function(){var e={version:"4.1.0",array:{}};return e.array.sort=function(e,t){e.sort((function(e,t){return Number(e)-Number(t)})),t&&0===e[0]&&e.push(e.shift())},e.array.next=function(e,t,n){for(var r,a=0!==n[0],i=0,u=t.length-1;u>-1;--u){if((r=t[u])===e)return r;if(!(r>e||0===r&&a&&n[1]>e))break;i=u}return t[i]},e.array.nextInvalid=function(e,t,n){for(var r=n[0],a=n[1],i=t.length,u=0===t[i-1]&&0!==r?a:0,o=e,f=t.indexOf(e),d=o;o===(t[f]||u);)if(++o>a&&(o=r),++f===i&&(f=0),o===d)return;return o},e.array.prev=function(e,t,n){for(var r,a=t.length,i=0!==n[0],u=a-1,o=0;o<a;o++){if((r=t[o])===e)return r;if(!(r<e||0===r&&i&&n[1]<e))break;u=o}return t[u]},e.array.prevInvalid=function(e,t,n){for(var r=n[0],a=n[1],i=t.length,u=0===t[i-1]&&0!==r?a:0,o=e,f=t.indexOf(e),d=o;o===(t[f]||u);)if(--o<r&&(o=a),-1==--f&&(f=i-1),o===d)return;return o},e.day=e.D={name:"day",range:86400,val:function(t){return t.D||(t.D=e.date.getDate.call(t))},isValid:function(t,n){return e.D.val(t)===(n||e.D.extent(t)[1])},extent:function(t){if(t.DExtent)return t.DExtent;var n=e.M.val(t),r=e.DAYS_IN_MONTH[n-1];return 2===n&&366===e.dy.extent(t)[1]&&(r+=1),t.DExtent=[1,r]},start:function(t){return t.DStart||(t.DStart=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)))},end:function(t){return t.DEnd||(t.DEnd=e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t)))},next:function(t,n){n=n>e.D.extent(t)[1]?1:n;var r=e.date.nextRollover(t,n,e.D,e.M),a=e.D.extent(r)[1];return n=n>a?1:n||a,e.date.next(e.Y.val(r),e.M.val(r),n)},prev:function(t,n){var r=e.date.prevRollover(t,n,e.D,e.M),a=e.D.extent(r)[1];return e.date.prev(e.Y.val(r),e.M.val(r),n>a?a:n||a)}},e.dayOfWeekCount=e.dc={name:"day of week count",range:604800,val:function(t){return t.dc||(t.dc=Math.floor((e.D.val(t)-1)/7)+1)},isValid:function(t,n){return e.dc.val(t)===n||0===n&&e.D.val(t)>e.D.extent(t)[1]-7},extent:function(t){return t.dcExtent||(t.dcExtent=[1,Math.ceil(e.D.extent(t)[1]/7)])},start:function(t){return t.dcStart||(t.dcStart=e.date.next(e.Y.val(t),e.M.val(t),Math.max(1,7*(e.dc.val(t)-1)+1||1)))},end:function(t){return t.dcEnd||(t.dcEnd=e.date.prev(e.Y.val(t),e.M.val(t),Math.min(7*e.dc.val(t),e.D.extent(t)[1])))},next:function(t,n){n=n>e.dc.extent(t)[1]?1:n;var r=e.date.nextRollover(t,n,e.dc,e.M);n=n>e.dc.extent(r)[1]?1:n;var a=e.date.next(e.Y.val(r),e.M.val(r),0===n?e.D.extent(r)[1]-6:1+7*(n-1));return a.getTime()<=t.getTime()?(r=e.M.next(t,e.M.val(t)+1),e.date.next(e.Y.val(r),e.M.val(r),0===n?e.D.extent(r)[1]-6:1+7*(n-1))):a},prev:function(t,n){var r=e.date.prevRollover(t,n,e.dc,e.M),a=e.dc.extent(r)[1];return n=n>a?a:n||a,e.dc.end(e.date.prev(e.Y.val(r),e.M.val(r),1+7*(n-1)))}},e.dayOfWeek=e.dw=e.d={name:"day of week",range:86400,val:function(t){return t.dw||(t.dw=e.date.getDay.call(t)+1)},isValid:function(t,n){return e.dw.val(t)===(n||7)},extent:function(){return[1,7]},start:function(t){return e.D.start(t)},end:function(t){return e.D.end(t)},next:function(t,n){return n=n>7?1:n||7,e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)+(n-e.dw.val(t))+(n<=e.dw.val(t)?7:0))},prev:function(t,n){return n=n>7?7:n||7,e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t)+(n-e.dw.val(t))+(n>=e.dw.val(t)?-7:0))}},e.dayOfYear=e.dy={name:"day of year",range:86400,val:function(t){return t.dy||(t.dy=Math.ceil(1+(e.D.start(t).getTime()-e.Y.start(t).getTime())/e.DAY))},isValid:function(t,n){return e.dy.val(t)===(n||e.dy.extent(t)[1])},extent:function(t){var n=e.Y.val(t);return t.dyExtent||(t.dyExtent=[1,n%4?365:366])},start:function(t){return e.D.start(t)},end:function(t){return e.D.end(t)},next:function(t,n){n=n>e.dy.extent(t)[1]?1:n;var r=e.date.nextRollover(t,n,e.dy,e.Y),a=e.dy.extent(r)[1];return n=n>a?1:n||a,e.date.next(e.Y.val(r),e.M.val(r),n)},prev:function(t,n){var r=e.date.prevRollover(t,n,e.dy,e.Y),a=e.dy.extent(r)[1];return n=n>a?a:n||a,e.date.prev(e.Y.val(r),e.M.val(r),n)}},e.hour=e.h={name:"hour",range:3600,val:function(t){return t.h||(t.h=e.date.getHour.call(t))},isValid:function(t,n){return e.h.val(t)===n},extent:function(){return[0,23]},start:function(t){return t.hStart||(t.hStart=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t)))},end:function(t){return t.hEnd||(t.hEnd=e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t)))},next:function(t,n){n=n>23?0:n;var r=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)+(n<=e.h.val(t)?1:0),n);return!e.date.isUTC&&r.getTime()<=t.getTime()&&(r=e.date.next(e.Y.val(r),e.M.val(r),e.D.val(r),n+1)),r},prev:function(t,n){return n=n>23?23:n,e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t)+(n>=e.h.val(t)?-1:0),n)}},e.minute=e.m={name:"minute",range:60,val:function(t){return t.m||(t.m=e.date.getMin.call(t))},isValid:function(t,n){return e.m.val(t)===n},extent:function(e){return[0,59]},start:function(t){return t.mStart||(t.mStart=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t),e.m.val(t)))},end:function(t){return t.mEnd||(t.mEnd=e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t),e.m.val(t)))},next:function(t,n){var r=e.m.val(t),a=e.s.val(t),i=n>59?60-r:n<=r?60-r+n:n-r,u=new Date(t.getTime()+i*e.MIN-a*e.SEC);return!e.date.isUTC&&u.getTime()<=t.getTime()&&(u=new Date(t.getTime()+(i+120)*e.MIN-a*e.SEC)),u},prev:function(t,n){return n=n>59?59:n,e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t)+(n>=e.m.val(t)?-1:0),n)}},e.month=e.M={name:"month",range:2629740,val:function(t){return t.M||(t.M=e.date.getMonth.call(t)+1)},isValid:function(t,n){return e.M.val(t)===(n||12)},extent:function(){return[1,12]},start:function(t){return t.MStart||(t.MStart=e.date.next(e.Y.val(t),e.M.val(t)))},end:function(t){return t.MEnd||(t.MEnd=e.date.prev(e.Y.val(t),e.M.val(t)))},next:function(t,n){return n=n>12?1:n||12,e.date.next(e.Y.val(t)+(n>e.M.val(t)?0:1),n)},prev:function(t,n){return n=n>12?12:n||12,e.date.prev(e.Y.val(t)-(n>=e.M.val(t)?1:0),n)}},e.second=e.s={name:"second",range:1,val:function(t){return t.s||(t.s=e.date.getSec.call(t))},isValid:function(t,n){return e.s.val(t)===n},extent:function(){return[0,59]},start:function(e){return e},end:function(e){return e},next:function(t,n){var r=e.s.val(t),a=n>59?60-r:n<=r?60-r+n:n-r,i=new Date(t.getTime()+a*e.SEC);return!e.date.isUTC&&i.getTime()<=t.getTime()&&(i=new Date(t.getTime()+(a+7200)*e.SEC)),i},prev:function(t,n,r){return n=n>59?59:n,e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t),e.h.val(t),e.m.val(t)+(n>=e.s.val(t)?-1:0),n)}},e.time=e.t={name:"time",range:1,val:function(t){return t.t||(t.t=3600*e.h.val(t)+60*e.m.val(t)+e.s.val(t))},isValid:function(t,n){return e.t.val(t)===n},extent:function(){return[0,86399]},start:function(e){return e},end:function(e){return e},next:function(t,n){n=n>86399?0:n;var r=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)+(n<=e.t.val(t)?1:0),0,0,n);return!e.date.isUTC&&r.getTime()<t.getTime()&&(r=e.date.next(e.Y.val(r),e.M.val(r),e.D.val(r),e.h.val(r),e.m.val(r),n+7200)),r},prev:function(t,n){return n=n>86399?86399:n,e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)+(n>=e.t.val(t)?-1:0),0,0,n)}},e.weekOfMonth=e.wm={name:"week of month",range:604800,val:function(t){return t.wm||(t.wm=(e.D.val(t)+(e.dw.val(e.M.start(t))-1)+(7-e.dw.val(t)))/7)},isValid:function(t,n){return e.wm.val(t)===(n||e.wm.extent(t)[1])},extent:function(t){return t.wmExtent||(t.wmExtent=[1,(e.D.extent(t)[1]+(e.dw.val(e.M.start(t))-1)+(7-e.dw.val(e.M.end(t))))/7])},start:function(t){return t.wmStart||(t.wmStart=e.date.next(e.Y.val(t),e.M.val(t),Math.max(e.D.val(t)-e.dw.val(t)+1,1)))},end:function(t){return t.wmEnd||(t.wmEnd=e.date.prev(e.Y.val(t),e.M.val(t),Math.min(e.D.val(t)+(7-e.dw.val(t)),e.D.extent(t)[1])))},next:function(t,n){n=n>e.wm.extent(t)[1]?1:n;var r=e.date.nextRollover(t,n,e.wm,e.M),a=e.wm.extent(r)[1];return n=n>a?1:n||a,e.date.next(e.Y.val(r),e.M.val(r),Math.max(1,7*(n-1)-(e.dw.val(r)-2)))},prev:function(t,n){var r=e.date.prevRollover(t,n,e.wm,e.M),a=e.wm.extent(r)[1];return n=n>a?a:n||a,e.wm.end(e.date.next(e.Y.val(r),e.M.val(r),Math.max(1,7*(n-1)-(e.dw.val(r)-2))))}},e.weekOfYear=e.wy={name:"week of year (ISO)",range:604800,val:function(t){if(t.wy)return t.wy;var n=e.dw.next(e.wy.start(t),5),r=e.dw.next(e.Y.prev(n,e.Y.val(n)-1),5);return t.wy=1+Math.ceil((n.getTime()-r.getTime())/e.WEEK)},isValid:function(t,n){return e.wy.val(t)===(n||e.wy.extent(t)[1])},extent:function(t){if(t.wyExtent)return t.wyExtent;var n=e.dw.next(e.wy.start(t),5),r=e.dw.val(e.Y.start(n)),a=e.dw.val(e.Y.end(n));return t.wyExtent=[1,5===r||5===a?53:52]},start:function(t){return t.wyStart||(t.wyStart=e.date.next(e.Y.val(t),e.M.val(t),e.D.val(t)-(e.dw.val(t)>1?e.dw.val(t)-2:6)))},end:function(t){return t.wyEnd||(t.wyEnd=e.date.prev(e.Y.val(t),e.M.val(t),e.D.val(t)+(e.dw.val(t)>1?8-e.dw.val(t):0)))},next:function(t,n){n=n>e.wy.extent(t)[1]?1:n;var r=e.dw.next(e.wy.start(t),5),a=e.date.nextRollover(r,n,e.wy,e.Y);1!==e.wy.val(a)&&(a=e.dw.next(a,2));var i=e.wy.extent(a)[1],u=e.wy.start(a);return n=n>i?1:n||i,e.date.next(e.Y.val(u),e.M.val(u),e.D.val(u)+7*(n-1))},prev:function(t,n){var r=e.dw.next(e.wy.start(t),5),a=e.date.prevRollover(r,n,e.wy,e.Y);1!==e.wy.val(a)&&(a=e.dw.next(a,2));var i=e.wy.extent(a)[1],u=e.wy.end(a);return n=n>i?i:n||i,e.wy.end(e.date.next(e.Y.val(u),e.M.val(u),e.D.val(u)+7*(n-1)))}},e.year=e.Y={name:"year",range:31556900,val:function(t){return t.Y||(t.Y=e.date.getYear.call(t))},isValid:function(t,n){return e.Y.val(t)===n},extent:function(){return[1970,2099]},start:function(t){return t.YStart||(t.YStart=e.date.next(e.Y.val(t)))},end:function(t){return t.YEnd||(t.YEnd=e.date.prev(e.Y.val(t)))},next:function(t,n){return n>e.Y.val(t)&&n<=e.Y.extent()[1]?e.date.next(n):e.NEVER},prev:function(t,n){return n<e.Y.val(t)&&n>=e.Y.extent()[0]?e.date.prev(n):e.NEVER}},e.fullDate=e.fd={name:"full date",range:1,val:function(e){return e.fd||(e.fd=e.getTime())},isValid:function(t,n){return e.fd.val(t)===n},extent:function(){return[0,3250368e7]},start:function(e){return e},end:function(e){return e},next:function(t,n){return e.fd.val(t)<n?new Date(n):e.NEVER},prev:function(t,n){return e.fd.val(t)>n?new Date(n):e.NEVER}},e.modifier={},e.modifier.after=e.modifier.a=function(e,t){var n=t[0];return{name:"after "+e.name,range:(e.extent(new Date)[1]-n)*e.range,val:e.val,isValid:function(e,t){return this.val(e)>=n},extent:e.extent,start:e.start,end:e.end,next:function(t,r){return r!=n&&(r=e.extent(t)[0]),e.next(t,r)},prev:function(t,r){return r=r===n?e.extent(t)[1]:n-1,e.prev(t,r)}}},e.modifier.before=e.modifier.b=function(e,t){var n=t[t.length-1];return{name:"before "+e.name,range:e.range*(n-1),val:e.val,isValid:function(e,t){return this.val(e)<n},extent:e.extent,start:e.start,end:e.end,next:function(t,r){return r=r===n?e.extent(t)[0]:n,e.next(t,r)},prev:function(t,r){return r=r===n?n-1:e.extent(t)[1],e.prev(t,r)}}},e.compile=function(t){var n,r=[],a=0;for(var i in t){var u=i.split("_"),o=u[0],f=u[1],d=t[i],l=f?e.modifier[f](e[o],d):e[o];r.push({constraint:l,vals:d}),a++}return r.sort((function(e,t){var n=e.constraint.range,r=t.constraint.range;return r<n?-1:r>n?1:0})),n=r[a-1].constraint,{start:function(t,i){for(var u,o=i,f=e.array[t],d=1e3;d--&&!u&&o;){u=!0;for(var l=0;l<a;l++){var c=r[l].constraint,v=c.val(o),s=c.extent(o),m=f(v,r[l].vals,s);if(!c.isValid(o,m)){o=c[t](o,m),u=!1;break}}}return o!==e.NEVER&&(o="next"===t?n.start(o):n.end(o)),o},end:function(t,n){for(var i,u=e.array[t+"Invalid"],o=function(e){return"next"===e?function(e,t){return!e||!t||e.getTime()>t.getTime()}:function(e,t){return!e||!t||t.getTime()>e.getTime()}}(t),f=a-1;f>=0;f--){var d,l=r[f].constraint,c=l.val(n),v=l.extent(n),s=u(c,r[f].vals,v);void 0!==s&&(!(d=l[t](n,s))||i&&!o(i,d)||(i=d))}return i},tick:function(t,r){return new Date("next"===t?n.end(r).getTime()+e.SEC:n.start(r).getTime()-e.SEC)},tickStart:function(e){return n.start(e)}}},e.schedule=function(t){if(!t)throw new Error("Missing schedule definition.");if(!t.schedules)throw new Error("Definition must include at least one schedule.");for(var n=[],r=t.schedules.length,a=[],i=t.exceptions?t.exceptions.length:0,u=0;u<r;u++)n.push(e.compile(t.schedules[u]));for(var o=0;o<i;o++)a.push(e.compile(t.exceptions[o]));function f(t,r,u,o,f){var g,p,D,M=w(t),b=r,Y=1e3,k=[],E=[],T=[],O="next"===t,N=O?0:1,S=O?1:0;if(!(u=u?new Date(u):new Date)||!u.getTime())throw new Error("Invalid start date.");for(function(e,t,n,r){for(var a=0,i=t.length;a<i;a++)n[a]=t[a].start(e,r)}(t,n,k,u),function(t,n,r,a){w(t);for(var i=0,u=n.length;i<u;i++){var o=n[i].start(t,a);r[i]=o?[o,n[i].end(t,o)]:e.NEVER}}(t,a,E,u);Y--&&b&&(g=y(k,M))&&(!o||!M(g,o));)if(i&&(c(t,a,E,g),p=m(t,E,g)))l(t,n,k,p);else{if(f){var R=h(E,M);p=x(t,n,k,g,R);var C=O?[new Date(Math.max(u,g)),p?new Date(o?Math.min(p,o):p):void 0]:[p?new Date(o?Math.max(o,p.getTime()+e.SEC):p.getTime()+e.SEC):void 0,new Date(Math.min(u,g.getTime()+e.SEC))];if(D&&C[N].getTime()===D[S].getTime()?(D[S]=C[S],b++):(D=C,T.push(D)),!p)break;l(t,n,k,p)}else T.push(O?new Date(Math.max(u,g)):s(n,k,g,o)),v(t,n,k,g);b--}for(var V=0,I=T.length;V<I;V++){var U=T[V];T[V]="[object Array]"===Object.prototype.toString.call(U)?[d(U[0]),d(U[1])]:d(U)}return 0===T.length?e.NEVER:1===r?T[0]:T}function d(e){if(e instanceof Date&&!isNaN(e.valueOf()))return new Date(e)}function l(e,t,n,r){for(var a=w(e),i=0,u=t.length;i<u;i++)n[i]&&!a(n[i],r)&&(n[i]=t[i].start(e,r))}function c(t,n,r,a){for(var i=w(t),u=0,o=n.length;u<o;u++)if(r[u]&&!i(r[u][0],a)){var f=n[u].start(t,a);r[u]=f?[f,n[u].end(t,f)]:e.NEVER}}function v(e,t,n,r){for(var a=0,i=t.length;a<i;a++)n[a]&&n[a].getTime()===r.getTime()&&(n[a]=t[a].start(e,t[a].tick(e,r)))}function s(e,t,n,r){for(var a,i=0,u=t.length;i<u;i++)if(t[i]&&t[i].getTime()===n.getTime()){var o=e[i].tickStart(n);if(r&&o<r)return r;(!a||o>a)&&(a=o)}return a}function m(e,t,n){for(var r,a=w(e),i=0,u=t.length;i<u;i++){var o=t[i];!o||a(o[0],n)||o[1]&&!a(o[1],n)||r&&!a(o[1],r)||(r=o[1])}return r}function h(e,t){for(var n,r=0,a=e.length;r<a;r++)!e[r]||n&&!t(n,e[r][0])||(n=e[r][0]);return n}function x(e,t,n,r,a){for(var i,u=w(e),o=0,f=t.length;o<f;o++){var d=n[o];if(d&&d.getTime()===r.getTime()){var l=t[o].end(e,d);if(a&&(!l||u(l,a)))return a;i&&!u(l,i)||(i=l)}}return i}function w(e){return"next"===e?function(e,t){return!e||!t||e.getTime()>t.getTime()}:function(e,t){return!e||!t||t.getTime()>e.getTime()}}function y(e,t){for(var n=e[0],r=1,a=e.length;r<a;r++)e[r]&&t(n,e[r])&&(n=e[r]);return n}return{isValid:function(t){return f("next",1,t,t)!==e.NEVER},next:function(e,t,n){return f("next",e||1,t,n)},prev:function(e,t,n){return f("prev",e||1,t,n)},nextRange:function(e,t,n){return f("next",e||1,t,n,!0)},prevRange:function(e,t,n){return f("prev",e||1,t,n,!0)}}},e.setTimeout=function(t,n,r){var a,i=e.schedule(n);return t&&function e(){var n=new Date,u=n.getTime(),o=function(){if(!r||["local","system"].includes(r))return i.next(2,u);var e=6e4*n.getTimezoneOffset(),t=function(e,t){var n=e.toLocaleString("en-US",{hour12:!1,timeZone:t,timeZoneName:"short"}).match(/(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/).map((function(e){return 1===e.length?"0"+e:e})),r=new Date("".concat(n[3],"-").concat(n[1],"-").concat(n[2],"T").concat(n[4].replace("24","00"),":").concat(n[5],":").concat(n[6],"Z"));return e.getTime()-r.getTime()}(n,r);if(t===e)return i.next(2,u);var a=new Date(u+e-t);return(i.next(2,a)||[]).map((function(n){return new Date(n.getTime()+t-e)}))}();if(o[0]){var f=o[0].getTime()-u;f<1e3&&(f=o[1]?o[1].getTime()-u:1e3),a=f<2147483647?setTimeout(t,f):setTimeout(e,2147483647)}else a=void 0}(),{isDone:function(){return!a},clear:function(){clearTimeout(a)}}},e.setInterval=function(t,n,r){if(t){var a=e.setTimeout((function u(){i||(t(),a=e.setTimeout(u,n,r))}),n,r),i=a.isDone();return{isDone:function(){return a.isDone()},clear:function(){i=!0,a.clear()}}}},e.date={},e.date.timezone=function(t){e.date.build=t?function(e,t,n,r,a,i){return new Date(e,t,n,r,a,i)}:function(e,t,n,r,a,i){return new Date(Date.UTC(e,t,n,r,a,i))};var n=t?"get":"getUTC",r=Date.prototype;e.date.getYear=r[n+"FullYear"],e.date.getMonth=r[n+"Month"],e.date.getDate=r[n+"Date"],e.date.getDay=r[n+"Day"],e.date.getHour=r[n+"Hours"],e.date.getMin=r[n+"Minutes"],e.date.getSec=r[n+"Seconds"],e.date.isUTC=!t},e.date.UTC=function(){e.date.timezone(!1)},e.date.localTime=function(){e.date.timezone(!0)},e.date.UTC(),e.SEC=1e3,e.MIN=60*e.SEC,e.HOUR=60*e.MIN,e.DAY=24*e.HOUR,e.WEEK=7*e.DAY,e.DAYS_IN_MONTH=[31,28,31,30,31,30,31,31,30,31,30,31],e.NEVER=0,e.date.next=function(t,n,r,a,i,u){return e.date.build(t,void 0!==n?n-1:0,void 0!==r?r:1,a||0,i||0,u||0)},e.date.nextRollover=function(t,n,r,a){var i=r.val(t),u=r.extent(t)[1];return(n||u)<=i||n>u?new Date(a.end(t).getTime()+e.SEC):a.start(t)},e.date.prev=function(t,n,r,a,i,u){var o=arguments.length;return n=o<2?11:n-1,r=o<3?e.D.extent(e.date.next(t,n+1))[1]:r,a=o<4?23:a,i=o<5?59:i,u=o<6?59:u,e.date.build(t,n,r,a,i,u)},e.date.prevRollover=function(e,t,n,r){return t>=n.val(e)||!t?r.start(r.prev(e,r.val(e)-1)):r.start(e)},e.parse={},e.parse.cron=function(e,t){var n={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12,SUN:1,MON:2,TUE:3,WED:4,THU:5,FRI:6,SAT:7},r={"* * * * * *":"0/1 * * * * *","@YEARLY":"0 0 1 1 *","@ANNUALLY":"0 0 1 1 *","@MONTHLY":"0 0 1 * *","@WEEKLY":"0 0 * * 0","@DAILY":"0 0 * * *","@HOURLY":"0 * * * *"},a={s:[0,0,59],m:[1,0,59],h:[2,0,23],D:[3,1,31],M:[4,1,12],Y:[6,1970,2099],d:[5,1,7,1]};function i(e,t,r){return isNaN(e)?n[e]||null:Math.min(Number(e)+(t||0),r||9999)}function u(e,t,n,r,a){var i=n;for(e[t]||(e[t]=[]);i<=r;)e[t].includes(i)||e[t].push(i),i+=a||1;e[t].sort((function(e,t){return e-t}))}function o(e,t,n,r){(t.d&&!t.dc||t.dc&&!t.dc.includes(r))&&(e.push(function(e){var t,n={};for(t in e)"dc"!==t&&"d"!==t&&(n[t]=e[t].slice(0));return n}(t)),t=e[e.length-1]),u(t,"d",n,n),u(t,"dc",r,r)}function f(e){return e.includes("#")||e.indexOf("L")>0}function d(e,t){return f(e)&&!f(t)?1:e-t}var l=function(e){var t=e.toUpperCase();return r[t]||t}(e);return function(e){var t,r,f,l,c,v,s,m,h,x,w,y,g,p,D={schedules:[{}],exceptions:[]},M=e.replace(/(\s)+/g," ").split(" ");for(t in a)if((f=M[(r=a[t])[0]])&&"*"!==f&&"?"!==f){var b,Y=(l=f.split(",").sort(d)).length;for(b=0;b<Y;b++)c=l[b],v=D,s=t,m=r[1],h=r[2],x=r[3],w=void 0,y=void 0,g=void 0,p=void 0,g=v.schedules,p=g[g.length-1],"L"===c&&(c=m-1),null!==(w=i(c,x,h))?u(p,s,w,w):null!==(w=i(c.replace("W",""),x,h))?function(e,t,r){var a={},i={};1===r?(u(t,"D",1,3),u(t,"d",n.MON,n.FRI),u(a,"D",2,2),u(a,"d",n.TUE,n.FRI),u(i,"D",3,3),u(i,"d",n.TUE,n.FRI)):(u(t,"D",r-1,r+1),u(t,"d",n.MON,n.FRI),u(a,"D",r-1,r-1),u(a,"d",n.MON,n.THU),u(i,"D",r+1,r+1),u(i,"d",n.TUE,n.FRI)),e.exceptions.push(a),e.exceptions.push(i)}(v,p,w):null!==(w=i(c.replace("L",""),x,h))?o(g,p,w,m-1):2===(y=c.split("#")).length?o(g,p,w=i(y[0],x,h),i(y[1])):function(e,t,n,r,a,o){var f=e.split("/"),d=Number(f[1]),l=f[0];if("*"!==l&&"0"!==l){var c=l.split("-");r=i(c[0],o,a),a=i(c[1],o,a)||a}u(t,n,r,a,d)}(c,p,s,m,h,x)}return D}(t?l:"0 "+l)},e.parse.recur=function(){var t,n,r,a,i,u,o,f,d,l=[],c=[],v=l;function s(e,l,c){if(e=i?e+"_"+i:e,t||(v.push({}),t=v[0]),t[e]||(t[e]=[]),n=t[e],a){for(r=[],f=l;f<=c;f+=a)r.push(f);d={n:e,x:a,c:n.length,m:c}}var s=(r=u?[l]:o?[c]:r).length;for(f=0;f<s;f+=1){var m=r[f];n.includes(m)||n.push(m)}r=a=i=u=o=0}return{schedules:l,exceptions:c,on:function(){return r=Array.isArray(arguments[0])?arguments[0]:arguments,this},every:function(e){return a=e||1,this},after:function(e){return i="a",r=[e],this},before:function(e){return i="b",r=[e],this},first:function(){return u=1,this},last:function(){return o=1,this},time:function(){for(var e=0,t=r.length;e<t;e++){var n=r[e].split(":");n.length<3&&n.push(0),r[e]=3600*Number(n[0])+60*Number(n[1])+Number(n[2])}return s("t"),this},second:function(){return s("s",0,59),this},minute:function(){return s("m",0,59),this},hour:function(){return s("h",0,23),this},dayOfMonth:function(){return s("D",1,o?0:31),this},dayOfWeek:function(){return s("d",1,7),this},onWeekend:function(){return r=[1,7],this.dayOfWeek()},onWeekday:function(){return r=[2,3,4,5,6],this.dayOfWeek()},dayOfWeekCount:function(){return s("dc",1,o?0:5),this},dayOfYear:function(){return s("dy",1,o?0:366),this},weekOfMonth:function(){return s("wm",1,o?0:5),this},weekOfYear:function(){return s("wy",1,o?0:53),this},month:function(){return s("M",1,12),this},year:function(){return s("Y",1970,2450),this},fullDate:function(){for(var e=0,t=r.length;e<t;e++)r[e]=r[e].getTime();return s("fd"),this},customModifier:function(t,n){if(!e.modifier[t])throw new Error("Custom modifier "+t+" not recognized!");return i=t,r=Array.isArray(arguments[1])?arguments[1]:[arguments[1]],this},customPeriod:function(t){var n=e[t];if(!n)throw new Error("Custom time period "+t+" not recognized!");return s(t,n.extent(new Date)[0],n.extent(new Date)[1]),this},startingOn:function(e){return this.between(e,d.m)},between:function(e,n){return t[d.n]=t[d.n].splice(0,d.c),a=d.x,s(d.n,e,n),this},and:function(){return t=v[v.push({})-1],this},except:function(){return v=c,t=null,this}}},e.parse.text=function(t){var n,r=e.parse.recur,a=0,i="",u={eof:/^$/,rank:/^((\d+)(st|nd|rd|th)?)\b/,time:/^(((0?[1-9]|1[0-2]):[0-5]\d(\s)?(am|pm))|((0?\d|1\d|2[0-3]):[0-5]\d))\b/,dayName:/^((sun|mon|tue(s)?|wed(nes)?|thu(r(s)?)?|fri|sat(ur)?)(day)?)\b/,monthName:/^(jan(uary)?|feb(ruary)?|ma((r(ch)?)?|y)|apr(il)?|ju(ly|ne)|aug(ust)?|oct(ober)?|(sept|nov|dec)(ember)?)\b/,yearIndex:/^(\d{4})\b/,every:/^every\b/,after:/^after\b/,before:/^before\b/,second:/^(s|sec(ond)?(s)?)\b/,minute:/^(m|min(ute)?(s)?)\b/,hour:/^(h|hour(s)?)\b/,day:/^(day(s)?( of the month)?)\b/,dayInstance:/^day instance\b/,dayOfWeek:/^day(s)? of the week\b/,dayOfYear:/^day(s)? of the year\b/,weekOfYear:/^week(s)?( of the year)?\b/,weekOfMonth:/^week(s)? of the month\b/,weekday:/^weekday\b/,weekend:/^weekend\b/,month:/^month(s)?\b/,year:/^year(s)?\b/,between:/^between (the)?\b/,start:/^(start(ing)? (at|on( the)?)?)\b/,at:/^(at|@)\b/,and:/^(,|and\b)/,except:/^(except\b)/,also:/(also)\b/,first:/^(first)\b/,last:/^last\b/,in:/^in\b/,of:/^of\b/,onthe:/^on the\b/,on:/^on\b/,through:/(-|^(to|through)\b)/},o={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12,sun:1,mon:2,tue:3,wed:4,thu:5,fri:6,sat:7,"1st":1,fir:1,"2nd":2,sec:2,"3rd":3,thi:3,"4th":4,for:4};function f(e,t,n,r){return{startPos:e,endPos:t,text:n,type:r}}function d(e){var t,n,r,u,o,d,l=Array.isArray(e)?e:[e],c=/\s+/;for(l.push(c),o=a;!t||t.type===c;){var v;d=-1,n=i.slice(Math.max(0,o)),t=f(o,o,i.split(c)[0]);var s=l.length;for(v=0;v<s;v++)(r=(u=l[v]).exec(n))&&0===r.index&&r[0].length>d&&(t=f(o,o+(d=r[0].length),n.slice(0,Math.max(0,d)),u));t.type===c&&(o=t.endPos)}return t}function l(e){var t=d(e);return a=t.endPos,t}function c(e){for(var t=Number(y(e)),n=x(u.through)?Number(y(e)):t,r=[],a=t;a<=n;a++)r.push(a);return r}function v(e){for(var t=c(e);x(u.and);)t=t.concat(c(e));return t}function s(e){var t,n,r,a;x(u.weekend)?e.on(o.sun,o.sat).dayOfWeek():x(u.weekday)?e.on(o.mon,o.tue,o.wed,o.thu,o.fri).dayOfWeek():(t=y(u.rank),e.every(t),n=h(e),x(u.start)?(t=y(u.rank),e.startingOn(t),w(n.type)):x(u.between)&&(r=y(u.rank),x(u.and)&&(a=y(u.rank),e.between(r,a))))}function m(e){x(u.first)?e.first():x(u.last)?e.last():e.on(v(u.rank)),h(e)}function h(e){var t=w([u.second,u.minute,u.hour,u.dayOfYear,u.dayOfWeek,u.dayInstance,u.day,u.month,u.year,u.weekOfMonth,u.weekOfYear]);switch(t.type){case u.second:e.second();break;case u.minute:e.minute();break;case u.hour:e.hour();break;case u.dayOfYear:e.dayOfYear();break;case u.dayOfWeek:e.dayOfWeek();break;case u.dayInstance:e.dayOfWeekCount();break;case u.day:e.dayOfMonth();break;case u.weekOfMonth:e.weekOfMonth();break;case u.weekOfYear:e.weekOfYear();break;case u.month:e.month();break;case u.year:e.year();break;default:n=a}return t}function x(e){var t=d(e).type===e;return t&&l(e),t}function w(e){var t=l(e);return t.type?t.text=function(e,t){var n=e;switch(t){case u.time:var r=e.split(/(:|am|pm)/),a=Number.parseInt(r[0],10),i=r[2].trim();"pm"===r[3]&&a<12?a+=12:"am"===r[3]&&12===a&&(a-=12),n=(1===(a=String(a)).length?"0":"")+a+":"+i;break;case u.rank:n=Number.parseInt(/^\d+/.exec(e)[0],10);break;case u.monthName:case u.dayName:n=o[e.slice(0,3)]}return n}(t.text,e):n=a,t}function y(e){return w(e).text}return function(e){a=0,i=e,n=-1;for(var t=r();a<i.length&&n<0;)switch(w([u.every,u.after,u.before,u.onthe,u.on,u.of,u.in,u.at,u.and,u.except,u.also]).type){case u.every:s(t);break;case u.after:void 0!==d(u.time).type?(t.after(y(u.time)),t.time()):(t.after(y(u.rank)),h(t));break;case u.before:void 0!==d(u.time).type?(t.before(y(u.time)),t.time()):(t.before(y(u.rank)),h(t));break;case u.onthe:m(t);break;case u.on:t.on(v(u.dayName)).dayOfWeek();break;case u.of:t.on(v(u.monthName)).month();break;case u.in:t.on(v(u.yearIndex)).year();break;case u.at:for(t.on(y(u.time)).time();x(u.and);)t.on(y(u.time)).time();break;case u.and:break;case u.also:t.and();break;case u.except:t.except();break;default:n=a}return{schedules:t.schedules,exceptions:t.exceptions,error:n}}(t.toLowerCase())},e})); |
{ | ||
"name": "@breejs/later", | ||
"description": "Maintained fork of later. Determine later (or previous) occurrences of recurring schedules", | ||
"version": "4.1.0", | ||
"version": "4.2.0", | ||
"author": "BunKat <bill@levelstory.com>", | ||
@@ -12,5 +12,5 @@ "bugs": { | ||
"BunKat <bill@levelstory.com>", | ||
"Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)" | ||
"Nick Baugh <niftylettuce@gmail.com> (http://niftylettuce.com/)", | ||
"yrambler2001 <yrambler2001@gmail.com> (https://yrambler2001.me/)" | ||
], | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -21,22 +21,22 @@ "@babel/cli": "^7.10.5", | ||
"@babel/preset-env": "^7.11.0", | ||
"@commitlint/cli": "latest", | ||
"@commitlint/config-conventional": "latest", | ||
"@commitlint/cli": "^18.4.3", | ||
"@commitlint/config-conventional": "^18.4.3", | ||
"babelify": "^10.0.0", | ||
"benchmark": "*", | ||
"benchmark": "^2.1.4", | ||
"browserify": "^16.5.2", | ||
"codecov": "latest", | ||
"cross-env": "latest", | ||
"cross-env": "^7.0.3", | ||
"eslint": "^7.7.0", | ||
"eslint-config-xo-lass": "latest", | ||
"eslint-config-xo-lass": "^2.0.1", | ||
"eslint-plugin-compat": "^3.8.0", | ||
"eslint-plugin-node": "^11.1.0", | ||
"fixpack": "latest", | ||
"husky": "latest", | ||
"lint-staged": "latest", | ||
"mocha": "*", | ||
"nyc": "latest", | ||
"remark-cli": "latest", | ||
"remark-preset-github": "latest", | ||
"fixpack": "^4.0.0", | ||
"husky": "^8.0.3", | ||
"lint-staged": "^15.1.0", | ||
"mocha": "^10.2.0", | ||
"nyc": "^15.1.0", | ||
"remark-cli": "11", | ||
"remark-preset-github": "^4.0.4", | ||
"rimraf": "^5.0.5", | ||
"semver": "^7.3.2", | ||
"should": ">=13.2.3", | ||
"should": "^13.2.3", | ||
"sinon": "^11.1.2", | ||
@@ -160,4 +160,4 @@ "tinyify": "^3.0.0", | ||
"build:lib": "babel --config-file ./.lib.babelrc src --out-dir lib", | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov", | ||
"lint": "yarn run lint:js && yarn run lint:md && yarn run lint:lib && yarn run lint:dist", | ||
"coverage": "nyc report --reporter=text-lcov > coverage.lcov", | ||
"lint": "npm run lint:js && npm run lint:md && npm run lint:lib && npm run lint:dist", | ||
"lint:dist": "eslint --no-inline-config -c .dist.eslintrc dist", | ||
@@ -169,5 +169,5 @@ "lint:js": "xo", | ||
"nyc": "cross-env NODE_ENV=test nyc mocha test/**/*-test.js --reporter dot", | ||
"pretest": "yarn run build && yarn run lint", | ||
"test": "cross-env NODE_ENV=test mocha test/**/*-test.js --reporter dot", | ||
"test-coverage": "cross-env NODE_ENV=test nyc yarn run test" | ||
"pretest": "npm run build && npm run lint", | ||
"test": "cross-env NODE_ENV=test mocha test/**/*-test.js --reporter dot --exit", | ||
"test-coverage": "cross-env NODE_ENV=test nyc npm run test" | ||
}, | ||
@@ -174,0 +174,0 @@ "unpkg": "dist/later.min.js", |
# @breejs/later | ||
[![build status](https://img.shields.io/travis/com/breejs/later.svg)](https://travis-ci.com/breejs/later) | ||
[![build status](https://github.com/breejs/later/actions/workflows/ci.yml/badge.svg)](https://github.com/breejs/later/actions/workflows/ci.yml) | ||
[![code coverage](https://img.shields.io/codecov/c/github/breejs/later.svg)](https://codecov.io/gh/breejs/later) | ||
@@ -28,3 +28,3 @@ [![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo) | ||
Types of schedules supported by _Later_: | ||
Types of schedules supported by *Later*: | ||
@@ -50,9 +50,3 @@ * Run a report on the last day of every month at 12 AM except in December | ||
[yarn][]: | ||
```sh | ||
yarn add @breejs/later | ||
``` | ||
## Usage | ||
@@ -90,6 +84,7 @@ | ||
| Name | Website | | ||
| -------------- | -------------------------- | | ||
| **BunKat** | | | ||
| **Nick Baugh** | <http://niftylettuce.com/> | | ||
| Name | Website | | ||
| ---------------- | -------------------------- | | ||
| **BunKat** | | | ||
| **Nick Baugh** | <http://niftylettuce.com/> | | ||
| **yrambler2001** | <https://yrambler2001.me/> | | ||
@@ -102,8 +97,6 @@ | ||
## | ||
## | ||
[npm]: https://www.npmjs.com/ | ||
[yarn]: https://yarnpkg.com/ | ||
[browserify]: https://github.com/browserify/browserify | ||
@@ -110,0 +103,0 @@ |
Sorry, the diff of this file is too big to display
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
470953
7
3543
105