cronstrue
Version:
Convert cron expressions into human readable descriptions
1,107 lines (1,078 loc) • 263 kB
JavaScript
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
else if(typeof define === 'function' && define.amd)
define("cronstrue", [], factory);
else if(typeof exports === 'object')
exports["cronstrue"] = factory();
else
root["cronstrue"] = factory();
})(globalThis, () => {
return /******/ (() => { // webpackBootstrap
/******/ "use strict";
/******/ var __webpack_modules__ = ({
/***/ 949:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.CronParser = void 0;
var rangeValidator_1 = __webpack_require__(515);
var CronParser = (function () {
function CronParser(expression, dayOfWeekStartIndexZero, monthStartIndexZero) {
if (dayOfWeekStartIndexZero === void 0) { dayOfWeekStartIndexZero = true; }
if (monthStartIndexZero === void 0) { monthStartIndexZero = false; }
this.expression = expression;
this.dayOfWeekStartIndexZero = dayOfWeekStartIndexZero;
this.monthStartIndexZero = monthStartIndexZero;
}
CronParser.prototype.parse = function () {
var _a;
var parsed;
var expression = (_a = this.expression) !== null && _a !== void 0 ? _a : '';
if (expression === "@reboot") {
parsed = ["@reboot", "", "", "", "", "", ""];
return parsed;
}
else if (expression.startsWith('@')) {
var special = this.parseSpecial(this.expression);
parsed = this.extractParts(special);
}
else {
parsed = this.extractParts(this.expression);
}
this.normalize(parsed);
this.validate(parsed);
return parsed;
};
CronParser.prototype.parseSpecial = function (expression) {
var specialExpressions = {
'@yearly': '0 0 1 1 *',
'@annually': '0 0 1 1 *',
'@monthly': '0 0 1 * *',
'@weekly': '0 0 * * 0',
'@daily': '0 0 * * *',
'@midnight': '0 0 * * *',
'@hourly': '0 * * * *',
'@reboot': '@reboot'
};
var special = specialExpressions[expression];
if (!special) {
throw new Error('Unknown special expression.');
}
return special;
};
CronParser.prototype.extractParts = function (expression) {
if (!this.expression) {
throw new Error("cron expression is empty");
}
var parsed = expression.trim().split(/[ ]+/);
for (var i = 0; i < parsed.length; i++) {
if (parsed[i].includes(",")) {
var arrayElement = parsed[i]
.split(",")
.map(function (item) { return item.trim(); })
.filter(function (item) { return item !== ""; })
.map(function (item) { return (!isNaN(Number(item)) ? Number(item) : item); })
.filter(function (item) { return item !== null && item !== ""; });
if (arrayElement.length === 0) {
arrayElement.push("*");
}
arrayElement.sort(function (a, b) { return (a !== null && b !== null ? a - b : 0); });
parsed[i] = arrayElement.map(function (item) { return (item !== null ? item.toString() : ""); }).join(",");
}
}
if (parsed.length < 5) {
throw new Error("Expression has only ".concat(parsed.length, " part").concat(parsed.length == 1 ? "" : "s", ". At least 5 parts are required."));
}
else if (parsed.length == 5) {
parsed.unshift("");
parsed.push("");
}
else if (parsed.length == 6) {
var isYearWithNoSecondsPart = /\d{4}$/.test(parsed[5]) || parsed[4] == "?" || parsed[2] == "?";
if (isYearWithNoSecondsPart) {
parsed.unshift("");
}
else {
parsed.push("");
}
}
else if (parsed.length > 7) {
throw new Error("Expression has ".concat(parsed.length, " parts; too many!"));
}
return parsed;
};
CronParser.prototype.normalize = function (expressionParts) {
var _this = this;
expressionParts[3] = expressionParts[3].replace("?", "*");
expressionParts[5] = expressionParts[5].replace("?", "*");
expressionParts[2] = expressionParts[2].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[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[5] == "L") {
expressionParts[5] = "6";
}
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, "gi"), days[day].toString());
}
expressionParts[4] = expressionParts[4].replace(/(^\d{1,2})|([^#/\s]\d{1,2})/g, function (t) {
var dowDigits = t.replace(/\D/, "");
var dowDigitsAdjusted = dowDigits;
if (_this.monthStartIndexZero) {
dowDigitsAdjusted = (parseInt(dowDigits) + 1).toString();
}
return t.replace(dowDigits, dowDigitsAdjusted);
});
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, "gi"), months[month].toString());
}
if (expressionParts[0] == "0") {
expressionParts[0] = "";
}
if (!/\*|\-|\,|\//.test(expressionParts[2]) &&
(/\*|\//.test(expressionParts[1]) || /\*|\//.test(expressionParts[0]))) {
expressionParts[2] += "-".concat(expressionParts[2]);
}
for (var i = 0; i < expressionParts.length; i++) {
if (expressionParts[i].indexOf(",") != -1) {
expressionParts[i] =
expressionParts[i]
.split(",")
.filter(function (str) { return str !== ""; })
.join(",") || "*";
}
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] = "".concat(parts[0], "-").concat(stepRangeThrough, "/").concat(parts[1]);
}
}
}
};
CronParser.prototype.validate = function (parsed) {
var standardCronPartCharacters = "0-9,\\-*\/";
this.validateOnlyExpectedCharactersFound(parsed[0], standardCronPartCharacters);
this.validateOnlyExpectedCharactersFound(parsed[1], standardCronPartCharacters);
this.validateOnlyExpectedCharactersFound(parsed[2], standardCronPartCharacters);
this.validateOnlyExpectedCharactersFound(parsed[3], "0-9,\\-*\/LW");
this.validateOnlyExpectedCharactersFound(parsed[4], standardCronPartCharacters);
this.validateOnlyExpectedCharactersFound(parsed[5], "0-9,\\-*\/L#");
this.validateOnlyExpectedCharactersFound(parsed[6], standardCronPartCharacters);
this.validateAnyRanges(parsed);
};
CronParser.prototype.validateAnyRanges = function (parsed) {
rangeValidator_1.default.secondRange(parsed[0]);
rangeValidator_1.default.minuteRange(parsed[1]);
rangeValidator_1.default.hourRange(parsed[2]);
rangeValidator_1.default.dayOfMonthRange(parsed[3]);
rangeValidator_1.default.monthRange(parsed[4], this.monthStartIndexZero);
rangeValidator_1.default.dayOfWeekRange(parsed[5], this.dayOfWeekStartIndexZero);
};
CronParser.prototype.validateOnlyExpectedCharactersFound = function (cronPart, allowedCharsExpression) {
var invalidChars = cronPart.match(new RegExp("[^".concat(allowedCharsExpression, "]+"), "gi"));
if (invalidChars && invalidChars.length) {
throw new Error("Expression contains invalid values: '".concat(invalidChars.toString(), "'"));
}
};
return CronParser;
}());
exports.CronParser = CronParser;
/***/ }),
/***/ 333:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ExpressionDescriptor = void 0;
var stringUtilities_1 = __webpack_require__(823);
var cronParser_1 = __webpack_require__(949);
var ExpressionDescriptor = (function () {
function ExpressionDescriptor(expression, options) {
this.expression = expression;
this.options = options;
this.expressionParts = new Array(5);
if (!this.options.locale && ExpressionDescriptor.defaultLocale) {
this.options.locale = ExpressionDescriptor.defaultLocale;
}
if (!ExpressionDescriptor.locales[this.options.locale]) {
var fallBackLocale = Object.keys(ExpressionDescriptor.locales)[0];
console.warn("Locale '".concat(this.options.locale, "' could not be found; falling back to '").concat(fallBackLocale, "'."));
this.options.locale = fallBackLocale;
}
this.i18n = ExpressionDescriptor.locales[this.options.locale];
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, _f = _b.monthStartIndexZero, monthStartIndexZero = _f === void 0 ? false : _f, use24HourTimeFormat = _b.use24HourTimeFormat, _g = _b.locale, locale = _g === void 0 ? null : _g;
var options = {
throwExceptionOnParseError: throwExceptionOnParseError,
verbose: verbose,
dayOfWeekStartIndexZero: dayOfWeekStartIndexZero,
monthStartIndexZero: monthStartIndexZero,
use24HourTimeFormat: use24HourTimeFormat,
locale: locale,
};
if (options.tzOffset) {
console.warn("'tzOffset' option has been deprecated and is no longer supported.");
}
var descripter = new ExpressionDescriptor(expression, options);
return descripter.getFullDescription();
};
ExpressionDescriptor.initialize = function (localesLoader, defaultLocale) {
if (defaultLocale === void 0) { defaultLocale = "en"; }
ExpressionDescriptor.specialCharacters = ["/", "-", ",", "*"];
ExpressionDescriptor.defaultLocale = defaultLocale;
localesLoader.load(ExpressionDescriptor.locales);
};
ExpressionDescriptor.prototype.getFullDescription = function () {
var _a, _b;
var description = "";
try {
var parser = new cronParser_1.CronParser(this.expression, this.options.dayOfWeekStartIndexZero, this.options.monthStartIndexZero);
this.expressionParts = parser.parse();
if (this.expressionParts[0] === "@reboot") {
return ((_b = (_a = this.i18n).atReboot) === null || _b === void 0 ? void 0 : _b.call(_a)) || "Run once, at startup";
}
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 "".concat(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 (!secondsExpression &&
minuteExpression.indexOf("-") > -1 &&
!(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 (!secondsExpression &&
hourExpression.indexOf(",") > -1 &&
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 && minutesDescription) {
description += ", ";
}
description += minutesDescription;
if (minutesDescription === hoursDescription) {
return description;
}
if (description && hoursDescription) {
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), s);
}, function (s) {
return _this.i18n.secondsX0ThroughX1PastTheMinute();
}, function (s) {
return s == "0"
? ""
: parseInt(s) < 20
? _this.i18n.atX0SecondsPastTheMinute(s)
: _this.i18n.atX0SecondsPastTheMinuteGt20() || _this.i18n.atX0SecondsPastTheMinute(s);
});
return description;
};
ExpressionDescriptor.prototype.getMinutesDescription = function () {
var _this = this;
var secondsExpression = this.expressionParts[0];
var hourExpression = this.expressionParts[2];
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), s);
}, function (s) {
return _this.i18n.minutesX0ThroughX1PastTheHour();
}, function (s) {
try {
return s == "0" && hourExpression.indexOf("/") == -1 && secondsExpression == ""
? _this.i18n.everyHour()
: parseInt(s) < 20
? _this.i18n.atX0MinutesPastTheHour(s)
: _this.i18n.atX0MinutesPastTheHourGt20() || _this.i18n.atX0MinutesPastTheHour(s);
}
catch (e) {
return _this.i18n.atX0MinutesPastTheHour(s);
}
});
return description;
};
ExpressionDescriptor.prototype.getHoursDescription = function () {
var _this = this;
var expression = this.expressionParts[2];
var hourIndex = 0;
var rangeEndValues = [];
expression
.split("/")[0]
.split(",")
.forEach(function (range) {
var rangeParts = range.split("-");
if (rangeParts.length === 2) {
rangeEndValues.push({ value: rangeParts[1], index: hourIndex + 1 });
}
hourIndex += rangeParts.length;
});
var evaluationIndex = 0;
var description = this.getSegmentDescription(expression, this.i18n.everyHour(), function (s) {
var match = rangeEndValues.find(function (r) { return r.value === s && r.index === evaluationIndex; });
var isRangeEndWithNonZeroMinute = match && _this.expressionParts[1] !== "0";
evaluationIndex++;
return isRangeEndWithNonZeroMinute ? _this.formatTime(s, "59", "") : _this.formatTime(s, "0", "");
}, function (s) {
return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Hours(s), 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] == "*") {
description = "";
}
else {
description = this.getSegmentDescription(this.expressionParts[5], this.i18n.commaEveryDay(), function (s, form) {
var exp = s;
if (s.indexOf("#") > -1) {
exp = s.substring(0, s.indexOf("#"));
}
else if (s.indexOf("L") > -1) {
exp = exp.replace("L", "");
}
var parsedExp = parseInt(exp);
var description = _this.i18n.daysOfTheWeekInCase
? _this.i18n.daysOfTheWeekInCase(form)[parsedExp]
: daysOfWeekNames[parsedExp];
if (s.indexOf("#") > -1) {
var dayOfWeekOfMonthDescription = null;
var dayOfWeekOfMonthNumber = s.substring(s.indexOf("#") + 1);
var dayOfWeekNumber = s.substring(0, s.indexOf("#"));
switch (dayOfWeekOfMonthNumber) {
case "1":
dayOfWeekOfMonthDescription = _this.i18n.first(dayOfWeekNumber);
break;
case "2":
dayOfWeekOfMonthDescription = _this.i18n.second(dayOfWeekNumber);
break;
case "3":
dayOfWeekOfMonthDescription = _this.i18n.third(dayOfWeekNumber);
break;
case "4":
dayOfWeekOfMonthDescription = _this.i18n.fourth(dayOfWeekNumber);
break;
case "5":
dayOfWeekOfMonthDescription = _this.i18n.fifth(dayOfWeekNumber);
break;
}
description = dayOfWeekOfMonthDescription + " " + description;
}
return description;
}, function (s) {
if (parseInt(s) == 1) {
return "";
}
else {
return stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0DaysOfTheWeek(s), s);
}
}, function (s) {
var beginFrom = s.substring(0, s.indexOf("-"));
var domSpecified = _this.expressionParts[3] != "*";
return domSpecified ? _this.i18n.commaAndX0ThroughX1(beginFrom) : _this.i18n.commaX0ThroughX1(beginFrom);
}, function (s) {
var format = null;
if (s.indexOf("#") > -1) {
var dayOfWeekOfMonthNumber = s.substring(s.indexOf("#") + 1);
var dayOfWeek = s.substring(0, s.indexOf("#"));
format = _this.i18n.commaOnThe(dayOfWeekOfMonthNumber, dayOfWeek).trim() + _this.i18n.spaceX0OfTheMonth();
}
else if (s.indexOf("L") > -1) {
format = _this.i18n.commaOnTheLastX0OfTheMonth(s.replace("L", ""));
}
else {
var domSpecified = _this.expressionParts[3] != "*";
format = domSpecified ? _this.i18n.commaAndOnX0() : _this.i18n.commaOnlyOnX0(s);
}
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, form) {
return form && _this.i18n.monthsOfTheYearInCase
? _this.i18n.monthsOfTheYearInCase(form)[parseInt(s) - 1]
: monthNames[parseInt(s) - 1];
}, function (s) {
if (parseInt(s) == 1) {
return "";
}
else {
return stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0Months(s), s);
}
}, function (s) {
return _this.i18n.commaMonthX0ThroughMonthX1() || _this.i18n.commaX0ThroughX1();
}, function (s) {
return _this.i18n.commaOnlyInMonthX0 ? _this.i18n.commaOnlyInMonthX0() : _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 weekDayNumberMatches = expression.match(/(\d{1,2}W)|(W\d{1,2})/);
if (weekDayNumberMatches) {
var dayNumber = parseInt(weekDayNumberMatches[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 {
var lastDayOffSetMatches = expression.match(/L-(\d{1,2})/);
if (lastDayOffSetMatches) {
var offSetDays = lastDayOffSetMatches[1];
description = stringUtilities_1.StringUtilities.format(this.i18n.commaDaysBeforeTheLastDayOfTheMonth(offSetDays), offSetDays);
break;
}
else if (expression == "*" && this.expressionParts[5] != "*") {
return "";
}
else {
description = this.getSegmentDescription(expression, this.i18n.commaEveryDay(), function (s) {
return s == "L"
? _this.i18n.lastDay()
: _this.i18n.dayX0
? stringUtilities_1.StringUtilities.format(_this.i18n.dayX0(), s)
: s;
}, function (s) {
return s == "1" ? _this.i18n.commaEveryDay() : _this.i18n.commaEveryX0Days(s);
}, function (s) {
return _this.i18n.commaBetweenDayX0AndX1OfTheMonth(s);
}, function (s) {
return _this.i18n.commaOnDayX0OfTheMonth(s);
});
}
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), s);
}, function (s) {
return _this.i18n.commaYearX0ThroughYearX1() || _this.i18n.commaX0ThroughX1();
}, function (s) {
return _this.i18n.commaOnlyInYearX0 ? _this.i18n.commaOnlyInYearX0() : _this.i18n.commaOnlyInX0();
});
return description;
};
ExpressionDescriptor.prototype.getSegmentDescription = function (expression, allDescription, getSingleItemDescription, getIncrementDescriptionFormat, getRangeDescriptionFormat, getDescriptionFormat) {
var description = null;
var doesExpressionContainIncrement = expression.indexOf("/") > -1;
var doesExpressionContainRange = expression.indexOf("-") > -1;
var doesExpressionContainMultipleValues = expression.indexOf(",") > -1;
if (!expression) {
description = "";
}
else if (expression === "*") {
description = allDescription;
}
else if (!doesExpressionContainIncrement && !doesExpressionContainRange && !doesExpressionContainMultipleValues) {
description = stringUtilities_1.StringUtilities.format(getDescriptionFormat(expression), getSingleItemDescription(expression));
}
else if (doesExpressionContainMultipleValues) {
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 += "".concat(this.i18n.spaceAnd(), " ");
}
if (segments[i].indexOf("/") > -1 || segments[i].indexOf("-") > -1) {
var isSegmentRangeWithoutIncrement = segments[i].indexOf("-") > -1 && segments[i].indexOf("/") == -1;
var currentDescriptionContent = this.getSegmentDescription(segments[i], allDescription, getSingleItemDescription, getIncrementDescriptionFormat, isSegmentRangeWithoutIncrement ? this.i18n.commaX0ThroughX1 : getRangeDescriptionFormat, getDescriptionFormat);
if (isSegmentRangeWithoutIncrement) {
currentDescriptionContent = currentDescriptionContent.replace(", ", "");
}
descriptionContent += currentDescriptionContent;
}
else if (!doesExpressionContainIncrement) {
descriptionContent += getSingleItemDescription(segments[i]);
}
else {
descriptionContent += this.getSegmentDescription(segments[i], allDescription, getSingleItemDescription, getIncrementDescriptionFormat, getRangeDescriptionFormat, getDescriptionFormat);
}
}
if (!doesExpressionContainIncrement) {
description = stringUtilities_1.StringUtilities.format(getDescriptionFormat(expression), descriptionContent);
}
else {
description = descriptionContent;
}
}
else if (doesExpressionContainIncrement) {
var segments = expression.split("/");
description = stringUtilities_1.StringUtilities.format(getIncrementDescriptionFormat(segments[1]), segments[1]);
if (segments[0].indexOf("-") > -1) {
var rangeSegmentDescription = this.generateRangeSegmentDescription(segments[0], getRangeDescriptionFormat, getSingleItemDescription);
if (rangeSegmentDescription.indexOf(", ") != 0) {
description += ", ";
}
description += rangeSegmentDescription;
}
else if (segments[0].indexOf("*") == -1) {
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 (doesExpressionContainRange) {
description = this.generateRangeSegmentDescription(expression, getRangeDescriptionFormat, getSingleItemDescription);
}
return description;
};
ExpressionDescriptor.prototype.generateRangeSegmentDescription = function (rangeExpression, getRangeDescriptionFormat, getSingleItemDescription) {
var description = "";
var rangeSegments = rangeExpression.split("-");
var rangeSegment1Description = getSingleItemDescription(rangeSegments[0], 1);
var rangeSegment2Description = getSingleItemDescription(rangeSegments[1], 2);
var rangeDescriptionFormat = getRangeDescriptionFormat(rangeExpression);
description += stringUtilities_1.StringUtilities.format(rangeDescriptionFormat, rangeSegment1Description, rangeSegment2Description);
return description;
};
ExpressionDescriptor.prototype.formatTime = function (hourExpression, minuteExpression, secondExpression) {
var hourOffset = 0;
var minuteOffset = 0;
var hour = parseInt(hourExpression) + hourOffset;
var minute = parseInt(minuteExpression) + minuteOffset;
if (minute >= 60) {
minute -= 60;
hour += 1;
}
else if (minute < 0) {
minute += 60;
hour -= 1;
}
if (hour >= 24) {
hour = hour - 24;
}
else if (hour < 0) {
hour = 24 + hour;
}
var period = "";
var setPeriodBeforeTime = false;
if (!this.options.use24HourTimeFormat) {
setPeriodBeforeTime = !!(this.i18n.setPeriodBeforeTime && this.i18n.setPeriodBeforeTime());
period = setPeriodBeforeTime ? "".concat(this.getPeriod(hour), " ") : " ".concat(this.getPeriod(hour));
if (hour > 12) {
hour -= 12;
}
if (hour === 0) {
hour = 12;
}
}
var second = "";
if (secondExpression) {
second = ":".concat(("00" + secondExpression).substring(secondExpression.length));
}
return "".concat(setPeriodBeforeTime ? period : "").concat(("00" + hour.toString()).substring(hour.toString().length), ":").concat(("00" + minute.toString()).substring(minute.toString().length)).concat(second).concat(!setPeriodBeforeTime ? period : "");
};
ExpressionDescriptor.prototype.transformVerbosity = function (description, useVerboseFormat) {
if (!useVerboseFormat) {
description = description.replace(new RegExp(", ".concat(this.i18n.everyMinute()), "g"), "");
description = description.replace(new RegExp(", ".concat(this.i18n.everyHour()), "g"), "");
description = description.replace(new RegExp(this.i18n.commaEveryDay(), "g"), "");
description = description.replace(/\, ?$/, "");
if (this.i18n.conciseVerbosityReplacements) {
for (var _i = 0, _a = Object.entries(this.i18n.conciseVerbosityReplacements()); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
description = description.replace(new RegExp(key, "g"), value);
}
}
}
return description;
};
ExpressionDescriptor.prototype.getPeriod = function (hour) {
return hour >= 12 ? (this.i18n.pm && this.i18n.pm()) || "PM" : (this.i18n.am && this.i18n.am()) || "AM";
};
ExpressionDescriptor.locales = {};
return ExpressionDescriptor;
}());
exports.ExpressionDescriptor = ExpressionDescriptor;
/***/ }),
/***/ 99:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.bg = exports.my = exports.vi = exports.ar = exports.th = exports.af = exports.hu = exports.be = exports.ca = exports.fa = exports.sw = exports.sl = exports.fi = exports.sk = exports.cs = exports.he = exports.ja = exports.zh_TW = exports.zh_CN = exports.uk = exports.tr = exports.ru = exports.ro = exports.pt_PT = exports.pt_BR = exports.pl = exports.sv = exports.nb = exports.nl = exports.ko = exports.id = exports.it = exports.fr = exports.es = exports.de = exports.da = exports.en = void 0;
var en_1 = __webpack_require__(486);
Object.defineProperty(exports, "en", ({ enumerable: true, get: function () { return en_1.en; } }));
var da_1 = __webpack_require__(506);
Object.defineProperty(exports, "da", ({ enumerable: true, get: function () { return da_1.da; } }));
var de_1 = __webpack_require__(230);
Object.defineProperty(exports, "de", ({ enumerable: true, get: function () { return de_1.de; } }));
var es_1 = __webpack_require__(153);
Object.defineProperty(exports, "es", ({ enumerable: true, get: function () { return es_1.es; } }));
var fr_1 = __webpack_require__(517);
Object.defineProperty(exports, "fr", ({ enumerable: true, get: function () { return fr_1.fr; } }));
var it_1 = __webpack_require__(488);
Object.defineProperty(exports, "it", ({ enumerable: true, get: function () { return it_1.it; } }));
var id_1 = __webpack_require__(72);
Object.defineProperty(exports, "id", ({ enumerable: true, get: function () { return id_1.id; } }));
var ko_1 = __webpack_require__(839);
Object.defineProperty(exports, "ko", ({ enumerable: true, get: function () { return ko_1.ko; } }));
var nl_1 = __webpack_require__(647);
Object.defineProperty(exports, "nl", ({ enumerable: true, get: function () { return nl_1.nl; } }));
var nb_1 = __webpack_require__(957);
Object.defineProperty(exports, "nb", ({ enumerable: true, get: function () { return nb_1.nb; } }));
var sv_1 = __webpack_require__(544);
Object.defineProperty(exports, "sv", ({ enumerable: true, get: function () { return sv_1.sv; } }));
var pl_1 = __webpack_require__(905);
Object.defineProperty(exports, "pl", ({ enumerable: true, get: function () { return pl_1.pl; } }));
var pt_BR_1 = __webpack_require__(556);
Object.defineProperty(exports, "pt_BR", ({ enumerable: true, get: function () { return pt_BR_1.pt_BR; } }));
var pt_PT_1 = __webpack_require__(163);
Object.defineProperty(exports, "pt_PT", ({ enumerable: true, get: function () { return pt_PT_1.pt_PT; } }));
var ro_1 = __webpack_require__(614);
Object.defineProperty(exports, "ro", ({ enumerable: true, get: function () { return ro_1.ro; } }));
var ru_1 = __webpack_require__(892);
Object.defineProperty(exports, "ru", ({ enumerable: true, get: function () { return ru_1.ru; } }));
var tr_1 = __webpack_require__(631);
Object.defineProperty(exports, "tr", ({ enumerable: true, get: function () { return tr_1.tr; } }));
var uk_1 = __webpack_require__(225);
Object.defineProperty(exports, "uk", ({ enumerable: true, get: function () { return uk_1.uk; } }));
var zh_CN_1 = __webpack_require__(571);
Object.defineProperty(exports, "zh_CN", ({ enumerable: true, get: function () { return zh_CN_1.zh_CN; } }));
var zh_TW_1 = __webpack_require__(983);
Object.defineProperty(exports, "zh_TW", ({ enumerable: true, get: function () { return zh_TW_1.zh_TW; } }));
var ja_1 = __webpack_require__(904);
Object.defineProperty(exports, "ja", ({ enumerable: true, get: function () { return ja_1.ja; } }));
var he_1 = __webpack_require__(82);
Object.defineProperty(exports, "he", ({ enumerable: true, get: function () { return he_1.he; } }));
var cs_1 = __webpack_require__(651);
Object.defineProperty(exports, "cs", ({ enumerable: true, get: function () { return cs_1.cs; } }));
var sk_1 = __webpack_require__(923);
Object.defineProperty(exports, "sk", ({ enumerable: true, get: function () { return sk_1.sk; } }));
var fi_1 = __webpack_require__(964);
Object.defineProperty(exports, "fi", ({ enumerable: true, get: function () { return fi_1.fi; } }));
var sl_1 = __webpack_require__(474);
Object.defineProperty(exports, "sl", ({ enumerable: true, get: function () { return sl_1.sl; } }));
var sw_1 = __webpack_require__(799);
Object.defineProperty(exports, "sw", ({ enumerable: true, get: function () { return sw_1.sw; } }));
var fa_1 = __webpack_require__(804);
Object.defineProperty(exports, "fa", ({ enumerable: true, get: function () { return fa_1.fa; } }));
var ca_1 = __webpack_require__(845);
Object.defineProperty(exports, "ca", ({ enumerable: true, get: function () { return ca_1.ca; } }));
var be_1 = __webpack_require__(348);
Object.defineProperty(exports, "be", ({ enumerable: true, get: function () { return be_1.be; } }));
var hu_1 = __webpack_require__(194);
Object.defineProperty(exports, "hu", ({ enumerable: true, get: function () { return hu_1.hu; } }));
var af_1 = __webpack_require__(810);
Object.defineProperty(exports, "af", ({ enumerable: true, get: function () { return af_1.af; } }));
var th_1 = __webpack_require__(33);
Object.defineProperty(exports, "th", ({ enumerable: true, get: function () { return th_1.th; } }));
var ar_1 = __webpack_require__(574);
Object.defineProperty(exports, "ar", ({ enumerable: true, get: function () { return ar_1.ar; } }));
var vi_1 = __webpack_require__(292);
Object.defineProperty(exports, "vi", ({ enumerable: true, get: function () { return vi_1.vi; } }));
var my_1 = __webpack_require__(919);
Object.defineProperty(exports, "my", ({ enumerable: true, get: function () { return my_1.my; } }));
var bg_1 = __webpack_require__(622);
Object.defineProperty(exports, "bg", ({ enumerable: true, get: function () { return bg_1.bg; } }));
/***/ }),
/***/ 420:
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.allLocalesLoader = void 0;
var allLocales = __webpack_require__(99);
var allLocalesLoader = (function () {
function allLocalesLoader() {
}
allLocalesLoader.prototype.load = function (availableLocales) {
for (var property in allLocales) {
if (allLocales.hasOwnProperty(property)) {
availableLocales[property] = new allLocales[property]();
}
}
};
return allLocalesLoader;
}());
exports.allLocalesLoader = allLocalesLoader;
/***/ }),
/***/ 810:
/***/ ((__unused_webpack_module, exports) => {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.af = void 0;
var af = (function () {
function af() {
}
af.prototype.atX0SecondsPastTheMinuteGt20 = function () {
return null;
};
af.prototype.atX0MinutesPastTheHourGt20 = function () {
return null;
};
af.prototype.commaMonthX0ThroughMonthX1 = function () {
return null;
};
af.prototype.commaYearX0ThroughYearX1 = function () {
return ", jaar %s na %s";
};
af.prototype.use24HourTimeFormatByDefault = function () {
return true;
};
af.prototype.anErrorOccuredWhenGeneratingTheExpressionD = function () {
return "Daar was 'n fout om die tydsuitdrukking the genereer. Raadpleeg asb die uitdrukking formaat.";
};
af.prototype.everyMinute = function () {
return "elke minuut";
};
af.prototype.everyHour = function () {
return "elke uur";
};
af.prototype.atSpace = function () {
return "Teen ";
};
af.prototype.everyMinuteBetweenX0AndX1 = function () {
return "Elke minuut tussen %s en %s";
};
af.prototype.at = function () {
return "Teen";
};
af.prototype.spaceAnd = function () {
return " en";
};
af.prototype.everySecond = function () {
return "elke sekonde";
};
af.prototype.everyX0Seconds = function () {
return "elke %s sekonde";
};
af.prototype.secondsX0ThroughX1PastTheMinute = function () {
return "sekonde %s deur na %s na die minuut";
};
af.prototype.atX0SecondsPastTheMinute = function () {
return "teen %s sekondes na die minuut";
};
af.prototype.everyX0Minutes = function () {
return "elke %s minute";
};
af.prototype.minutesX0ThroughX1PastTheHour = function () {
return "minute %s deur na %s na die uur";
};
af.prototype.atX0MinutesPastTheHour = function () {
return "teen %s minute na die uur";
};
af.prototype.everyX0Hours = function () {
return "elke %s ure";
};
af.prototype.betweenX0AndX1 = function () {
return "tussen %s en %s";
};
af.prototype.atX0 = function () {
return "teen %s";
};
af.prototype.commaEveryDay = function () {
return ", elke dag";
};
af.prototype.commaEveryX0DaysOfTheWeek = function () {
return ", elke %s dae van die week";
};
af.prototype.commaX0ThroughX1 = function () {
return ", %s deur na %s";
};
af.prototype.commaAndX0ThroughX1 = function () {
return ", en %s deur na %s";
};
af.prototype.first = function () {
return "eerste";
};
af.prototype.second = function () {
return "tweede";
};
af.prototype.third = function () {
return "derde";
};
af.prototype.fourth = function () {
return "vierde";
};
af.prototype.fifth = function () {
return "vyfde";
};
af.prototype.commaOnThe = function () {
return ", op die ";
};
af.prototype.spaceX0OfTheMonth = function () {
return " %s van die maand";
};
af.prototype.lastDay = function () {
return "die laaste dag";
};
af.prototype.commaOnTheLastX0OfTheMonth = function () {
return ", op die laaste %s van die maand";
};
af.prototype.commaOnlyOnX0 = function () {
return ", net op %s";
};
af.prototype.commaAndOnX0 = function () {
return ", en op %s";
};
af.prototype.commaEveryX0Months = function () {
return ", elke %s maande";
};
af.prototype.commaOnlyInX0 = function () {
return ", net in %s";
};
af.prototype.commaOnTheLastDayOfTheMonth = function () {
return ", op die laaste dag van die maand";
};
af.prototype.commaOnTheLastWeekdayOfTheMonth = function () {
return ", op die laaste weeksdag van die maand";
};
af.prototype.commaDaysBeforeTheLastDayOfTheMonth = function () {
return ", %s dae voor die laaste dag van die maand";
};
af.prototype.firstWeekday = function () {
return "eerste weeksdag";
};
af.prototype.weekdayNearestDayX0 = function () {
return "weeksdag naaste aan dag %s";
};
af.prototype.commaOnTheX0OfTheMonth = function () {
return ", op die %s van die maande";
};
af.prototype.commaEveryX0Days = function () {
return ", elke %s dae";
};
af.prototype.commaBetweenDayX0AndX1OfTheMonth = function () {
return ", tussen dag %s en %s van die maand";
};
af.prototype.commaOnDayX0OfTheMonth = function () {
return ", op dag %s van die maand";
};
af.prototype.commaEveryHour = function () {
return ", elke uur";
};
af.prototype.commaEveryX0Years = function () {
return ", elke %s jare";
};
af.prototype.commaStartingX0 = function () {
return ", beginnende %s";
};
af.prototype.daysOfTheWeek = function () {
return ["Sondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrydag", "Saterdag"];
};
af.prototype.monthsOfTheYear = function () {
return [
"Januarie",
"Februarie",
"Maart",
"April",
"Mei",
"Junie",
"Julie",
"Augustus",
"September",
"Oktober",
"November",
"Desember",
];
};
return af;
}());
exports.af = af;
/***/ }),
/***/ 574:
/***/ ((__unused_webpack_module, exports) => {
Object.defineProperty(exports, "__esModule", ({ value: true }));
exports.ar = void 0;
var ar = (function () {
function ar() {
}
ar.prototype.atX0SecondsPastTheMinuteGt20 = function () {
return null;
};
ar.prototype.atX0MinutesPastTheHourGt20 = function () {
return null;
};
ar.prototype.commaMonthX0ThroughMonthX1 = function () {
return null;
};
ar.prototype.commaYearX0ThroughYearX1 = function () {
return null;
};
ar.prototype.use24HourTimeFormatByDefault = function () {
return true;
};
ar.prototype.anErrorOccuredWhenGeneratingTheExpressionD = function () {
return "حدث خطأ في إنشاء وصف المصطلح٠ تأكد من تركيب مصطلح الكرون";
};
ar.prototype.everyMinute = function () {
return "كل دقيقة";
};
ar.prototype.everyHour = function () {
return "كل ساعة";
};
ar.prototype.atSpace = function () {
return " ";
};
ar.prototype.everyMinuteBetweenX0AndX1 = function () {
return "كل دقيقة بين %s و %s";
};
ar.prototype.at = function () {
return "";
};
ar.prototype.spaceAnd = function () {
return " و";