cronstrue
Advanced tools
Comparing version 0.9.3 to 0.10.0
@@ -0,0 +0,0 @@ export declare class CronParser { |
import { ExpressionDescriptor } from "./expressionDescriptor"; | ||
export = ExpressionDescriptor; |
import { ExpressionDescriptor } from "./expressionDescriptor"; | ||
export = ExpressionDescriptor; | ||
export default ExpressionDescriptor; | ||
declare let toString: typeof ExpressionDescriptor.toString; | ||
export { toString }; |
@@ -14,39 +14,65 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/******/ var installedModules = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ | ||
/******/ // Check if module is in cache | ||
/******/ if(installedModules[moduleId]) | ||
/******/ return installedModules[moduleId].exports; | ||
/******/ | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = installedModules[moduleId] = { | ||
/******/ exports: {}, | ||
/******/ id: moduleId, | ||
/******/ loaded: false | ||
/******/ i: moduleId, | ||
/******/ l: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ module.l = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = modules; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = installedModules; | ||
/******/ | ||
/******/ // identity function for calling harmony imports with the correct context | ||
/******/ __webpack_require__.i = function(value) { return value; }; | ||
/******/ | ||
/******/ // define getter function for harmony exports | ||
/******/ __webpack_require__.d = function(exports, name, getter) { | ||
/******/ if(!__webpack_require__.o(exports, name)) { | ||
/******/ Object.defineProperty(exports, name, { | ||
/******/ configurable: false, | ||
/******/ enumerable: true, | ||
/******/ get: getter | ||
/******/ }); | ||
/******/ } | ||
/******/ }; | ||
/******/ | ||
/******/ // getDefaultExport function for compatibility with non-harmony modules | ||
/******/ __webpack_require__.n = function(module) { | ||
/******/ var getter = module && module.__esModule ? | ||
/******/ function getDefault() { return module['default']; } : | ||
/******/ function getModuleExports() { return module; }; | ||
/******/ __webpack_require__.d(getter, 'a', getter); | ||
/******/ return getter; | ||
/******/ }; | ||
/******/ | ||
/******/ // Object.prototype.hasOwnProperty.call | ||
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; | ||
/******/ | ||
/******/ // __webpack_public_path__ | ||
/******/ __webpack_require__.p = ""; | ||
/******/ | ||
/******/ // Load entry module and return exports | ||
/******/ return __webpack_require__(0); | ||
/******/ return __webpack_require__(__webpack_require__.s = 7); | ||
/******/ }) | ||
@@ -56,716 +82,731 @@ /************************************************************************/ | ||
/* 0 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var expressionDescriptor_1 = __webpack_require__(1); | ||
var enLocaleLoader_1 = __webpack_require__(4); | ||
expressionDescriptor_1.ExpressionDescriptor.initialize(new enLocaleLoader_1.enLocaleLoader()); | ||
module.exports = expressionDescriptor_1.ExpressionDescriptor; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var stringUtilities_1 = __webpack_require__(3); | ||
var cronParser_1 = __webpack_require__(1); | ||
var ExpressionDescriptor = (function () { | ||
function ExpressionDescriptor(expression, options) { | ||
this.expression = expression; | ||
this.options = options; | ||
this.expressionParts = new Array(5); | ||
if (ExpressionDescriptor.locales[options.locale]) { | ||
this.i18n = ExpressionDescriptor.locales[options.locale]; | ||
} | ||
else { | ||
console.warn("Locale '" + options.locale + "' could not be found; falling back to 'en'."); | ||
this.i18n = ExpressionDescriptor.locales["en"]; | ||
} | ||
if (options.use24HourTimeFormat === undefined) { | ||
options.use24HourTimeFormat = this.i18n.use24HourTimeFormatByDefault(); | ||
} | ||
} | ||
ExpressionDescriptor.toString = function (expression, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.throwExceptionOnParseError, throwExceptionOnParseError = _c === void 0 ? true : _c, _d = _b.verbose, verbose = _d === void 0 ? false : _d, _e = _b.dayOfWeekStartIndexZero, dayOfWeekStartIndexZero = _e === void 0 ? true : _e, use24HourTimeFormat = _b.use24HourTimeFormat, _f = _b.locale, locale = _f === void 0 ? "en" : _f; | ||
var options = { | ||
throwExceptionOnParseError: throwExceptionOnParseError, | ||
verbose: verbose, | ||
dayOfWeekStartIndexZero: dayOfWeekStartIndexZero, | ||
use24HourTimeFormat: use24HourTimeFormat, | ||
locale: locale | ||
}; | ||
var descripter = new ExpressionDescriptor(expression, options); | ||
return descripter.getFullDescription(); | ||
}; | ||
ExpressionDescriptor.initialize = function (localesLoader) { | ||
ExpressionDescriptor.specialCharacters = ["/", "-", ",", "*"]; | ||
localesLoader.load(ExpressionDescriptor.locales); | ||
}; | ||
ExpressionDescriptor.prototype.getFullDescription = function () { | ||
var description = ""; | ||
try { | ||
var parser = new cronParser_1.CronParser(this.expression, this.options.dayOfWeekStartIndexZero); | ||
this.expressionParts = parser.parse(); | ||
var timeSegment = this.getTimeOfDayDescription(); | ||
var dayOfMonthDesc = this.getDayOfMonthDescription(); | ||
var monthDesc = this.getMonthDescription(); | ||
var dayOfWeekDesc = this.getDayOfWeekDescription(); | ||
var yearDesc = this.getYearDescription(); | ||
description += (timeSegment + dayOfMonthDesc + dayOfWeekDesc + monthDesc + yearDesc); | ||
description = this.transformVerbosity(description, this.options.verbose); | ||
description = description.charAt(0).toLocaleUpperCase() + description.substr(1); | ||
} | ||
catch (ex) { | ||
if (!this.options.throwExceptionOnParseError) { | ||
description = this.i18n.anErrorOccuredWhenGeneratingTheExpressionD(); | ||
} | ||
else { | ||
throw "" + ex; | ||
} | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getTimeOfDayDescription = function () { | ||
var secondsExpression = this.expressionParts[0]; | ||
var minuteExpression = this.expressionParts[1]; | ||
var hourExpression = this.expressionParts[2]; | ||
var description = ""; | ||
if (!stringUtilities_1.StringUtilities.containsAny(minuteExpression, ExpressionDescriptor.specialCharacters) | ||
&& !stringUtilities_1.StringUtilities.containsAny(hourExpression, ExpressionDescriptor.specialCharacters) | ||
&& !stringUtilities_1.StringUtilities.containsAny(secondsExpression, ExpressionDescriptor.specialCharacters)) { | ||
description += this.i18n.atSpace() + this.formatTime(hourExpression, minuteExpression, secondsExpression); | ||
} | ||
else if (minuteExpression.indexOf("-") > -1 | ||
&& !(minuteExpression.indexOf(",") > -1) | ||
&& !stringUtilities_1.StringUtilities.containsAny(hourExpression, ExpressionDescriptor.specialCharacters)) { | ||
var minuteParts = minuteExpression.split("-"); | ||
description += stringUtilities_1.StringUtilities.format(this.i18n.everyMinutebetweenX0AndX1(), this.formatTime(hourExpression, minuteParts[0], ""), this.formatTime(hourExpression, minuteParts[1], "")); | ||
} | ||
else if (hourExpression.indexOf(",") > -1 | ||
&& hourExpression.indexOf("-") == -1 | ||
&& !stringUtilities_1.StringUtilities.containsAny(minuteExpression, ExpressionDescriptor.specialCharacters)) { | ||
var hourParts = hourExpression.split(","); | ||
description += this.i18n.at(); | ||
for (var i = 0; i < hourParts.length; i++) { | ||
description += " "; | ||
description += this.formatTime(hourParts[i], minuteExpression, ""); | ||
if (i < (hourParts.length - 2)) { | ||
description += ","; | ||
} | ||
if (i == hourParts.length - 2) { | ||
description += this.i18n.spaceAnd(); | ||
} | ||
} | ||
} | ||
else { | ||
var secondsDescription = this.getSecondsDescription(); | ||
var minutesDescription = this.getMinutesDescription(); | ||
var hoursDescription = this.getHoursDescription(); | ||
description += secondsDescription; | ||
if (description.length > 0) { | ||
description += ", "; | ||
} | ||
description += minutesDescription; | ||
if (description.length > 0) { | ||
description += ", "; | ||
} | ||
description += hoursDescription; | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getSecondsDescription = function () { | ||
var _this = this; | ||
var description = this.getSegmentDescription(this.expressionParts[0], this.i18n.everysecond(), function (s) { return s; }, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Seconds(), s); }, function (s) { return _this.i18n.secondsX0ThroughX1PastTheMinute(); }, function (s) { | ||
return s == "0" ? "" : parseInt(s) < 20 | ||
? _this.i18n.atX0SecondsPastTheMinute() | ||
: _this.i18n.atX0SecondsPastTheMinuteGt20() || _this.i18n.atX0SecondsPastTheMinute(); | ||
}); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getMinutesDescription = function () { | ||
var _this = this; | ||
var description = this.getSegmentDescription(this.expressionParts[1], this.i18n.everyMinute(), function (s) { return s; }, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Minutes(), s); }, function (s) { return _this.i18n.minutesX0ThroughX1PastTheHour(); }, function (s) { | ||
try { | ||
return s == "0" ? "" : parseInt(s) < 20 | ||
? _this.i18n.atX0MinutesPastTheHour() | ||
: _this.i18n.atX0MinutesPastTheHourGt20() || _this.i18n.atX0MinutesPastTheHour(); | ||
} | ||
catch (e) { | ||
return _this.i18n.atX0MinutesPastTheHour(); | ||
} | ||
}); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getHoursDescription = function () { | ||
var _this = this; | ||
var expression = this.expressionParts[2]; | ||
var description = this.getSegmentDescription(expression, this.i18n.everyHour(), function (s) { return _this.formatTime(s, "0", ""); }, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Hours(), s); }, function (s) { return _this.i18n.betweenX0AndX1(); }, function (s) { return _this.i18n.atX0(); }); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getDayOfWeekDescription = function () { | ||
var _this = this; | ||
var daysOfWeekNames = this.i18n.daysOfTheWeek(); | ||
var description = null; | ||
if (this.expressionParts[5] == "*" && this.expressionParts[3] != "*") { | ||
description = ""; | ||
} | ||
else { | ||
description = this.getSegmentDescription(this.expressionParts[5], this.i18n.commaEveryDay(), function (s) { | ||
var exp = s; | ||
if (s.indexOf("#") > -1) { | ||
exp = s.substr(0, s.indexOf("#")); | ||
} | ||
else if (s.indexOf("L") > -1) { | ||
exp = exp.replace("L", ""); | ||
} | ||
return daysOfWeekNames[parseInt(exp)]; | ||
}, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0daysOfTheWeek(), s); }, function (s) { return _this.i18n.commaX0ThroughX1(); }, function (s) { | ||
var format = null; | ||
if (s.indexOf("#") > -1) { | ||
var dayOfWeekOfMonthNumber = s.substring(s.indexOf("#") + 1); | ||
var dayOfWeekOfMonthDescription = null; | ||
switch (dayOfWeekOfMonthNumber) { | ||
case "1": | ||
dayOfWeekOfMonthDescription = _this.i18n.first(); | ||
break; | ||
case "2": | ||
dayOfWeekOfMonthDescription = _this.i18n.second(); | ||
break; | ||
case "3": | ||
dayOfWeekOfMonthDescription = _this.i18n.third(); | ||
break; | ||
case "4": | ||
dayOfWeekOfMonthDescription = _this.i18n.forth(); | ||
break; | ||
case "5": | ||
dayOfWeekOfMonthDescription = _this.i18n.fifth(); | ||
break; | ||
} | ||
format = _this.i18n.commaOnThe() + dayOfWeekOfMonthDescription + _this.i18n.spaceX0OfTheMonth(); | ||
} | ||
else if (s.indexOf("L") > -1) { | ||
format = _this.i18n.commaOnTheLastX0OfTheMonth(); | ||
} | ||
else { | ||
format = _this.i18n.commaOnlyOnX0(); | ||
} | ||
return format; | ||
}); | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getMonthDescription = function () { | ||
var _this = this; | ||
var monthNames = this.i18n.monthsOfTheYear(); | ||
var description = this.getSegmentDescription(this.expressionParts[4], "", function (s) { return monthNames[(parseInt(s) - 1)]; }, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0Months(), s); }, function (s) { return _this.i18n.commaMonthX0ThroughMonthX1() || _this.i18n.commaX0ThroughX1(); }, function (s) { return _this.i18n.commaOnlyInX0(); }); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getDayOfMonthDescription = function () { | ||
var _this = this; | ||
var description = null; | ||
var expression = this.expressionParts[3]; | ||
switch (expression) { | ||
case "L": | ||
description = this.i18n.commaOnTheLastDayOfTheMonth(); | ||
break; | ||
case "WL": | ||
case "LW": | ||
description = this.i18n.commaOnTheLastWeekdayOfTheMonth(); | ||
break; | ||
default: | ||
var matches = expression.match(/(\d{1,2}W)|(W\d{1,2})/); | ||
if (matches) { | ||
var dayNumber = parseInt(matches[0].replace("W", "")); | ||
var dayString = dayNumber == 1 ? this.i18n.firstWeekday() : | ||
stringUtilities_1.StringUtilities.format(this.i18n.weekdayNearestDayX0(), dayNumber.toString()); | ||
description = stringUtilities_1.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(), dayString); | ||
break; | ||
} | ||
else { | ||
description = this.getSegmentDescription(expression, this.i18n.commaEveryDay(), function (s) { return s; }, function (s) { | ||
return s == "1" ? _this.i18n.commaEveryDay() : | ||
_this.i18n.commaEveryX0Days(); | ||
}, function (s) { return _this.i18n.commaBetweenDayX0AndX1OfTheMonth(); }, function (s) { return _this.i18n.commaOnDayX0OfTheMonth(); }); | ||
break; | ||
} | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getYearDescription = function () { | ||
var _this = this; | ||
var description = this.getSegmentDescription(this.expressionParts[6], "", function (s) { return /^\d+$/.test(s) ? new Date(parseInt(s), 1).getFullYear().toString() : s; }, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0Years(), s); }, function (s) { return _this.i18n.commaYearX0ThroughYearX1() || _this.i18n.commaX0ThroughX1(); }, function (s) { return _this.i18n.commaOnlyInX0(); }); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getSegmentDescription = function (expression, allDescription, getSingleItemDescription, getIntervalDescriptionFormat, getBetweenDescriptionFormat, getDescriptionFormat) { | ||
var _this = this; | ||
var description = null; | ||
if (!expression) { | ||
description = ""; | ||
} | ||
else if (expression === "*") { | ||
description = allDescription; | ||
} | ||
else if (!stringUtilities_1.StringUtilities.containsAny(expression, ["/", "-", ","])) { | ||
description = stringUtilities_1.StringUtilities.format(getDescriptionFormat(expression), getSingleItemDescription(expression)); | ||
} | ||
else if (expression.indexOf("/") > -1) { | ||
var segments = expression.split("/"); | ||
description = stringUtilities_1.StringUtilities.format(getIntervalDescriptionFormat(segments[1]), getSingleItemDescription(segments[1])); | ||
if (segments[0].indexOf("-") > -1) { | ||
var betweenSegmentDescription = this.generateBetweenSegmentDescription(segments[0], getBetweenDescriptionFormat, getSingleItemDescription); | ||
if (betweenSegmentDescription.indexOf(", ") != 0) { | ||
description += ", "; | ||
} | ||
description += betweenSegmentDescription; | ||
} | ||
else if (!stringUtilities_1.StringUtilities.containsAny(segments[0], ["*", ","])) { | ||
var rangeItemDescription = stringUtilities_1.StringUtilities.format(getDescriptionFormat(segments[0]), getSingleItemDescription(segments[0])); | ||
rangeItemDescription = rangeItemDescription.replace(", ", ""); | ||
description += stringUtilities_1.StringUtilities.format(this.i18n.commaStartingX0(), rangeItemDescription); | ||
} | ||
} | ||
else if (expression.indexOf(",") > -1) { | ||
var segments = expression.split(','); | ||
var descriptionContent = ""; | ||
for (var i = 0; i < segments.length; i++) { | ||
if (i > 0 && segments.length > 2) { | ||
descriptionContent += ","; | ||
if (i < segments.length - 1) { | ||
descriptionContent += " "; | ||
} | ||
} | ||
if (i > 0 && segments.length > 1 && (i == segments.length - 1 || segments.length == 2)) { | ||
descriptionContent += this.i18n.spaceAndSpace(); | ||
} | ||
if (segments[i].indexOf("-") > -1) { | ||
var betweenSegmentDescription = this.generateBetweenSegmentDescription(segments[i], (function (s) { return _this.i18n.commaX0ThroughX1(); }), getSingleItemDescription); | ||
betweenSegmentDescription = betweenSegmentDescription.replace(", ", ""); | ||
descriptionContent += betweenSegmentDescription; | ||
} | ||
else { | ||
descriptionContent += getSingleItemDescription(segments[i]); | ||
} | ||
} | ||
description = stringUtilities_1.StringUtilities.format(getDescriptionFormat(expression), descriptionContent); | ||
} | ||
else if (expression.indexOf("-") > -1) { | ||
description = this.generateBetweenSegmentDescription(expression, getBetweenDescriptionFormat, getSingleItemDescription); | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.generateBetweenSegmentDescription = function (betweenExpression, getBetweenDescriptionFormat, getSingleItemDescription) { | ||
var description = ""; | ||
var betweenSegments = betweenExpression.split('-'); | ||
var betweenSegment1Description = getSingleItemDescription(betweenSegments[0]); | ||
var betweenSegment2Description = getSingleItemDescription(betweenSegments[1]); | ||
betweenSegment2Description = betweenSegment2Description.replace(":00", ":59"); | ||
var betweenDescriptionFormat = getBetweenDescriptionFormat(betweenExpression); | ||
description += stringUtilities_1.StringUtilities.format(betweenDescriptionFormat, betweenSegment1Description, betweenSegment2Description); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.formatTime = function (hourExpression, minuteExpression, secondExpression) { | ||
var hour = parseInt(hourExpression); | ||
var period = ""; | ||
if (!this.options.use24HourTimeFormat) { | ||
period = (hour >= 12) ? " PM" : " AM"; | ||
if (hour > 12) { | ||
hour -= 12; | ||
} | ||
} | ||
var minute = minuteExpression; | ||
var second = ""; | ||
if (secondExpression) { | ||
second = ":" + ("00" + secondExpression).substring(secondExpression.length); | ||
} | ||
return ("00" + hour.toString()).substring(hour.toString().length) + ":" + ("00" + minute.toString()).substring(minute.toString().length) + second + period; | ||
}; | ||
ExpressionDescriptor.prototype.transformVerbosity = function (description, useVerboseFormat) { | ||
if (!useVerboseFormat) { | ||
description = description.replace(new RegExp(this.i18n.commaEveryMinute(), 'g'), ""); | ||
description = description.replace(new RegExp(this.i18n.commaEveryHour(), 'g'), ""); | ||
description = description.replace(new RegExp(this.i18n.commaEveryDay(), 'g'), ""); | ||
} | ||
return description; | ||
}; | ||
return ExpressionDescriptor; | ||
}()); | ||
ExpressionDescriptor.locales = {}; | ||
exports.ExpressionDescriptor = ExpressionDescriptor; | ||
/***/ }, | ||
/***/ }), | ||
/* 1 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var stringUtilities_1 = __webpack_require__(2); | ||
var cronParser_1 = __webpack_require__(3); | ||
var ExpressionDescriptor = (function () { | ||
function ExpressionDescriptor(expression, options) { | ||
this.expression = expression; | ||
this.options = options; | ||
this.expressionParts = new Array(5); | ||
if (ExpressionDescriptor.locales[options.locale]) { | ||
this.i18n = ExpressionDescriptor.locales[options.locale]; | ||
} | ||
else { | ||
console.warn("Locale '" + options.locale + "' could not be found; falling back to 'en'."); | ||
this.i18n = ExpressionDescriptor.locales["en"]; | ||
} | ||
if (options.use24HourTimeFormat === undefined) { | ||
options.use24HourTimeFormat = this.i18n.use24HourTimeFormatByDefault(); | ||
} | ||
} | ||
ExpressionDescriptor.toString = function (expression, _a) { | ||
var _b = _a === void 0 ? {} : _a, _c = _b.throwExceptionOnParseError, throwExceptionOnParseError = _c === void 0 ? true : _c, _d = _b.verbose, verbose = _d === void 0 ? false : _d, _e = _b.dayOfWeekStartIndexZero, dayOfWeekStartIndexZero = _e === void 0 ? true : _e, use24HourTimeFormat = _b.use24HourTimeFormat, _f = _b.locale, locale = _f === void 0 ? "en" : _f; | ||
var options = { | ||
throwExceptionOnParseError: throwExceptionOnParseError, | ||
verbose: verbose, | ||
dayOfWeekStartIndexZero: dayOfWeekStartIndexZero, | ||
use24HourTimeFormat: use24HourTimeFormat, | ||
locale: locale | ||
}; | ||
var descripter = new ExpressionDescriptor(expression, options); | ||
return descripter.getFullDescription(); | ||
}; | ||
ExpressionDescriptor.initialize = function (localesLoader) { | ||
ExpressionDescriptor.specialCharacters = ["/", "-", ",", "*"]; | ||
localesLoader.load(ExpressionDescriptor.locales); | ||
}; | ||
ExpressionDescriptor.prototype.getFullDescription = function () { | ||
var description = ""; | ||
try { | ||
var parser = new cronParser_1.CronParser(this.expression, this.options.dayOfWeekStartIndexZero); | ||
this.expressionParts = parser.parse(); | ||
var timeSegment = this.getTimeOfDayDescription(); | ||
var dayOfMonthDesc = this.getDayOfMonthDescription(); | ||
var monthDesc = this.getMonthDescription(); | ||
var dayOfWeekDesc = this.getDayOfWeekDescription(); | ||
var yearDesc = this.getYearDescription(); | ||
description += (timeSegment + dayOfMonthDesc + dayOfWeekDesc + monthDesc + yearDesc); | ||
description = this.transformVerbosity(description, this.options.verbose); | ||
description = description.charAt(0).toLocaleUpperCase() + description.substr(1); | ||
} | ||
catch (ex) { | ||
if (!this.options.throwExceptionOnParseError) { | ||
description = this.i18n.anErrorOccuredWhenGeneratingTheExpressionD(); | ||
} | ||
else { | ||
throw "" + ex; | ||
} | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getTimeOfDayDescription = function () { | ||
var secondsExpression = this.expressionParts[0]; | ||
var minuteExpression = this.expressionParts[1]; | ||
var hourExpression = this.expressionParts[2]; | ||
var description = ""; | ||
if (!stringUtilities_1.StringUtilities.containsAny(minuteExpression, ExpressionDescriptor.specialCharacters) | ||
&& !stringUtilities_1.StringUtilities.containsAny(hourExpression, ExpressionDescriptor.specialCharacters) | ||
&& !stringUtilities_1.StringUtilities.containsAny(secondsExpression, ExpressionDescriptor.specialCharacters)) { | ||
description += this.i18n.atSpace() + this.formatTime(hourExpression, minuteExpression, secondsExpression); | ||
} | ||
else if (minuteExpression.indexOf("-") > -1 | ||
&& !(minuteExpression.indexOf(",") > -1) | ||
&& !stringUtilities_1.StringUtilities.containsAny(hourExpression, ExpressionDescriptor.specialCharacters)) { | ||
var minuteParts = minuteExpression.split("-"); | ||
description += stringUtilities_1.StringUtilities.format(this.i18n.everyMinutebetweenX0AndX1(), this.formatTime(hourExpression, minuteParts[0], ""), this.formatTime(hourExpression, minuteParts[1], "")); | ||
} | ||
else if (hourExpression.indexOf(",") > -1 | ||
&& hourExpression.indexOf("-") == -1 | ||
&& !stringUtilities_1.StringUtilities.containsAny(minuteExpression, ExpressionDescriptor.specialCharacters)) { | ||
var hourParts = hourExpression.split(","); | ||
description += this.i18n.at(); | ||
for (var i = 0; i < hourParts.length; i++) { | ||
description += " "; | ||
description += this.formatTime(hourParts[i], minuteExpression, ""); | ||
if (i < (hourParts.length - 2)) { | ||
description += ","; | ||
} | ||
if (i == hourParts.length - 2) { | ||
description += this.i18n.spaceAnd(); | ||
} | ||
} | ||
} | ||
else { | ||
var secondsDescription = this.getSecondsDescription(); | ||
var minutesDescription = this.getMinutesDescription(); | ||
var hoursDescription = this.getHoursDescription(); | ||
description += secondsDescription; | ||
if (description.length > 0) { | ||
description += ", "; | ||
} | ||
description += minutesDescription; | ||
if (description.length > 0) { | ||
description += ", "; | ||
} | ||
description += hoursDescription; | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getSecondsDescription = function () { | ||
var _this = this; | ||
var description = this.getSegmentDescription(this.expressionParts[0], this.i18n.everysecond(), function (s) { return s; }, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Seconds(), s); }, function (s) { return _this.i18n.secondsX0ThroughX1PastTheMinute(); }, function (s) { | ||
return s == "0" ? "" : parseInt(s) < 20 | ||
? _this.i18n.atX0SecondsPastTheMinute() | ||
: _this.i18n.atX0SecondsPastTheMinuteGt20() || _this.i18n.atX0SecondsPastTheMinute(); | ||
}); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getMinutesDescription = function () { | ||
var _this = this; | ||
var description = this.getSegmentDescription(this.expressionParts[1], this.i18n.everyMinute(), function (s) { return s; }, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Minutes(), s); }, function (s) { return _this.i18n.minutesX0ThroughX1PastTheHour(); }, function (s) { | ||
try { | ||
return s == "0" ? "" : parseInt(s) < 20 | ||
? _this.i18n.atX0MinutesPastTheHour() | ||
: _this.i18n.atX0MinutesPastTheHourGt20() || _this.i18n.atX0MinutesPastTheHour(); | ||
} | ||
catch (e) { | ||
return _this.i18n.atX0MinutesPastTheHour(); | ||
} | ||
}); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getHoursDescription = function () { | ||
var _this = this; | ||
var expression = this.expressionParts[2]; | ||
var description = this.getSegmentDescription(expression, this.i18n.everyHour(), function (s) { return _this.formatTime(s, "0", ""); }, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Hours(), s); }, function (s) { return _this.i18n.betweenX0AndX1(); }, function (s) { return _this.i18n.atX0(); }); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getDayOfWeekDescription = function () { | ||
var _this = this; | ||
var daysOfWeekNames = this.i18n.daysOfTheWeek(); | ||
var description = null; | ||
if (this.expressionParts[5] == "*" && this.expressionParts[3] != "*") { | ||
description = ""; | ||
} | ||
else { | ||
description = this.getSegmentDescription(this.expressionParts[5], this.i18n.commaEveryDay(), function (s) { | ||
var exp = s; | ||
if (s.indexOf("#") > -1) { | ||
exp = s.substr(0, s.indexOf("#")); | ||
} | ||
else if (s.indexOf("L") > -1) { | ||
exp = exp.replace("L", ""); | ||
} | ||
return daysOfWeekNames[parseInt(exp)]; | ||
}, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0daysOfTheWeek(), s); }, function (s) { return _this.i18n.commaX0ThroughX1(); }, function (s) { | ||
var format = null; | ||
if (s.indexOf("#") > -1) { | ||
var dayOfWeekOfMonthNumber = s.substring(s.indexOf("#") + 1); | ||
var dayOfWeekOfMonthDescription = null; | ||
switch (dayOfWeekOfMonthNumber) { | ||
case "1": | ||
dayOfWeekOfMonthDescription = _this.i18n.first(); | ||
break; | ||
case "2": | ||
dayOfWeekOfMonthDescription = _this.i18n.second(); | ||
break; | ||
case "3": | ||
dayOfWeekOfMonthDescription = _this.i18n.third(); | ||
break; | ||
case "4": | ||
dayOfWeekOfMonthDescription = _this.i18n.forth(); | ||
break; | ||
case "5": | ||
dayOfWeekOfMonthDescription = _this.i18n.fifth(); | ||
break; | ||
} | ||
format = _this.i18n.commaOnThe() + dayOfWeekOfMonthDescription + _this.i18n.spaceX0OfTheMonth(); | ||
} | ||
else if (s.indexOf("L") > -1) { | ||
format = _this.i18n.commaOnTheLastX0OfTheMonth(); | ||
} | ||
else { | ||
format = _this.i18n.commaOnlyOnX0(); | ||
} | ||
return format; | ||
}); | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getMonthDescription = function () { | ||
var _this = this; | ||
var monthNames = this.i18n.monthsOfTheYear(); | ||
var description = this.getSegmentDescription(this.expressionParts[4], "", function (s) { return monthNames[(parseInt(s) - 1)]; }, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0Months(), s); }, function (s) { return _this.i18n.commaMonthX0ThroughMonthX1() || _this.i18n.commaX0ThroughX1(); }, function (s) { return _this.i18n.commaOnlyInX0(); }); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getDayOfMonthDescription = function () { | ||
var _this = this; | ||
var description = null; | ||
var expression = this.expressionParts[3]; | ||
switch (expression) { | ||
case "L": | ||
description = this.i18n.commaOnTheLastDayOfTheMonth(); | ||
break; | ||
case "WL": | ||
case "LW": | ||
description = this.i18n.commaOnTheLastWeekdayOfTheMonth(); | ||
break; | ||
default: | ||
var matches = expression.match(/(\d{1,2}W)|(W\d{1,2})/); | ||
if (matches) { | ||
var dayNumber = parseInt(matches[0].replace("W", "")); | ||
var dayString = dayNumber == 1 ? this.i18n.firstWeekday() : | ||
stringUtilities_1.StringUtilities.format(this.i18n.weekdayNearestDayX0(), dayNumber.toString()); | ||
description = stringUtilities_1.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(), dayString); | ||
break; | ||
} | ||
else { | ||
description = this.getSegmentDescription(expression, this.i18n.commaEveryDay(), function (s) { return s; }, function (s) { | ||
return s == "1" ? _this.i18n.commaEveryDay() : | ||
_this.i18n.commaEveryX0Days(); | ||
}, function (s) { return _this.i18n.commaBetweenDayX0AndX1OfTheMonth(); }, function (s) { return _this.i18n.commaOnDayX0OfTheMonth(); }); | ||
break; | ||
} | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getYearDescription = function () { | ||
var _this = this; | ||
var description = this.getSegmentDescription(this.expressionParts[6], "", function (s) { return /^\d+$/.test(s) ? new Date(parseInt(s), 1).getFullYear().toString() : s; }, function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0Years(), s); }, function (s) { return _this.i18n.commaYearX0ThroughYearX1() || _this.i18n.commaX0ThroughX1(); }, function (s) { return _this.i18n.commaOnlyInX0(); }); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.getSegmentDescription = function (expression, allDescription, getSingleItemDescription, getIntervalDescriptionFormat, getBetweenDescriptionFormat, getDescriptionFormat) { | ||
var _this = this; | ||
var description = null; | ||
if (!expression) { | ||
description = ""; | ||
} | ||
else if (expression === "*") { | ||
description = allDescription; | ||
} | ||
else if (!stringUtilities_1.StringUtilities.containsAny(expression, ["/", "-", ","])) { | ||
description = stringUtilities_1.StringUtilities.format(getDescriptionFormat(expression), getSingleItemDescription(expression)); | ||
} | ||
else if (expression.indexOf("/") > -1) { | ||
var segments = expression.split("/"); | ||
description = stringUtilities_1.StringUtilities.format(getIntervalDescriptionFormat(segments[1]), getSingleItemDescription(segments[1])); | ||
if (segments[0].indexOf("-") > -1) { | ||
var betweenSegmentDescription = this.generateBetweenSegmentDescription(segments[0], getBetweenDescriptionFormat, getSingleItemDescription); | ||
if (betweenSegmentDescription.indexOf(", ") != 0) { | ||
description += ", "; | ||
} | ||
description += betweenSegmentDescription; | ||
} | ||
else if (!stringUtilities_1.StringUtilities.containsAny(segments[0], ["*", ","])) { | ||
var rangeItemDescription = stringUtilities_1.StringUtilities.format(getDescriptionFormat(segments[0]), getSingleItemDescription(segments[0])); | ||
rangeItemDescription = rangeItemDescription.replace(", ", ""); | ||
description += stringUtilities_1.StringUtilities.format(this.i18n.commaStartingX0(), rangeItemDescription); | ||
} | ||
} | ||
else if (expression.indexOf(",") > -1) { | ||
var segments = expression.split(','); | ||
var descriptionContent = ""; | ||
for (var i = 0; i < segments.length; i++) { | ||
if (i > 0 && segments.length > 2) { | ||
descriptionContent += ","; | ||
if (i < segments.length - 1) { | ||
descriptionContent += " "; | ||
} | ||
} | ||
if (i > 0 && segments.length > 1 && (i == segments.length - 1 || segments.length == 2)) { | ||
descriptionContent += this.i18n.spaceAndSpace(); | ||
} | ||
if (segments[i].indexOf("-") > -1) { | ||
var betweenSegmentDescription = this.generateBetweenSegmentDescription(segments[i], (function (s) { return _this.i18n.commaX0ThroughX1(); }), getSingleItemDescription); | ||
betweenSegmentDescription = betweenSegmentDescription.replace(", ", ""); | ||
descriptionContent += betweenSegmentDescription; | ||
} | ||
else { | ||
descriptionContent += getSingleItemDescription(segments[i]); | ||
} | ||
} | ||
description = stringUtilities_1.StringUtilities.format(getDescriptionFormat(expression), descriptionContent); | ||
} | ||
else if (expression.indexOf("-") > -1) { | ||
description = this.generateBetweenSegmentDescription(expression, getBetweenDescriptionFormat, getSingleItemDescription); | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.generateBetweenSegmentDescription = function (betweenExpression, getBetweenDescriptionFormat, getSingleItemDescription) { | ||
var description = ""; | ||
var betweenSegments = betweenExpression.split('-'); | ||
var betweenSegment1Description = getSingleItemDescription(betweenSegments[0]); | ||
var betweenSegment2Description = getSingleItemDescription(betweenSegments[1]); | ||
betweenSegment2Description = betweenSegment2Description.replace(":00", ":59"); | ||
var betweenDescriptionFormat = getBetweenDescriptionFormat(betweenExpression); | ||
description += stringUtilities_1.StringUtilities.format(betweenDescriptionFormat, betweenSegment1Description, betweenSegment2Description); | ||
return description; | ||
}; | ||
ExpressionDescriptor.prototype.formatTime = function (hourExpression, minuteExpression, secondExpression) { | ||
var hour = parseInt(hourExpression); | ||
var period = ""; | ||
if (!this.options.use24HourTimeFormat) { | ||
period = (hour >= 12) ? " PM" : " AM"; | ||
if (hour > 12) { | ||
hour -= 12; | ||
} | ||
} | ||
var minute = minuteExpression; | ||
var second = ""; | ||
if (secondExpression) { | ||
second = ":" + ("00" + secondExpression).substring(secondExpression.length); | ||
} | ||
return ("00" + hour.toString()).substring(hour.toString().length) + ":" + ("00" + minute.toString()).substring(minute.toString().length) + second + period; | ||
}; | ||
ExpressionDescriptor.prototype.transformVerbosity = function (description, useVerboseFormat) { | ||
if (!useVerboseFormat) { | ||
description = description.replace(new RegExp(this.i18n.commaEveryMinute(), 'g'), ""); | ||
description = description.replace(new RegExp(this.i18n.commaEveryHour(), 'g'), ""); | ||
description = description.replace(new RegExp(this.i18n.commaEveryDay(), 'g'), ""); | ||
} | ||
return description; | ||
}; | ||
ExpressionDescriptor.locales = {}; | ||
return ExpressionDescriptor; | ||
}()); | ||
exports.ExpressionDescriptor = ExpressionDescriptor; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var CronParser = (function () { | ||
function CronParser(expression, dayOfWeekStartIndexZero) { | ||
if (dayOfWeekStartIndexZero === void 0) { dayOfWeekStartIndexZero = true; } | ||
this.expression = expression; | ||
this.dayOfWeekStartIndexZero = dayOfWeekStartIndexZero; | ||
} | ||
CronParser.prototype.parse = function () { | ||
if (!this.expression) { | ||
throw new Error("Expression is empty"); | ||
} | ||
var parsed = this.expression.trim().split(' '); | ||
if (parsed.length < 5) { | ||
throw new Error("Expression only has " + parsed.length + " parts. At least 5 part are required."); | ||
} | ||
else if (parsed.length == 5) { | ||
parsed.unshift(""); | ||
parsed.push(""); | ||
} | ||
else if (parsed.length == 6) { | ||
if (/\d{4}$/.test(parsed[5])) { | ||
parsed.unshift(''); | ||
} | ||
else { | ||
parsed.push(''); | ||
} | ||
} | ||
else if (parsed.length > 7) { | ||
throw new Error("Expression has " + parsed.length + " parts; too many!"); | ||
} | ||
this.normalizeExpression(parsed); | ||
return parsed; | ||
}; | ||
CronParser.prototype.normalizeExpression = function (expressionParts) { | ||
var _this = this; | ||
expressionParts[3] = expressionParts[3].replace("?", "*"); | ||
expressionParts[5] = expressionParts[5].replace("?", "*"); | ||
if (expressionParts[0].indexOf("0/") == 0) { | ||
expressionParts[0] = expressionParts[0].replace("0/", "*/"); | ||
} | ||
if (expressionParts[1].indexOf("0/") == 0) { | ||
expressionParts[1] = expressionParts[1].replace("0/", "*/"); | ||
} | ||
if (expressionParts[2].indexOf("0/") == 0) { | ||
expressionParts[2] = expressionParts[2].replace("0/", "*/"); | ||
} | ||
if (expressionParts[3].indexOf("1/") == 0) { | ||
expressionParts[3] = expressionParts[3].replace("1/", "*/"); | ||
} | ||
if (expressionParts[4].indexOf("1/") == 0) { | ||
expressionParts[4] = expressionParts[4].replace("1/", "*/"); | ||
} | ||
if (expressionParts[5].indexOf("1/") == 0) { | ||
expressionParts[5] = expressionParts[5].replace("1/", "*/"); | ||
} | ||
if (expressionParts[6].indexOf("1/") == 0) { | ||
expressionParts[6] = expressionParts[6].replace("1/", "*/"); | ||
} | ||
expressionParts[5] = expressionParts[5].replace(/(^\d)|([^#/\s]\d)/g, function (t) { | ||
var dowDigits = t.replace(/\D/, ""); | ||
var dowDigitsAdjusted = dowDigits; | ||
if (_this.dayOfWeekStartIndexZero) { | ||
if (dowDigits == "7") { | ||
dowDigitsAdjusted = "0"; | ||
} | ||
} | ||
else { | ||
dowDigitsAdjusted = (parseInt(dowDigits) - 1).toString(); | ||
} | ||
return t.replace(dowDigits, dowDigitsAdjusted); | ||
}); | ||
if (expressionParts[3] == "?") { | ||
expressionParts[3] = "*"; | ||
} | ||
if (expressionParts[3].indexOf('W') > -1 && (expressionParts[3].indexOf(',') > -1 || expressionParts[3].indexOf('-') > -1)) { | ||
throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days."); | ||
} | ||
var days = { | ||
"SUN": 0, "MON": 1, "TUE": 2, "WED": 3, "THU": 4, "FRI": 5, "SAT": 6 | ||
}; | ||
for (var day in days) { | ||
expressionParts[5] = expressionParts[5].replace(new RegExp(day, "g"), days[day].toString()); | ||
} | ||
var months = { | ||
"JAN": 1, "FEB": 2, "MAR": 3, "APR": 4, "MAY": 5, "JUN": 6, "JUL": 7, "AUG": 8, "SEP": 9, "OCT": 10, "NOV": 11, "DEC": 12 | ||
}; | ||
for (var month in months) { | ||
expressionParts[4] = expressionParts[4].replace(new RegExp(month, "g"), months[month].toString()); | ||
} | ||
if (expressionParts[0] == "0") { | ||
expressionParts[0] = ""; | ||
} | ||
for (var i = 0; i < expressionParts.length; i++) { | ||
if (expressionParts[i] == "*/1") { | ||
expressionParts[i] = "*"; | ||
} | ||
if (expressionParts[i].indexOf("/") > -1 | ||
&& !(/^\*|\-|\,/.test(expressionParts[i]))) { | ||
var stepRangeThrough = null; | ||
switch (i) { | ||
case 4: | ||
stepRangeThrough = "12"; | ||
break; | ||
case 5: | ||
stepRangeThrough = "6"; | ||
break; | ||
case 6: | ||
stepRangeThrough = "9999"; | ||
break; | ||
default: | ||
stepRangeThrough = null; | ||
break; | ||
} | ||
if (stepRangeThrough != null) { | ||
var parts = expressionParts[i].split("/"); | ||
expressionParts[i] = parts[0] + "-" + stepRangeThrough + "/" + parts[1]; | ||
} | ||
} | ||
} | ||
}; | ||
return CronParser; | ||
}()); | ||
exports.CronParser = CronParser; | ||
/***/ }, | ||
/***/ }), | ||
/* 2 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var StringUtilities = (function () { | ||
function StringUtilities() { | ||
} | ||
StringUtilities.format = function (template) { | ||
var values = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
values[_i - 1] = arguments[_i]; | ||
} | ||
return template.replace(/%s/g, function () { | ||
return values.shift(); | ||
}); | ||
}; | ||
StringUtilities.containsAny = function (text, searchStrings) { | ||
return searchStrings.some(function (c) { return text.indexOf(c) > -1; }); | ||
}; | ||
return StringUtilities; | ||
}()); | ||
exports.StringUtilities = StringUtilities; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var en = (function () { | ||
function en() { | ||
} | ||
en.prototype.atX0SecondsPastTheMinuteGt20 = function () { return null; }; | ||
en.prototype.atX0MinutesPastTheHourGt20 = function () { return null; }; | ||
en.prototype.commaMonthX0ThroughMonthX1 = function () { return null; }; | ||
en.prototype.commaYearX0ThroughYearX1 = function () { return null; }; | ||
en.prototype.use24HourTimeFormatByDefault = function () { return false; }; | ||
en.prototype.anErrorOccuredWhenGeneratingTheExpressionD = function () { | ||
return "An error occured when generating the expression description. Check the cron expression syntax."; | ||
}; | ||
; | ||
en.prototype.everyMinute = function () { | ||
return "every minute"; | ||
}; | ||
; | ||
en.prototype.everyHour = function () { | ||
return "every hour"; | ||
}; | ||
; | ||
en.prototype.atSpace = function () { | ||
return "At "; | ||
}; | ||
; | ||
en.prototype.everyMinutebetweenX0AndX1 = function () { | ||
return "Every minute between %s and %s"; | ||
}; | ||
; | ||
en.prototype.at = function () { | ||
return "At"; | ||
}; | ||
; | ||
en.prototype.spaceAnd = function () { | ||
return " and"; | ||
}; | ||
; | ||
en.prototype.everysecond = function () { | ||
return "every second"; | ||
}; | ||
; | ||
en.prototype.everyX0Seconds = function () { | ||
return "every %s seconds"; | ||
}; | ||
; | ||
en.prototype.secondsX0ThroughX1PastTheMinute = function () { | ||
return "seconds %s through %s past the minute"; | ||
}; | ||
; | ||
en.prototype.atX0SecondsPastTheMinute = function () { | ||
return "at %s seconds past the minute"; | ||
}; | ||
; | ||
en.prototype.everyX0Minutes = function () { | ||
return "every %s minutes"; | ||
}; | ||
; | ||
en.prototype.minutesX0ThroughX1PastTheHour = function () { | ||
return "minutes %s through %s past the hour"; | ||
}; | ||
; | ||
en.prototype.atX0MinutesPastTheHour = function () { | ||
return "at %s minutes past the hour"; | ||
}; | ||
; | ||
en.prototype.everyX0Hours = function () { | ||
return "every %s hours"; | ||
}; | ||
; | ||
en.prototype.betweenX0AndX1 = function () { | ||
return "between %s and %s"; | ||
}; | ||
; | ||
en.prototype.atX0 = function () { | ||
return "at %s"; | ||
}; | ||
; | ||
en.prototype.commaEveryDay = function () { | ||
return ", every day"; | ||
}; | ||
; | ||
en.prototype.commaEveryX0daysOfTheWeek = function () { | ||
return ", every %s days of the week"; | ||
}; | ||
; | ||
en.prototype.commaX0ThroughX1 = function () { | ||
return ", %s through %s"; | ||
}; | ||
; | ||
en.prototype.first = function () { | ||
return "first"; | ||
}; | ||
; | ||
en.prototype.second = function () { | ||
return "second"; | ||
}; | ||
; | ||
en.prototype.third = function () { | ||
return "third"; | ||
}; | ||
; | ||
en.prototype.forth = function () { | ||
return "forth"; | ||
}; | ||
; | ||
en.prototype.fifth = function () { | ||
return "fifth"; | ||
}; | ||
; | ||
en.prototype.commaOnThe = function () { | ||
return ", on the "; | ||
}; | ||
; | ||
en.prototype.spaceX0OfTheMonth = function () { | ||
return " %s of the month"; | ||
}; | ||
; | ||
en.prototype.commaOnTheLastX0OfTheMonth = function () { | ||
return ", on the last %s of the month"; | ||
}; | ||
; | ||
en.prototype.commaOnlyOnX0 = function () { | ||
return ", only on %s"; | ||
}; | ||
; | ||
en.prototype.commaEveryX0Months = function () { | ||
return ", every %s months"; | ||
}; | ||
; | ||
en.prototype.commaOnlyInX0 = function () { | ||
return ", only in %s"; | ||
}; | ||
; | ||
en.prototype.commaOnTheLastDayOfTheMonth = function () { | ||
return ", on the last day of the month"; | ||
}; | ||
; | ||
en.prototype.commaOnTheLastWeekdayOfTheMonth = function () { | ||
return ", on the last weekday of the month"; | ||
}; | ||
; | ||
en.prototype.firstWeekday = function () { | ||
return "first weekday"; | ||
}; | ||
; | ||
en.prototype.weekdayNearestDayX0 = function () { | ||
return "weekday nearest day %s"; | ||
}; | ||
; | ||
en.prototype.commaOnTheX0OfTheMonth = function () { | ||
return ", on the %s of the month"; | ||
}; | ||
; | ||
en.prototype.commaEveryX0Days = function () { | ||
return ", every %s days"; | ||
}; | ||
; | ||
en.prototype.commaBetweenDayX0AndX1OfTheMonth = function () { | ||
return ", between day %s and %s of the month"; | ||
}; | ||
; | ||
en.prototype.commaOnDayX0OfTheMonth = function () { | ||
return ", on day %s of the month"; | ||
}; | ||
; | ||
en.prototype.spaceAndSpace = function () { | ||
return " and "; | ||
}; | ||
; | ||
en.prototype.commaEveryMinute = function () { | ||
return ", every minute"; | ||
}; | ||
; | ||
en.prototype.commaEveryHour = function () { | ||
return ", every hour"; | ||
}; | ||
; | ||
en.prototype.commaEveryX0Years = function () { | ||
return ", every %s years"; | ||
}; | ||
; | ||
en.prototype.commaStartingX0 = function () { | ||
return ", starting %s"; | ||
}; | ||
; | ||
en.prototype.daysOfTheWeek = function () { | ||
return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; | ||
}; | ||
en.prototype.monthsOfTheYear = function () { | ||
return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; | ||
}; | ||
return en; | ||
}()); | ||
exports.en = en; | ||
/***/ }, | ||
/***/ }), | ||
/* 3 */ | ||
/***/ function(module, exports) { | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var CronParser = (function () { | ||
function CronParser(expression, dayOfWeekStartIndexZero) { | ||
if (dayOfWeekStartIndexZero === void 0) { dayOfWeekStartIndexZero = true; } | ||
this.expression = expression; | ||
this.dayOfWeekStartIndexZero = dayOfWeekStartIndexZero; | ||
} | ||
CronParser.prototype.parse = function () { | ||
if (!this.expression) { | ||
throw new Error("Expression is empty"); | ||
} | ||
var parsed = this.expression.trim().split(' '); | ||
if (parsed.length < 5) { | ||
throw new Error("Expression only has " + parsed.length + " parts. At least 5 part are required."); | ||
} | ||
else if (parsed.length == 5) { | ||
parsed.unshift(""); | ||
parsed.push(""); | ||
} | ||
else if (parsed.length == 6) { | ||
if (/\d{4}$/.test(parsed[5])) { | ||
parsed.unshift(''); | ||
} | ||
else { | ||
parsed.push(''); | ||
} | ||
} | ||
else if (parsed.length > 7) { | ||
throw new Error("Expression has " + parsed.length + " parts; too many!"); | ||
} | ||
this.normalizeExpression(parsed); | ||
return parsed; | ||
}; | ||
CronParser.prototype.normalizeExpression = function (expressionParts) { | ||
var _this = this; | ||
expressionParts[3] = expressionParts[3].replace("?", "*"); | ||
expressionParts[5] = expressionParts[5].replace("?", "*"); | ||
if (expressionParts[0].indexOf("0/") == 0) { | ||
expressionParts[0] = expressionParts[0].replace("0/", "*/"); | ||
} | ||
if (expressionParts[1].indexOf("0/") == 0) { | ||
expressionParts[1] = expressionParts[1].replace("0/", "*/"); | ||
} | ||
if (expressionParts[2].indexOf("0/") == 0) { | ||
expressionParts[2] = expressionParts[2].replace("0/", "*/"); | ||
} | ||
if (expressionParts[3].indexOf("1/") == 0) { | ||
expressionParts[3] = expressionParts[3].replace("1/", "*/"); | ||
} | ||
if (expressionParts[4].indexOf("1/") == 0) { | ||
expressionParts[4] = expressionParts[4].replace("1/", "*/"); | ||
} | ||
if (expressionParts[5].indexOf("1/") == 0) { | ||
expressionParts[5] = expressionParts[5].replace("1/", "*/"); | ||
} | ||
if (expressionParts[6].indexOf("1/") == 0) { | ||
expressionParts[6] = expressionParts[6].replace("1/", "*/"); | ||
} | ||
expressionParts[5] = expressionParts[5].replace(/(^\d)|([^#/\s]\d)/g, function (t) { | ||
var dowDigits = t.replace(/\D/, ""); | ||
var dowDigitsAdjusted = dowDigits; | ||
if (_this.dayOfWeekStartIndexZero) { | ||
if (dowDigits == "7") { | ||
dowDigitsAdjusted = "0"; | ||
} | ||
} | ||
else { | ||
dowDigitsAdjusted = (parseInt(dowDigits) - 1).toString(); | ||
} | ||
return t.replace(dowDigits, dowDigitsAdjusted); | ||
}); | ||
if (expressionParts[3] == "?") { | ||
expressionParts[3] = "*"; | ||
} | ||
if (expressionParts[3].indexOf('W') > -1 && (expressionParts[3].indexOf(',') > -1 || expressionParts[3].indexOf('-') > -1)) { | ||
throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days."); | ||
} | ||
var days = { | ||
"SUN": 0, "MON": 1, "TUE": 2, "WED": 3, "THU": 4, "FRI": 5, "SAT": 6 | ||
}; | ||
for (var day in days) { | ||
expressionParts[5] = expressionParts[5].replace(new RegExp(day, "g"), days[day].toString()); | ||
} | ||
var months = { | ||
"JAN": 1, "FEB": 2, "MAR": 3, "APR": 4, "MAY": 5, "JUN": 6, "JUL": 7, "AUG": 8, "SEP": 9, "OCT": 10, "NOV": 11, "DEC": 12 | ||
}; | ||
for (var month in months) { | ||
expressionParts[4] = expressionParts[4].replace(new RegExp(month, "g"), months[month].toString()); | ||
} | ||
if (expressionParts[0] == "0") { | ||
expressionParts[0] = ""; | ||
} | ||
for (var i = 0; i < expressionParts.length; i++) { | ||
if (expressionParts[i] == "*/1") { | ||
expressionParts[i] = "*"; | ||
} | ||
if (expressionParts[i].indexOf("/") > -1 | ||
&& !(/^\*|\-|\,/.test(expressionParts[i]))) { | ||
var stepRangeThrough = null; | ||
switch (i) { | ||
case 4: | ||
stepRangeThrough = "12"; | ||
break; | ||
case 5: | ||
stepRangeThrough = "6"; | ||
break; | ||
case 6: | ||
stepRangeThrough = "9999"; | ||
break; | ||
default: | ||
stepRangeThrough = null; | ||
break; | ||
} | ||
if (stepRangeThrough != null) { | ||
var parts = expressionParts[i].split("/"); | ||
expressionParts[i] = parts[0] + "-" + stepRangeThrough + "/" + parts[1]; | ||
} | ||
} | ||
} | ||
}; | ||
return CronParser; | ||
}()); | ||
exports.CronParser = CronParser; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var StringUtilities = (function () { | ||
function StringUtilities() { | ||
} | ||
StringUtilities.format = function (template) { | ||
var values = []; | ||
for (var _i = 1; _i < arguments.length; _i++) { | ||
values[_i - 1] = arguments[_i]; | ||
} | ||
return template.replace(/%s/g, function () { | ||
return values.shift(); | ||
}); | ||
}; | ||
StringUtilities.containsAny = function (text, searchStrings) { | ||
return searchStrings.some(function (c) { return text.indexOf(c) > -1; }); | ||
}; | ||
return StringUtilities; | ||
}()); | ||
exports.StringUtilities = StringUtilities; | ||
/***/ }, | ||
/* 4 */ | ||
/***/ function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
var en_1 = __webpack_require__(5); | ||
var enLocaleLoader = (function () { | ||
function enLocaleLoader() { | ||
} | ||
enLocaleLoader.prototype.load = function (availableLocales) { | ||
availableLocales["en"] = new en_1.en(); | ||
}; | ||
return enLocaleLoader; | ||
}()); | ||
exports.enLocaleLoader = enLocaleLoader; | ||
/***/ }), | ||
/* 4 */, | ||
/* 5 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
"use strict"; | ||
/***/ }, | ||
/* 5 */ | ||
/***/ function(module, exports) { | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var en_1 = __webpack_require__(2); | ||
var enLocaleLoader = (function () { | ||
function enLocaleLoader() { | ||
} | ||
enLocaleLoader.prototype.load = function (availableLocales) { | ||
availableLocales["en"] = new en_1.en(); | ||
}; | ||
return enLocaleLoader; | ||
}()); | ||
exports.enLocaleLoader = enLocaleLoader; | ||
"use strict"; | ||
var en = (function () { | ||
function en() { | ||
} | ||
en.prototype.atX0SecondsPastTheMinuteGt20 = function () { return null; }; | ||
en.prototype.atX0MinutesPastTheHourGt20 = function () { return null; }; | ||
en.prototype.commaMonthX0ThroughMonthX1 = function () { return null; }; | ||
en.prototype.commaYearX0ThroughYearX1 = function () { return null; }; | ||
en.prototype.use24HourTimeFormatByDefault = function () { return false; }; | ||
en.prototype.anErrorOccuredWhenGeneratingTheExpressionD = function () { | ||
return "An error occured when generating the expression description. Check the cron expression syntax."; | ||
}; | ||
; | ||
en.prototype.everyMinute = function () { | ||
return "every minute"; | ||
}; | ||
; | ||
en.prototype.everyHour = function () { | ||
return "every hour"; | ||
}; | ||
; | ||
en.prototype.atSpace = function () { | ||
return "At "; | ||
}; | ||
; | ||
en.prototype.everyMinutebetweenX0AndX1 = function () { | ||
return "Every minute between %s and %s"; | ||
}; | ||
; | ||
en.prototype.at = function () { | ||
return "At"; | ||
}; | ||
; | ||
en.prototype.spaceAnd = function () { | ||
return " and"; | ||
}; | ||
; | ||
en.prototype.everysecond = function () { | ||
return "every second"; | ||
}; | ||
; | ||
en.prototype.everyX0Seconds = function () { | ||
return "every %s seconds"; | ||
}; | ||
; | ||
en.prototype.secondsX0ThroughX1PastTheMinute = function () { | ||
return "seconds %s through %s past the minute"; | ||
}; | ||
; | ||
en.prototype.atX0SecondsPastTheMinute = function () { | ||
return "at %s seconds past the minute"; | ||
}; | ||
; | ||
en.prototype.everyX0Minutes = function () { | ||
return "every %s minutes"; | ||
}; | ||
; | ||
en.prototype.minutesX0ThroughX1PastTheHour = function () { | ||
return "minutes %s through %s past the hour"; | ||
}; | ||
; | ||
en.prototype.atX0MinutesPastTheHour = function () { | ||
return "at %s minutes past the hour"; | ||
}; | ||
; | ||
en.prototype.everyX0Hours = function () { | ||
return "every %s hours"; | ||
}; | ||
; | ||
en.prototype.betweenX0AndX1 = function () { | ||
return "between %s and %s"; | ||
}; | ||
; | ||
en.prototype.atX0 = function () { | ||
return "at %s"; | ||
}; | ||
; | ||
en.prototype.commaEveryDay = function () { | ||
return ", every day"; | ||
}; | ||
; | ||
en.prototype.commaEveryX0daysOfTheWeek = function () { | ||
return ", every %s days of the week"; | ||
}; | ||
; | ||
en.prototype.commaX0ThroughX1 = function () { | ||
return ", %s through %s"; | ||
}; | ||
; | ||
en.prototype.first = function () { | ||
return "first"; | ||
}; | ||
; | ||
en.prototype.second = function () { | ||
return "second"; | ||
}; | ||
; | ||
en.prototype.third = function () { | ||
return "third"; | ||
}; | ||
; | ||
en.prototype.forth = function () { | ||
return "forth"; | ||
}; | ||
; | ||
en.prototype.fifth = function () { | ||
return "fifth"; | ||
}; | ||
; | ||
en.prototype.commaOnThe = function () { | ||
return ", on the "; | ||
}; | ||
; | ||
en.prototype.spaceX0OfTheMonth = function () { | ||
return " %s of the month"; | ||
}; | ||
; | ||
en.prototype.commaOnTheLastX0OfTheMonth = function () { | ||
return ", on the last %s of the month"; | ||
}; | ||
; | ||
en.prototype.commaOnlyOnX0 = function () { | ||
return ", only on %s"; | ||
}; | ||
; | ||
en.prototype.commaEveryX0Months = function () { | ||
return ", every %s months"; | ||
}; | ||
; | ||
en.prototype.commaOnlyInX0 = function () { | ||
return ", only in %s"; | ||
}; | ||
; | ||
en.prototype.commaOnTheLastDayOfTheMonth = function () { | ||
return ", on the last day of the month"; | ||
}; | ||
; | ||
en.prototype.commaOnTheLastWeekdayOfTheMonth = function () { | ||
return ", on the last weekday of the month"; | ||
}; | ||
; | ||
en.prototype.firstWeekday = function () { | ||
return "first weekday"; | ||
}; | ||
; | ||
en.prototype.weekdayNearestDayX0 = function () { | ||
return "weekday nearest day %s"; | ||
}; | ||
; | ||
en.prototype.commaOnTheX0OfTheMonth = function () { | ||
return ", on the %s of the month"; | ||
}; | ||
; | ||
en.prototype.commaEveryX0Days = function () { | ||
return ", every %s days"; | ||
}; | ||
; | ||
en.prototype.commaBetweenDayX0AndX1OfTheMonth = function () { | ||
return ", between day %s and %s of the month"; | ||
}; | ||
; | ||
en.prototype.commaOnDayX0OfTheMonth = function () { | ||
return ", on day %s of the month"; | ||
}; | ||
; | ||
en.prototype.spaceAndSpace = function () { | ||
return " and "; | ||
}; | ||
; | ||
en.prototype.commaEveryMinute = function () { | ||
return ", every minute"; | ||
}; | ||
; | ||
en.prototype.commaEveryHour = function () { | ||
return ", every hour"; | ||
}; | ||
; | ||
en.prototype.commaEveryX0Years = function () { | ||
return ", every %s years"; | ||
}; | ||
; | ||
en.prototype.commaStartingX0 = function () { | ||
return ", starting %s"; | ||
}; | ||
; | ||
en.prototype.daysOfTheWeek = function () { | ||
return ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]; | ||
}; | ||
en.prototype.monthsOfTheYear = function () { | ||
return ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]; | ||
}; | ||
return en; | ||
}()); | ||
exports.en = en; | ||
/***/ }), | ||
/* 6 */, | ||
/* 7 */ | ||
/***/ (function(module, exports, __webpack_require__) { | ||
/***/ } | ||
/******/ ]) | ||
}); | ||
; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var expressionDescriptor_1 = __webpack_require__(0); | ||
var enLocaleLoader_1 = __webpack_require__(5); | ||
expressionDescriptor_1.ExpressionDescriptor.initialize(new enLocaleLoader_1.enLocaleLoader()); | ||
exports.default = expressionDescriptor_1.ExpressionDescriptor; | ||
var toString = expressionDescriptor_1.ExpressionDescriptor.toString; | ||
exports.toString = toString; | ||
/***/ }) | ||
/******/ ]); | ||
}); |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("cronstrue",[],e):"object"==typeof exports?exports.cronstrue=e():t.cronstrue=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return t[r].call(i.exports,i,i.exports,e),i.loaded=!0,i.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){"use strict";var r=n(1),i=n(4);r.ExpressionDescriptor.initialize(new i.enLocaleLoader),t.exports=r.ExpressionDescriptor},function(t,e,n){"use strict";var r=n(2),i=n(3),o=function(){function t(e,n){this.expression=e,this.options=n,this.expressionParts=new Array(5),t.locales[n.locale]?this.i18n=t.locales[n.locale]:(console.warn("Locale '"+n.locale+"' could not be found; falling back to 'en'."),this.i18n=t.locales.en),void 0===n.use24HourTimeFormat&&(n.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return t.toString=function(e,n){var r=void 0===n?{}:n,i=r.throwExceptionOnParseError,o=void 0===i||i,s=r.verbose,a=void 0!==s&&s,u=r.dayOfWeekStartIndexZero,c=void 0===u||u,p=r.use24HourTimeFormat,h=r.locale,f=void 0===h?"en":h,y={throwExceptionOnParseError:o,verbose:a,dayOfWeekStartIndexZero:c,use24HourTimeFormat:p,locale:f},m=new t(e,y);return m.getFullDescription()},t.initialize=function(e){t.specialCharacters=["/","-",",","*"],e.load(t.locales)},t.prototype.getFullDescription=function(){var t="";try{var e=new i.CronParser(this.expression,this.options.dayOfWeekStartIndexZero);this.expressionParts=e.parse();var n=this.getTimeOfDayDescription(),r=this.getDayOfMonthDescription(),o=this.getMonthDescription(),s=this.getDayOfWeekDescription(),a=this.getYearDescription();t+=n+r+s+o+a,t=this.transformVerbosity(t,this.options.verbose),t=t.charAt(0).toLocaleUpperCase()+t.substr(1)}catch(u){if(this.options.throwExceptionOnParseError)throw""+u;t=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD()}return t},t.prototype.getTimeOfDayDescription=function(){var e=this.expressionParts[0],n=this.expressionParts[1],i=this.expressionParts[2],o="";if(r.StringUtilities.containsAny(n,t.specialCharacters)||r.StringUtilities.containsAny(i,t.specialCharacters)||r.StringUtilities.containsAny(e,t.specialCharacters))if(!(n.indexOf("-")>-1)||n.indexOf(",")>-1||r.StringUtilities.containsAny(i,t.specialCharacters))if(i.indexOf(",")>-1&&i.indexOf("-")==-1&&!r.StringUtilities.containsAny(n,t.specialCharacters)){var s=i.split(",");o+=this.i18n.at();for(var a=0;a<s.length;a++)o+=" ",o+=this.formatTime(s[a],n,""),a<s.length-2&&(o+=","),a==s.length-2&&(o+=this.i18n.spaceAnd())}else{var u=this.getSecondsDescription(),c=this.getMinutesDescription(),p=this.getHoursDescription();o+=u,o.length>0&&(o+=", "),o+=c,o.length>0&&(o+=", "),o+=p}else{var h=n.split("-");o+=r.StringUtilities.format(this.i18n.everyMinutebetweenX0AndX1(),this.formatTime(i,h[0],""),this.formatTime(i,h[1],""))}else o+=this.i18n.atSpace()+this.formatTime(i,n,e);return o},t.prototype.getSecondsDescription=function(){var t=this,e=this.getSegmentDescription(this.expressionParts[0],this.i18n.everysecond(),function(t){return t},function(e){return r.StringUtilities.format(t.i18n.everyX0Seconds(),e)},function(e){return t.i18n.secondsX0ThroughX1PastTheMinute()},function(e){return"0"==e?"":parseInt(e)<20?t.i18n.atX0SecondsPastTheMinute():t.i18n.atX0SecondsPastTheMinuteGt20()||t.i18n.atX0SecondsPastTheMinute()});return e},t.prototype.getMinutesDescription=function(){var t=this,e=this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(t){return t},function(e){return r.StringUtilities.format(t.i18n.everyX0Minutes(),e)},function(e){return t.i18n.minutesX0ThroughX1PastTheHour()},function(e){try{return"0"==e?"":parseInt(e)<20?t.i18n.atX0MinutesPastTheHour():t.i18n.atX0MinutesPastTheHourGt20()||t.i18n.atX0MinutesPastTheHour()}catch(n){return t.i18n.atX0MinutesPastTheHour()}});return e},t.prototype.getHoursDescription=function(){var t=this,e=this.expressionParts[2],n=this.getSegmentDescription(e,this.i18n.everyHour(),function(e){return t.formatTime(e,"0","")},function(e){return r.StringUtilities.format(t.i18n.everyX0Hours(),e)},function(e){return t.i18n.betweenX0AndX1()},function(e){return t.i18n.atX0()});return n},t.prototype.getDayOfWeekDescription=function(){var t=this,e=this.i18n.daysOfTheWeek(),n=null;return n="*"==this.expressionParts[5]&&"*"!=this.expressionParts[3]?"":this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(t){var n=t;return t.indexOf("#")>-1?n=t.substr(0,t.indexOf("#")):t.indexOf("L")>-1&&(n=n.replace("L","")),e[parseInt(n)]},function(e){return r.StringUtilities.format(t.i18n.commaEveryX0daysOfTheWeek(),e)},function(e){return t.i18n.commaX0ThroughX1()},function(e){var n=null;if(e.indexOf("#")>-1){var r=e.substring(e.indexOf("#")+1),i=null;switch(r){case"1":i=t.i18n.first();break;case"2":i=t.i18n.second();break;case"3":i=t.i18n.third();break;case"4":i=t.i18n.forth();break;case"5":i=t.i18n.fifth()}n=t.i18n.commaOnThe()+i+t.i18n.spaceX0OfTheMonth()}else n=e.indexOf("L")>-1?t.i18n.commaOnTheLastX0OfTheMonth():t.i18n.commaOnlyOnX0();return n})},t.prototype.getMonthDescription=function(){var t=this,e=this.i18n.monthsOfTheYear(),n=this.getSegmentDescription(this.expressionParts[4],"",function(t){return e[parseInt(t)-1]},function(e){return r.StringUtilities.format(t.i18n.commaEveryX0Months(),e)},function(e){return t.i18n.commaMonthX0ThroughMonthX1()||t.i18n.commaX0ThroughX1()},function(e){return t.i18n.commaOnlyInX0()});return n},t.prototype.getDayOfMonthDescription=function(){var t=this,e=null,n=this.expressionParts[3];switch(n){case"L":e=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":e=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var i=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(i){var o=parseInt(i[0].replace("W","")),s=1==o?this.i18n.firstWeekday():r.StringUtilities.format(this.i18n.weekdayNearestDayX0(),o.toString());e=r.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),s);break}e=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(t){return t},function(e){return"1"==e?t.i18n.commaEveryDay():t.i18n.commaEveryX0Days()},function(e){return t.i18n.commaBetweenDayX0AndX1OfTheMonth()},function(e){return t.i18n.commaOnDayX0OfTheMonth()})}return e},t.prototype.getYearDescription=function(){var t=this,e=this.getSegmentDescription(this.expressionParts[6],"",function(t){return/^\d+$/.test(t)?new Date(parseInt(t),1).getFullYear().toString():t},function(e){return r.StringUtilities.format(t.i18n.commaEveryX0Years(),e)},function(e){return t.i18n.commaYearX0ThroughYearX1()||t.i18n.commaX0ThroughX1()},function(e){return t.i18n.commaOnlyInX0()});return e},t.prototype.getSegmentDescription=function(t,e,n,i,o,s){var a=this,u=null;if(t)if("*"===t)u=e;else if(r.StringUtilities.containsAny(t,["/","-",","]))if(t.indexOf("/")>-1){var c=t.split("/");if(u=r.StringUtilities.format(i(c[1]),n(c[1])),c[0].indexOf("-")>-1){var p=this.generateBetweenSegmentDescription(c[0],o,n);0!=p.indexOf(", ")&&(u+=", "),u+=p}else if(!r.StringUtilities.containsAny(c[0],["*",","])){var h=r.StringUtilities.format(s(c[0]),n(c[0]));h=h.replace(", ",""),u+=r.StringUtilities.format(this.i18n.commaStartingX0(),h)}}else if(t.indexOf(",")>-1){for(var c=t.split(","),f="",y=0;y<c.length;y++)if(y>0&&c.length>2&&(f+=",",y<c.length-1&&(f+=" ")),y>0&&c.length>1&&(y==c.length-1||2==c.length)&&(f+=this.i18n.spaceAndSpace()),c[y].indexOf("-")>-1){var p=this.generateBetweenSegmentDescription(c[y],function(t){return a.i18n.commaX0ThroughX1()},n);p=p.replace(", ",""),f+=p}else f+=n(c[y]);u=r.StringUtilities.format(s(t),f)}else t.indexOf("-")>-1&&(u=this.generateBetweenSegmentDescription(t,o,n));else u=r.StringUtilities.format(s(t),n(t));else u="";return u},t.prototype.generateBetweenSegmentDescription=function(t,e,n){var i="",o=t.split("-"),s=n(o[0]),a=n(o[1]);a=a.replace(":00",":59");var u=e(t);return i+=r.StringUtilities.format(u,s,a)},t.prototype.formatTime=function(t,e,n){var r=parseInt(t),i="";this.options.use24HourTimeFormat||(i=r>=12?" PM":" AM",r>12&&(r-=12));var o=e,s="";return n&&(s=":"+("00"+n).substring(n.length)),("00"+r.toString()).substring(r.toString().length)+":"+("00"+o.toString()).substring(o.toString().length)+s+i},t.prototype.transformVerbosity=function(t,e){return e||(t=t.replace(new RegExp(this.i18n.commaEveryMinute(),"g"),""),t=t.replace(new RegExp(this.i18n.commaEveryHour(),"g"),""),t=t.replace(new RegExp(this.i18n.commaEveryDay(),"g"),"")),t},t.locales={},t}();e.ExpressionDescriptor=o},function(t,e){"use strict";var n=function(){function t(){}return t.format=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return t.replace(/%s/g,function(){return e.shift()})},t.containsAny=function(t,e){return e.some(function(e){return t.indexOf(e)>-1})},t}();e.StringUtilities=n},function(t,e){"use strict";var n=function(){function t(t,e){void 0===e&&(e=!0),this.expression=t,this.dayOfWeekStartIndexZero=e}return t.prototype.parse=function(){if(!this.expression)throw new Error("Expression is empty");var t=this.expression.trim().split(" ");if(t.length<5)throw new Error("Expression only has "+t.length+" parts. At least 5 part are required.");if(5==t.length)t.unshift(""),t.push("");else if(6==t.length)/\d{4}$/.test(t[5])?t.unshift(""):t.push("");else if(t.length>7)throw new Error("Expression has "+t.length+" parts; too many!");return this.normalizeExpression(t),t},t.prototype.normalizeExpression=function(t){var e=this;if(t[3]=t[3].replace("?","*"),t[5]=t[5].replace("?","*"),0==t[0].indexOf("0/")&&(t[0]=t[0].replace("0/","*/")),0==t[1].indexOf("0/")&&(t[1]=t[1].replace("0/","*/")),0==t[2].indexOf("0/")&&(t[2]=t[2].replace("0/","*/")),0==t[3].indexOf("1/")&&(t[3]=t[3].replace("1/","*/")),0==t[4].indexOf("1/")&&(t[4]=t[4].replace("1/","*/")),0==t[5].indexOf("1/")&&(t[5]=t[5].replace("1/","*/")),0==t[6].indexOf("1/")&&(t[6]=t[6].replace("1/","*/")),t[5]=t[5].replace(/(^\d)|([^#\/\s]\d)/g,function(t){var n=t.replace(/\D/,""),r=n;return e.dayOfWeekStartIndexZero?"7"==n&&(r="0"):r=(parseInt(n)-1).toString(),t.replace(n,r)}),"?"==t[3]&&(t[3]="*"),t[3].indexOf("W")>-1&&(t[3].indexOf(",")>-1||t[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var n={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var r in n)t[5]=t[5].replace(new RegExp(r,"g"),n[r].toString());var i={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var o in i)t[4]=t[4].replace(new RegExp(o,"g"),i[o].toString());"0"==t[0]&&(t[0]="");for(var s=0;s<t.length;s++)if("*/1"==t[s]&&(t[s]="*"),t[s].indexOf("/")>-1&&!/^\*|\-|\,/.test(t[s])){var a=null;switch(s){case 4:a="12";break;case 5:a="6";break;case 6:a="9999";break;default:a=null}if(null!=a){var u=t[s].split("/");t[s]=u[0]+"-"+a+"/"+u[1]}}},t}();e.CronParser=n},function(t,e,n){"use strict";var r=n(5),i=function(){function t(){}return t.prototype.load=function(t){t.en=new r.en},t}();e.enLocaleLoader=i},function(t,e){"use strict";var n=function(){function t(){}return t.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},t.prototype.atX0MinutesPastTheHourGt20=function(){return null},t.prototype.commaMonthX0ThroughMonthX1=function(){return null},t.prototype.commaYearX0ThroughYearX1=function(){return null},t.prototype.use24HourTimeFormatByDefault=function(){return!1},t.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occured when generating the expression description. Check the cron expression syntax."},t.prototype.everyMinute=function(){return"every minute"},t.prototype.everyHour=function(){return"every hour"},t.prototype.atSpace=function(){return"At "},t.prototype.everyMinutebetweenX0AndX1=function(){return"Every minute between %s and %s"},t.prototype.at=function(){return"At"},t.prototype.spaceAnd=function(){return" and"},t.prototype.everysecond=function(){return"every second"},t.prototype.everyX0Seconds=function(){return"every %s seconds"},t.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},t.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},t.prototype.everyX0Minutes=function(){return"every %s minutes"},t.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},t.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},t.prototype.everyX0Hours=function(){return"every %s hours"},t.prototype.betweenX0AndX1=function(){return"between %s and %s"},t.prototype.atX0=function(){return"at %s"},t.prototype.commaEveryDay=function(){return", every day"},t.prototype.commaEveryX0daysOfTheWeek=function(){return", every %s days of the week"},t.prototype.commaX0ThroughX1=function(){return", %s through %s"},t.prototype.first=function(){return"first"},t.prototype.second=function(){return"second"},t.prototype.third=function(){return"third"},t.prototype.forth=function(){return"forth"},t.prototype.fifth=function(){return"fifth"},t.prototype.commaOnThe=function(){return", on the "},t.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},t.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},t.prototype.commaOnlyOnX0=function(){return", only on %s"},t.prototype.commaEveryX0Months=function(){return", every %s months"},t.prototype.commaOnlyInX0=function(){return", only in %s"},t.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},t.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},t.prototype.firstWeekday=function(){return"first weekday"},t.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},t.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},t.prototype.commaEveryX0Days=function(){return", every %s days"},t.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},t.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},t.prototype.spaceAndSpace=function(){return" and "},t.prototype.commaEveryMinute=function(){return", every minute"},t.prototype.commaEveryHour=function(){return", every hour"},t.prototype.commaEveryX0Years=function(){return", every %s years"},t.prototype.commaStartingX0=function(){return", starting %s"},t.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},t.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},t}();e.en=n}])}); | ||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("cronstrue",[],t):"object"==typeof exports?exports.cronstrue=t():e.cronstrue=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=7)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),i=n(1),o=function(){function e(t,n){this.expression=t,this.options=n,this.expressionParts=new Array(5),e.locales[n.locale]?this.i18n=e.locales[n.locale]:(console.warn("Locale '"+n.locale+"' could not be found; falling back to 'en'."),this.i18n=e.locales.en),void 0===n.use24HourTimeFormat&&(n.use24HourTimeFormat=this.i18n.use24HourTimeFormatByDefault())}return e.toString=function(t,n){var r=void 0===n?{}:n,i=r.throwExceptionOnParseError,o=void 0===i||i,s=r.verbose,a=void 0!==s&&s,u=r.dayOfWeekStartIndexZero,c=void 0===u||u,p=r.use24HourTimeFormat,f=r.locale;return new e(t,{throwExceptionOnParseError:o,verbose:a,dayOfWeekStartIndexZero:c,use24HourTimeFormat:p,locale:void 0===f?"en":f}).getFullDescription()},e.initialize=function(t){e.specialCharacters=["/","-",",","*"],t.load(e.locales)},e.prototype.getFullDescription=function(){var e="";try{var t=new i.CronParser(this.expression,this.options.dayOfWeekStartIndexZero);this.expressionParts=t.parse();var n=this.getTimeOfDayDescription(),r=this.getDayOfMonthDescription(),o=this.getMonthDescription(),s=this.getDayOfWeekDescription(),a=this.getYearDescription();e+=n+r+s+o+a,e=this.transformVerbosity(e,this.options.verbose),e=e.charAt(0).toLocaleUpperCase()+e.substr(1)}catch(t){if(this.options.throwExceptionOnParseError)throw""+t;e=this.i18n.anErrorOccuredWhenGeneratingTheExpressionD()}return e},e.prototype.getTimeOfDayDescription=function(){var t=this.expressionParts[0],n=this.expressionParts[1],i=this.expressionParts[2],o="";if(r.StringUtilities.containsAny(n,e.specialCharacters)||r.StringUtilities.containsAny(i,e.specialCharacters)||r.StringUtilities.containsAny(t,e.specialCharacters))if(!(n.indexOf("-")>-1)||n.indexOf(",")>-1||r.StringUtilities.containsAny(i,e.specialCharacters))if(i.indexOf(",")>-1&&i.indexOf("-")==-1&&!r.StringUtilities.containsAny(n,e.specialCharacters)){var s=i.split(",");o+=this.i18n.at();for(var a=0;a<s.length;a++)o+=" ",o+=this.formatTime(s[a],n,""),a<s.length-2&&(o+=","),a==s.length-2&&(o+=this.i18n.spaceAnd())}else{var u=this.getSecondsDescription(),c=this.getMinutesDescription(),p=this.getHoursDescription();o+=u,o.length>0&&(o+=", "),o+=c,o.length>0&&(o+=", "),o+=p}else{var f=n.split("-");o+=r.StringUtilities.format(this.i18n.everyMinutebetweenX0AndX1(),this.formatTime(i,f[0],""),this.formatTime(i,f[1],""))}else o+=this.i18n.atSpace()+this.formatTime(i,n,t);return o},e.prototype.getSecondsDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[0],this.i18n.everysecond(),function(e){return e},function(t){return r.StringUtilities.format(e.i18n.everyX0Seconds(),t)},function(t){return e.i18n.secondsX0ThroughX1PastTheMinute()},function(t){return"0"==t?"":parseInt(t)<20?e.i18n.atX0SecondsPastTheMinute():e.i18n.atX0SecondsPastTheMinuteGt20()||e.i18n.atX0SecondsPastTheMinute()})},e.prototype.getMinutesDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[1],this.i18n.everyMinute(),function(e){return e},function(t){return r.StringUtilities.format(e.i18n.everyX0Minutes(),t)},function(t){return e.i18n.minutesX0ThroughX1PastTheHour()},function(t){try{return"0"==t?"":parseInt(t)<20?e.i18n.atX0MinutesPastTheHour():e.i18n.atX0MinutesPastTheHourGt20()||e.i18n.atX0MinutesPastTheHour()}catch(t){return e.i18n.atX0MinutesPastTheHour()}})},e.prototype.getHoursDescription=function(){var e=this,t=this.expressionParts[2];return this.getSegmentDescription(t,this.i18n.everyHour(),function(t){return e.formatTime(t,"0","")},function(t){return r.StringUtilities.format(e.i18n.everyX0Hours(),t)},function(t){return e.i18n.betweenX0AndX1()},function(t){return e.i18n.atX0()})},e.prototype.getDayOfWeekDescription=function(){var e=this,t=this.i18n.daysOfTheWeek();return"*"==this.expressionParts[5]&&"*"!=this.expressionParts[3]?"":this.getSegmentDescription(this.expressionParts[5],this.i18n.commaEveryDay(),function(e){var n=e;return e.indexOf("#")>-1?n=e.substr(0,e.indexOf("#")):e.indexOf("L")>-1&&(n=n.replace("L","")),t[parseInt(n)]},function(t){return r.StringUtilities.format(e.i18n.commaEveryX0daysOfTheWeek(),t)},function(t){return e.i18n.commaX0ThroughX1()},function(t){var n=null;if(t.indexOf("#")>-1){var r=t.substring(t.indexOf("#")+1),i=null;switch(r){case"1":i=e.i18n.first();break;case"2":i=e.i18n.second();break;case"3":i=e.i18n.third();break;case"4":i=e.i18n.forth();break;case"5":i=e.i18n.fifth()}n=e.i18n.commaOnThe()+i+e.i18n.spaceX0OfTheMonth()}else n=t.indexOf("L")>-1?e.i18n.commaOnTheLastX0OfTheMonth():e.i18n.commaOnlyOnX0();return n})},e.prototype.getMonthDescription=function(){var e=this,t=this.i18n.monthsOfTheYear();return this.getSegmentDescription(this.expressionParts[4],"",function(e){return t[parseInt(e)-1]},function(t){return r.StringUtilities.format(e.i18n.commaEveryX0Months(),t)},function(t){return e.i18n.commaMonthX0ThroughMonthX1()||e.i18n.commaX0ThroughX1()},function(t){return e.i18n.commaOnlyInX0()})},e.prototype.getDayOfMonthDescription=function(){var e=this,t=null,n=this.expressionParts[3];switch(n){case"L":t=this.i18n.commaOnTheLastDayOfTheMonth();break;case"WL":case"LW":t=this.i18n.commaOnTheLastWeekdayOfTheMonth();break;default:var i=n.match(/(\d{1,2}W)|(W\d{1,2})/);if(i){var o=parseInt(i[0].replace("W","")),s=1==o?this.i18n.firstWeekday():r.StringUtilities.format(this.i18n.weekdayNearestDayX0(),o.toString());t=r.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(),s);break}t=this.getSegmentDescription(n,this.i18n.commaEveryDay(),function(e){return e},function(t){return"1"==t?e.i18n.commaEveryDay():e.i18n.commaEveryX0Days()},function(t){return e.i18n.commaBetweenDayX0AndX1OfTheMonth()},function(t){return e.i18n.commaOnDayX0OfTheMonth()})}return t},e.prototype.getYearDescription=function(){var e=this;return this.getSegmentDescription(this.expressionParts[6],"",function(e){return/^\d+$/.test(e)?new Date(parseInt(e),1).getFullYear().toString():e},function(t){return r.StringUtilities.format(e.i18n.commaEveryX0Years(),t)},function(t){return e.i18n.commaYearX0ThroughYearX1()||e.i18n.commaX0ThroughX1()},function(t){return e.i18n.commaOnlyInX0()})},e.prototype.getSegmentDescription=function(e,t,n,i,o,s){var a=this,u=null;if(e)if("*"===e)u=t;else if(r.StringUtilities.containsAny(e,["/","-",","]))if(e.indexOf("/")>-1){var c=e.split("/");if(u=r.StringUtilities.format(i(c[1]),n(c[1])),c[0].indexOf("-")>-1){var p=this.generateBetweenSegmentDescription(c[0],o,n);0!=p.indexOf(", ")&&(u+=", "),u+=p}else if(!r.StringUtilities.containsAny(c[0],["*",","])){var f=r.StringUtilities.format(s(c[0]),n(c[0]));f=f.replace(", ",""),u+=r.StringUtilities.format(this.i18n.commaStartingX0(),f)}}else if(e.indexOf(",")>-1){for(var c=e.split(","),h="",y=0;y<c.length;y++)if(y>0&&c.length>2&&(h+=",",y<c.length-1&&(h+=" ")),y>0&&c.length>1&&(y==c.length-1||2==c.length)&&(h+=this.i18n.spaceAndSpace()),c[y].indexOf("-")>-1){var p=this.generateBetweenSegmentDescription(c[y],function(e){return a.i18n.commaX0ThroughX1()},n);p=p.replace(", ",""),h+=p}else h+=n(c[y]);u=r.StringUtilities.format(s(e),h)}else e.indexOf("-")>-1&&(u=this.generateBetweenSegmentDescription(e,o,n));else u=r.StringUtilities.format(s(e),n(e));else u="";return u},e.prototype.generateBetweenSegmentDescription=function(e,t,n){var i="",o=e.split("-"),s=n(o[0]),a=n(o[1]);a=a.replace(":00",":59");var u=t(e);return i+=r.StringUtilities.format(u,s,a)},e.prototype.formatTime=function(e,t,n){var r=parseInt(e),i="";this.options.use24HourTimeFormat||(i=r>=12?" PM":" AM",r>12&&(r-=12));var o=t,s="";return n&&(s=":"+("00"+n).substring(n.length)),("00"+r.toString()).substring(r.toString().length)+":"+("00"+o.toString()).substring(o.toString().length)+s+i},e.prototype.transformVerbosity=function(e,t){return t||(e=e.replace(new RegExp(this.i18n.commaEveryMinute(),"g"),""),e=e.replace(new RegExp(this.i18n.commaEveryHour(),"g"),""),e=e.replace(new RegExp(this.i18n.commaEveryDay(),"g"),"")),e},e}();o.locales={},t.ExpressionDescriptor=o},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){void 0===t&&(t=!0),this.expression=e,this.dayOfWeekStartIndexZero=t}return e.prototype.parse=function(){if(!this.expression)throw new Error("Expression is empty");var e=this.expression.trim().split(" ");if(e.length<5)throw new Error("Expression only has "+e.length+" parts. At least 5 part are required.");if(5==e.length)e.unshift(""),e.push("");else if(6==e.length)/\d{4}$/.test(e[5])?e.unshift(""):e.push("");else if(e.length>7)throw new Error("Expression has "+e.length+" parts; too many!");return this.normalizeExpression(e),e},e.prototype.normalizeExpression=function(e){var t=this;if(e[3]=e[3].replace("?","*"),e[5]=e[5].replace("?","*"),0==e[0].indexOf("0/")&&(e[0]=e[0].replace("0/","*/")),0==e[1].indexOf("0/")&&(e[1]=e[1].replace("0/","*/")),0==e[2].indexOf("0/")&&(e[2]=e[2].replace("0/","*/")),0==e[3].indexOf("1/")&&(e[3]=e[3].replace("1/","*/")),0==e[4].indexOf("1/")&&(e[4]=e[4].replace("1/","*/")),0==e[5].indexOf("1/")&&(e[5]=e[5].replace("1/","*/")),0==e[6].indexOf("1/")&&(e[6]=e[6].replace("1/","*/")),e[5]=e[5].replace(/(^\d)|([^#\/\s]\d)/g,function(e){var n=e.replace(/\D/,""),r=n;return t.dayOfWeekStartIndexZero?"7"==n&&(r="0"):r=(parseInt(n)-1).toString(),e.replace(n,r)}),"?"==e[3]&&(e[3]="*"),e[3].indexOf("W")>-1&&(e[3].indexOf(",")>-1||e[3].indexOf("-")>-1))throw new Error("The 'W' character can be specified only when the day-of-month is a single day, not a range or list of days.");var n={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6};for(var r in n)e[5]=e[5].replace(new RegExp(r,"g"),n[r].toString());var i={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12};for(var o in i)e[4]=e[4].replace(new RegExp(o,"g"),i[o].toString());"0"==e[0]&&(e[0]="");for(var s=0;s<e.length;s++)if("*/1"==e[s]&&(e[s]="*"),e[s].indexOf("/")>-1&&!/^\*|\-|\,/.test(e[s])){var a=null;switch(s){case 4:a="12";break;case 5:a="6";break;case 6:a="9999";break;default:a=null}if(null!=a){var u=e[s].split("/");e[s]=u[0]+"-"+a+"/"+u[1]}}},e}();t.CronParser=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return e.prototype.atX0SecondsPastTheMinuteGt20=function(){return null},e.prototype.atX0MinutesPastTheHourGt20=function(){return null},e.prototype.commaMonthX0ThroughMonthX1=function(){return null},e.prototype.commaYearX0ThroughYearX1=function(){return null},e.prototype.use24HourTimeFormatByDefault=function(){return!1},e.prototype.anErrorOccuredWhenGeneratingTheExpressionD=function(){return"An error occured when generating the expression description. Check the cron expression syntax."},e.prototype.everyMinute=function(){return"every minute"},e.prototype.everyHour=function(){return"every hour"},e.prototype.atSpace=function(){return"At "},e.prototype.everyMinutebetweenX0AndX1=function(){return"Every minute between %s and %s"},e.prototype.at=function(){return"At"},e.prototype.spaceAnd=function(){return" and"},e.prototype.everysecond=function(){return"every second"},e.prototype.everyX0Seconds=function(){return"every %s seconds"},e.prototype.secondsX0ThroughX1PastTheMinute=function(){return"seconds %s through %s past the minute"},e.prototype.atX0SecondsPastTheMinute=function(){return"at %s seconds past the minute"},e.prototype.everyX0Minutes=function(){return"every %s minutes"},e.prototype.minutesX0ThroughX1PastTheHour=function(){return"minutes %s through %s past the hour"},e.prototype.atX0MinutesPastTheHour=function(){return"at %s minutes past the hour"},e.prototype.everyX0Hours=function(){return"every %s hours"},e.prototype.betweenX0AndX1=function(){return"between %s and %s"},e.prototype.atX0=function(){return"at %s"},e.prototype.commaEveryDay=function(){return", every day"},e.prototype.commaEveryX0daysOfTheWeek=function(){return", every %s days of the week"},e.prototype.commaX0ThroughX1=function(){return", %s through %s"},e.prototype.first=function(){return"first"},e.prototype.second=function(){return"second"},e.prototype.third=function(){return"third"},e.prototype.forth=function(){return"forth"},e.prototype.fifth=function(){return"fifth"},e.prototype.commaOnThe=function(){return", on the "},e.prototype.spaceX0OfTheMonth=function(){return" %s of the month"},e.prototype.commaOnTheLastX0OfTheMonth=function(){return", on the last %s of the month"},e.prototype.commaOnlyOnX0=function(){return", only on %s"},e.prototype.commaEveryX0Months=function(){return", every %s months"},e.prototype.commaOnlyInX0=function(){return", only in %s"},e.prototype.commaOnTheLastDayOfTheMonth=function(){return", on the last day of the month"},e.prototype.commaOnTheLastWeekdayOfTheMonth=function(){return", on the last weekday of the month"},e.prototype.firstWeekday=function(){return"first weekday"},e.prototype.weekdayNearestDayX0=function(){return"weekday nearest day %s"},e.prototype.commaOnTheX0OfTheMonth=function(){return", on the %s of the month"},e.prototype.commaEveryX0Days=function(){return", every %s days"},e.prototype.commaBetweenDayX0AndX1OfTheMonth=function(){return", between day %s and %s of the month"},e.prototype.commaOnDayX0OfTheMonth=function(){return", on day %s of the month"},e.prototype.spaceAndSpace=function(){return" and "},e.prototype.commaEveryMinute=function(){return", every minute"},e.prototype.commaEveryHour=function(){return", every hour"},e.prototype.commaEveryX0Years=function(){return", every %s years"},e.prototype.commaStartingX0=function(){return", starting %s"},e.prototype.daysOfTheWeek=function(){return["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},e.prototype.monthsOfTheYear=function(){return["January","February","March","April","May","June","July","August","September","October","November","December"]},e}();t.en=r},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(){}return e.format=function(e){for(var t=[],n=1;n<arguments.length;n++)t[n-1]=arguments[n];return e.replace(/%s/g,function(){return t.shift()})},e.containsAny=function(e,t){return t.some(function(t){return e.indexOf(t)>-1})},e}();t.StringUtilities=r},,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(2),i=function(){function e(){}return e.prototype.load=function(e){e.en=new r.en},e}();t.enLocaleLoader=i},,function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n(5);r.ExpressionDescriptor.initialize(new i.enLocaleLoader),t.default=r.ExpressionDescriptor;var o=r.ExpressionDescriptor.toString;t.toString=o}])}); |
@@ -0,0 +0,0 @@ import { Options } from "./options"; |
@@ -0,0 +0,0 @@ export { en } from "./locales/en"; |
@@ -0,0 +0,0 @@ import { Locale } from "./locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "./locale"; |
@@ -0,0 +0,0 @@ export interface Locale { |
@@ -0,0 +0,0 @@ import { Locale } from "./locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ import { Locale } from "../locale"; |
@@ -0,0 +0,0 @@ export interface Options { |
@@ -0,0 +0,0 @@ export declare class StringUtilities { |
{ | ||
"name": "cronstrue", | ||
"version": "0.9.3", | ||
"version": "0.10.0", | ||
"description": "Convert cron expressions into human readable descriptions", | ||
@@ -38,3 +38,3 @@ "author": "Brady Holt", | ||
"devDependencies": { | ||
"awesome-typescript-loader": "^2.1.1", | ||
"awesome-typescript-loader": "^3.1.2", | ||
"chai": "^3.5.0", | ||
@@ -45,4 +45,4 @@ "expose-loader": "^0.7.1", | ||
"octonode": "^0.7.6", | ||
"typescript": "^1.8.10", | ||
"webpack": "^1.13.1" | ||
"typescript": "^2.2.2", | ||
"webpack": "^2.3.2" | ||
}, | ||
@@ -53,5 +53,8 @@ "scripts": { | ||
"test": "./node_modules/.bin/mocha --reporter spec", | ||
"prerelease": "rm -rf ./dist && webpack && mv ./dist/src/* ./dist/ && rm -rf ./dist/src && git add -A && git commit --allow-empty -m 'Build latest /dist'", | ||
"prerelease": "rm -rf ./dist && webpack && git add -A && git commit --allow-empty -m 'Build latest /dist'", | ||
"release": "npm-github-release" | ||
}, | ||
"dependencies": { | ||
"ts-loader": "^2.0.3" | ||
} | ||
} |
@@ -18,6 +18,25 @@ # cRonstrue [![Build Status](https://travis-ci.org/bradyholt/cRonstrue.svg?branch=master)](https://travis-ci.org/bradyholt/cRonstrue) [![NPM Package](https://img.shields.io/npm/v/cronstrue.svg)](https://www.npmjs.com/package/cronstrue) | ||
### Node | ||
Install from npm: | ||
``` | ||
npm install cronstrue | ||
``` | ||
Then, require it: | ||
``` | ||
var cronstrue = require('cronstrue'); | ||
``` | ||
### ES6/TypeScript | ||
Install from npm: | ||
``` | ||
npm install cronstrue | ||
``` | ||
Then, import it: | ||
``` | ||
import construe from 'cronstrue'; | ||
``` | ||
### Browser | ||
@@ -43,2 +62,6 @@ The `cronstrue.min.js` file from the `/dist` folder in the npm package should be served to the browser. There are no dependencies so you can simply include the library in a `<script>` tag. | ||
> "At 12:23 PM, on the second Sunday of the month" | ||
console.log(construe.toString("* * * ? * 2-6/2", { dayOfWeekStartIndexZero: false})); | ||
> "Every second, every 2 days of the week, Monday through Friday" | ||
``` | ||
@@ -45,0 +68,0 @@ |
Sorry, the diff of this file is too big to display
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
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
112
264563
1
4837
+ Addedts-loader@^2.0.3
+ Addedansi-styles@3.2.1(transitive)
+ Addedbig.js@5.2.2(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedemojis-list@3.0.0(transitive)
+ Addedenhanced-resolve@3.4.1(transitive)
+ Addederrno@0.1.8(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedinherits@2.0.4(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedjson5@1.0.2(transitive)
+ Addedloader-utils@1.4.2(transitive)
+ Addedmemory-fs@0.4.1(transitive)
+ Addedminimist@1.2.8(transitive)
+ Addedobject-assign@4.1.1(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedprr@1.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedsemver@5.7.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedtapable@0.2.9(transitive)
+ Addedts-loader@2.3.7(transitive)
+ Addedutil-deprecate@1.0.2(transitive)