cronstrue 3.44.0 → 3.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cronstrue-i18n.js +324 -889
- package/dist/cronstrue-i18n.min.js +1 -1
- package/dist/cronstrue.js +243 -346
- package/dist/cronstrue.min.js +1 -1
- package/dist/expressionDescriptor.d.ts +16 -9
- package/dist/i18n/allLocales.d.ts +6 -6
- package/dist/i18n/locale.d.ts +4 -4
- package/dist/i18n/locales/af.d.ts +1 -4
- package/dist/i18n/locales/ar.d.ts +0 -4
- package/dist/i18n/locales/az.d.ts +2 -4
- package/dist/i18n/locales/be.d.ts +0 -4
- package/dist/i18n/locales/bg.d.ts +1 -5
- package/dist/i18n/locales/ca.d.ts +0 -4
- package/dist/i18n/locales/cs.d.ts +0 -4
- package/dist/i18n/locales/da.d.ts +0 -4
- package/dist/i18n/locales/de.d.ts +0 -4
- package/dist/i18n/locales/en.d.ts +4 -6
- package/dist/i18n/locales/es.d.ts +0 -4
- package/dist/i18n/locales/fa.d.ts +0 -4
- package/dist/i18n/locales/fi.d.ts +1 -4
- package/dist/i18n/locales/fr.d.ts +0 -4
- package/dist/i18n/locales/he.d.ts +0 -4
- package/dist/i18n/locales/hr.d.ts +0 -4
- package/dist/i18n/locales/hu.d.ts +0 -4
- package/dist/i18n/locales/id.d.ts +0 -4
- package/dist/i18n/locales/it.d.ts +0 -4
- package/dist/i18n/locales/ja.d.ts +0 -4
- package/dist/i18n/locales/ko.d.ts +0 -4
- package/dist/i18n/locales/my.d.ts +0 -4
- package/dist/i18n/locales/nb.d.ts +0 -4
- package/dist/i18n/locales/nl.d.ts +0 -4
- package/dist/i18n/locales/nn.d.ts +0 -4
- package/dist/i18n/locales/pl.d.ts +0 -4
- package/dist/i18n/locales/pt_BR.d.ts +0 -4
- package/dist/i18n/locales/pt_PT.d.ts +0 -4
- package/dist/i18n/locales/ru.d.ts +0 -4
- package/dist/i18n/locales/sk.d.ts +0 -4
- package/dist/i18n/locales/sl.d.ts +0 -4
- package/dist/i18n/locales/sr.d.ts +0 -4
- package/dist/i18n/locales/sv.d.ts +0 -4
- package/dist/i18n/locales/sw.d.ts +0 -4
- package/dist/i18n/locales/tg.d.ts +0 -4
- package/dist/i18n/locales/th.d.ts +0 -4
- package/dist/i18n/locales/tr.d.ts +0 -4
- package/dist/i18n/locales/uk.d.ts +0 -4
- package/dist/i18n/locales/vi.d.ts +0 -4
- package/dist/i18n/locales/zh_CN.d.ts +1 -4
- package/dist/i18n/locales/zh_TW.d.ts +1 -4
- package/locales/af.js +0 -9
- package/locales/af.min.js +1 -1
- package/locales/ar.js +0 -12
- package/locales/ar.min.js +1 -1
- package/locales/az.js +0 -6
- package/locales/az.min.js +1 -1
- package/locales/be.js +0 -12
- package/locales/be.min.js +1 -1
- package/locales/bg.js +69 -65
- package/locales/bg.min.js +1 -1
- package/locales/ca.js +0 -12
- package/locales/ca.min.js +1 -1
- package/locales/cs.js +0 -12
- package/locales/cs.min.js +1 -1
- package/locales/da.js +0 -12
- package/locales/da.min.js +1 -1
- package/locales/de.js +0 -12
- package/locales/de.min.js +1 -1
- package/locales/en.js +6 -12
- package/locales/en.min.js +1 -1
- package/locales/es.js +0 -12
- package/locales/es.min.js +1 -1
- package/locales/fa.js +0 -12
- package/locales/fa.min.js +1 -1
- package/locales/fi.js +0 -9
- package/locales/fi.min.js +1 -1
- package/locales/fr.js +0 -12
- package/locales/fr.min.js +1 -1
- package/locales/he.js +0 -12
- package/locales/he.min.js +1 -1
- package/locales/hr.js +1 -21
- package/locales/hr.min.js +1 -1
- package/locales/hu.js +0 -12
- package/locales/hu.min.js +1 -1
- package/locales/id.js +0 -12
- package/locales/id.min.js +1 -1
- package/locales/it.js +0 -12
- package/locales/it.min.js +1 -1
- package/locales/ja.js +0 -12
- package/locales/ja.min.js +1 -1
- package/locales/ko.js +0 -12
- package/locales/ko.min.js +1 -1
- package/locales/my.js +0 -12
- package/locales/my.min.js +1 -1
- package/locales/nb.js +0 -12
- package/locales/nb.min.js +1 -1
- package/locales/nl.js +0 -12
- package/locales/nl.min.js +1 -1
- package/locales/nn.js +0 -12
- package/locales/nn.min.js +1 -1
- package/locales/pl.js +0 -12
- package/locales/pl.min.js +1 -1
- package/locales/pt_BR.js +6 -18
- package/locales/pt_BR.min.js +1 -1
- package/locales/pt_PT.js +6 -18
- package/locales/pt_PT.min.js +1 -1
- package/locales/ru.js +0 -12
- package/locales/ru.min.js +1 -1
- package/locales/sk.js +0 -12
- package/locales/sk.min.js +1 -1
- package/locales/sl.js +0 -12
- package/locales/sl.min.js +1 -1
- package/locales/sr.js +1 -21
- package/locales/sr.min.js +1 -1
- package/locales/sv.js +0 -12
- package/locales/sv.min.js +1 -1
- package/locales/sw.js +0 -12
- package/locales/sw.min.js +1 -1
- package/locales/tg.js +0 -12
- package/locales/tg.min.js +1 -1
- package/locales/th.js +0 -12
- package/locales/th.min.js +1 -1
- package/locales/tr.js +0 -12
- package/locales/tr.min.js +1 -1
- package/locales/uk.js +0 -12
- package/locales/uk.min.js +1 -1
- package/locales/vi.js +0 -12
- package/locales/vi.min.js +1 -1
- package/locales/zh_CN.js +0 -9
- package/locales/zh_CN.min.js +1 -1
- package/locales/zh_TW.js +0 -9
- package/locales/zh_TW.min.js +1 -1
- package/package.json +10 -11
package/dist/cronstrue.js
CHANGED
|
@@ -19,6 +19,22 @@ return /******/ (() => { // webpackBootstrap
|
|
|
19
19
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
20
20
|
exports.CronParser = void 0;
|
|
21
21
|
var rangeValidator_1 = __webpack_require__(9515);
|
|
22
|
+
var DAYS = { SUN: 0, MON: 1, TUE: 2, WED: 3, THU: 4, FRI: 5, SAT: 6 };
|
|
23
|
+
var MONTHS = {
|
|
24
|
+
JAN: 1,
|
|
25
|
+
FEB: 2,
|
|
26
|
+
MAR: 3,
|
|
27
|
+
APR: 4,
|
|
28
|
+
MAY: 5,
|
|
29
|
+
JUN: 6,
|
|
30
|
+
JUL: 7,
|
|
31
|
+
AUG: 8,
|
|
32
|
+
SEP: 9,
|
|
33
|
+
OCT: 10,
|
|
34
|
+
NOV: 11,
|
|
35
|
+
DEC: 12,
|
|
36
|
+
};
|
|
37
|
+
var STEP_RANGE_THROUGH = { 4: "12", 5: "6", 6: "9999" };
|
|
22
38
|
var CronParser = (function () {
|
|
23
39
|
function CronParser(expression, dayOfWeekStartIndexZero, monthStartIndexZero) {
|
|
24
40
|
if (dayOfWeekStartIndexZero === void 0) { dayOfWeekStartIndexZero = true; }
|
|
@@ -30,12 +46,12 @@ var CronParser = (function () {
|
|
|
30
46
|
CronParser.prototype.parse = function () {
|
|
31
47
|
var _a;
|
|
32
48
|
var parsed;
|
|
33
|
-
var expression = (_a = this.expression) !== null && _a !== void 0 ? _a :
|
|
49
|
+
var expression = (_a = this.expression) !== null && _a !== void 0 ? _a : "";
|
|
34
50
|
if (expression === "@reboot") {
|
|
35
51
|
parsed = ["@reboot", "", "", "", "", "", ""];
|
|
36
52
|
return parsed;
|
|
37
53
|
}
|
|
38
|
-
else if (expression.startsWith(
|
|
54
|
+
else if (expression.startsWith("@")) {
|
|
39
55
|
var special = this.parseSpecial(this.expression);
|
|
40
56
|
parsed = this.extractParts(special);
|
|
41
57
|
}
|
|
@@ -48,18 +64,17 @@ var CronParser = (function () {
|
|
|
48
64
|
};
|
|
49
65
|
CronParser.prototype.parseSpecial = function (expression) {
|
|
50
66
|
var specialExpressions = {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
'@reboot': '@reboot'
|
|
67
|
+
"@yearly": "0 0 1 JAN *",
|
|
68
|
+
"@annually": "0 0 1 JAN *",
|
|
69
|
+
"@monthly": "0 0 1 * *",
|
|
70
|
+
"@weekly": "0 0 * * SUN",
|
|
71
|
+
"@daily": "0 0 * * *",
|
|
72
|
+
"@midnight": "0 0 * * *",
|
|
73
|
+
"@hourly": "0 * * * *",
|
|
59
74
|
};
|
|
60
75
|
var special = specialExpressions[expression];
|
|
61
76
|
if (!special) {
|
|
62
|
-
throw new Error(
|
|
77
|
+
throw new Error("Unknown special expression.");
|
|
63
78
|
}
|
|
64
79
|
return special;
|
|
65
80
|
};
|
|
@@ -112,23 +127,15 @@ var CronParser = (function () {
|
|
|
112
127
|
expressionParts[3] = expressionParts[3].replace("?", "*");
|
|
113
128
|
expressionParts[5] = expressionParts[5].replace("?", "*");
|
|
114
129
|
expressionParts[2] = expressionParts[2].replace("?", "*");
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (expressionParts[3].indexOf("1/") == 0) {
|
|
125
|
-
expressionParts[3] = expressionParts[3].replace("1/", "*/");
|
|
126
|
-
}
|
|
127
|
-
if (!this.monthStartIndexZero && expressionParts[4].indexOf("1/") == 0) {
|
|
128
|
-
expressionParts[4] = expressionParts[4].replace("1/", "*/");
|
|
129
|
-
}
|
|
130
|
-
if (expressionParts[6].indexOf("1/") == 0) {
|
|
131
|
-
expressionParts[6] = expressionParts[6].replace("1/", "*/");
|
|
130
|
+
var firstValueSteps = { 0: "0/", 1: "0/", 2: "0/", 3: "1/", 6: "1/" };
|
|
131
|
+
if (!this.monthStartIndexZero) {
|
|
132
|
+
firstValueSteps[4] = "1/";
|
|
133
|
+
}
|
|
134
|
+
for (var _i = 0, _a = Object.keys(firstValueSteps).map(Number); _i < _a.length; _i++) {
|
|
135
|
+
var index = _a[_i];
|
|
136
|
+
if (expressionParts[index].indexOf(firstValueSteps[index]) == 0) {
|
|
137
|
+
expressionParts[index] = expressionParts[index].replace(firstValueSteps[index], "*/");
|
|
138
|
+
}
|
|
132
139
|
}
|
|
133
140
|
if (this.dayOfWeekStartIndexZero) {
|
|
134
141
|
expressionParts[5] = expressionParts[5]
|
|
@@ -153,55 +160,29 @@ var CronParser = (function () {
|
|
|
153
160
|
.split(",")
|
|
154
161
|
.map(function (item) { return (item == "L" ? "6" : item); })
|
|
155
162
|
.join(",");
|
|
156
|
-
if (expressionParts[3] == "?") {
|
|
157
|
-
expressionParts[3] = "*";
|
|
158
|
-
}
|
|
159
163
|
var weekdayOffsetRegex = /^\d{1,2}W[+-]\d{1,2}$/;
|
|
160
164
|
if (expressionParts[3].indexOf("W") > -1 &&
|
|
161
165
|
(expressionParts[3].indexOf(",") > -1 || /[-+]/.test(expressionParts[3])) &&
|
|
162
166
|
!weekdayOffsetRegex.test(expressionParts[3])) {
|
|
163
167
|
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.");
|
|
164
168
|
}
|
|
165
|
-
var
|
|
166
|
-
|
|
167
|
-
MON: 1,
|
|
168
|
-
TUE: 2,
|
|
169
|
-
WED: 3,
|
|
170
|
-
THU: 4,
|
|
171
|
-
FRI: 5,
|
|
172
|
-
SAT: 6,
|
|
173
|
-
};
|
|
174
|
-
for (var day in days) {
|
|
175
|
-
expressionParts[5] = expressionParts[5].replace(new RegExp(day, "gi"), days[day].toString());
|
|
169
|
+
for (var day in DAYS) {
|
|
170
|
+
expressionParts[5] = expressionParts[5].replace(new RegExp(day, "gi"), DAYS[day].toString());
|
|
176
171
|
}
|
|
177
172
|
expressionParts[5] = expressionParts[5]
|
|
178
173
|
.split(",")
|
|
179
174
|
.filter(function (item, index, items) { return item === "" || items.indexOf(item) === index; })
|
|
180
175
|
.join(",");
|
|
181
176
|
expressionParts[4] = expressionParts[4].replace(/(^\d{1,2})|([^#/\s\d]\d{1,2})/g, function (t) {
|
|
182
|
-
var
|
|
183
|
-
var
|
|
177
|
+
var monthDigits = t.replace(/\D/, "");
|
|
178
|
+
var monthDigitsAdjusted = monthDigits;
|
|
184
179
|
if (_this.monthStartIndexZero) {
|
|
185
|
-
|
|
180
|
+
monthDigitsAdjusted = (parseInt(monthDigits) + 1).toString();
|
|
186
181
|
}
|
|
187
|
-
return t.replace(
|
|
182
|
+
return t.replace(monthDigits, monthDigitsAdjusted);
|
|
188
183
|
});
|
|
189
|
-
var
|
|
190
|
-
|
|
191
|
-
FEB: 2,
|
|
192
|
-
MAR: 3,
|
|
193
|
-
APR: 4,
|
|
194
|
-
MAY: 5,
|
|
195
|
-
JUN: 6,
|
|
196
|
-
JUL: 7,
|
|
197
|
-
AUG: 8,
|
|
198
|
-
SEP: 9,
|
|
199
|
-
OCT: 10,
|
|
200
|
-
NOV: 11,
|
|
201
|
-
DEC: 12,
|
|
202
|
-
};
|
|
203
|
-
for (var month in months) {
|
|
204
|
-
expressionParts[4] = expressionParts[4].replace(new RegExp(month, "gi"), months[month].toString());
|
|
184
|
+
for (var month in MONTHS) {
|
|
185
|
+
expressionParts[4] = expressionParts[4].replace(new RegExp(month, "gi"), MONTHS[month].toString());
|
|
205
186
|
}
|
|
206
187
|
if (expressionParts[0] == "0") {
|
|
207
188
|
expressionParts[0] = "";
|
|
@@ -221,26 +202,10 @@ var CronParser = (function () {
|
|
|
221
202
|
if (expressionParts[i] == "*/1") {
|
|
222
203
|
expressionParts[i] = "*";
|
|
223
204
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
stepRangeThrough = "12";
|
|
229
|
-
break;
|
|
230
|
-
case 5:
|
|
231
|
-
stepRangeThrough = "6";
|
|
232
|
-
break;
|
|
233
|
-
case 6:
|
|
234
|
-
stepRangeThrough = "9999";
|
|
235
|
-
break;
|
|
236
|
-
default:
|
|
237
|
-
stepRangeThrough = null;
|
|
238
|
-
break;
|
|
239
|
-
}
|
|
240
|
-
if (stepRangeThrough !== null) {
|
|
241
|
-
var parts = expressionParts[i].split("/");
|
|
242
|
-
expressionParts[i] = "".concat(parts[0], "-").concat(stepRangeThrough, "/").concat(parts[1]);
|
|
243
|
-
}
|
|
205
|
+
var stepRangeThrough = STEP_RANGE_THROUGH[i];
|
|
206
|
+
if (stepRangeThrough && expressionParts[i].indexOf("/") > -1 && !/^\*|\-|\,/.test(expressionParts[i])) {
|
|
207
|
+
var parts = expressionParts[i].split("/");
|
|
208
|
+
expressionParts[i] = "".concat(parts[0], "-").concat(stepRangeThrough, "/").concat(parts[1]);
|
|
244
209
|
}
|
|
245
210
|
}
|
|
246
211
|
};
|
|
@@ -281,15 +246,28 @@ exports.CronParser = CronParser;
|
|
|
281
246
|
(__unused_webpack_module, exports, __webpack_require__) {
|
|
282
247
|
|
|
283
248
|
|
|
249
|
+
var __assign = (this && this.__assign) || function () {
|
|
250
|
+
__assign = Object.assign || function(t) {
|
|
251
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
252
|
+
s = arguments[i];
|
|
253
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
254
|
+
t[p] = s[p];
|
|
255
|
+
}
|
|
256
|
+
return t;
|
|
257
|
+
};
|
|
258
|
+
return __assign.apply(this, arguments);
|
|
259
|
+
};
|
|
284
260
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
285
261
|
exports.ExpressionDescriptor = void 0;
|
|
286
262
|
var stringUtilities_1 = __webpack_require__(1823);
|
|
287
263
|
var cronParser_1 = __webpack_require__(6949);
|
|
264
|
+
var en_1 = __webpack_require__(9486);
|
|
265
|
+
var english = new en_1.en();
|
|
288
266
|
var ExpressionDescriptor = (function () {
|
|
289
267
|
function ExpressionDescriptor(expression, options) {
|
|
290
268
|
this.expression = expression;
|
|
291
269
|
this.options = options;
|
|
292
|
-
this.expressionParts =
|
|
270
|
+
this.expressionParts = [];
|
|
293
271
|
if (!this.options.locale && ExpressionDescriptor.defaultLocale) {
|
|
294
272
|
this.options.locale = ExpressionDescriptor.defaultLocale;
|
|
295
273
|
}
|
|
@@ -315,11 +293,7 @@ var ExpressionDescriptor = (function () {
|
|
|
315
293
|
locale: locale,
|
|
316
294
|
logicalAndDayFields: logicalAndDayFields,
|
|
317
295
|
};
|
|
318
|
-
|
|
319
|
-
console.warn("'tzOffset' option has been deprecated and is no longer supported.");
|
|
320
|
-
}
|
|
321
|
-
var descripter = new ExpressionDescriptor(expression, options);
|
|
322
|
-
return descripter.getFullDescription();
|
|
296
|
+
return new ExpressionDescriptor(expression, options).getFullDescription();
|
|
323
297
|
};
|
|
324
298
|
ExpressionDescriptor.initialize = function (localesLoader, defaultLocale) {
|
|
325
299
|
if (defaultLocale === void 0) { defaultLocale = "en"; }
|
|
@@ -334,7 +308,7 @@ var ExpressionDescriptor = (function () {
|
|
|
334
308
|
var parser = new cronParser_1.CronParser(this.expression, this.options.dayOfWeekStartIndexZero, this.options.monthStartIndexZero);
|
|
335
309
|
this.expressionParts = parser.parse();
|
|
336
310
|
if (this.expressionParts[0] === "@reboot") {
|
|
337
|
-
return ((_b = (_a = this.i18n).atReboot) === null || _b === void 0 ? void 0 : _b.call(_a)) ||
|
|
311
|
+
return ((_b = (_a = this.i18n).atReboot) === null || _b === void 0 ? void 0 : _b.call(_a)) || english.atReboot();
|
|
338
312
|
}
|
|
339
313
|
var timeSegment = this.getTimeOfDayDescription();
|
|
340
314
|
var dayOfMonthDesc = this.getDayOfMonthDescription();
|
|
@@ -343,7 +317,7 @@ var ExpressionDescriptor = (function () {
|
|
|
343
317
|
var yearDesc = this.getYearDescription();
|
|
344
318
|
description += timeSegment + dayOfMonthDesc + dayOfWeekDesc + monthDesc + yearDesc;
|
|
345
319
|
description = this.transformVerbosity(description, !!this.options.verbose);
|
|
346
|
-
description = description.charAt(0).toLocaleUpperCase() + description.
|
|
320
|
+
description = description.charAt(0).toLocaleUpperCase() + description.substring(1);
|
|
347
321
|
}
|
|
348
322
|
catch (ex) {
|
|
349
323
|
if (!this.options.throwExceptionOnParseError) {
|
|
@@ -414,47 +388,43 @@ var ExpressionDescriptor = (function () {
|
|
|
414
388
|
};
|
|
415
389
|
ExpressionDescriptor.prototype.getSecondsDescription = function () {
|
|
416
390
|
var _this = this;
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Seconds(s), s);
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
391
|
+
return this.getSegmentDescription(this.expressionParts[0], {
|
|
392
|
+
all: this.i18n.everySecond(),
|
|
393
|
+
single: function (s) { return s; },
|
|
394
|
+
increment: function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Seconds(s), s); },
|
|
395
|
+
range: function () { return _this.i18n.secondsX0ThroughX1PastTheMinute(); },
|
|
396
|
+
format: function (s) {
|
|
397
|
+
var _a, _b;
|
|
398
|
+
return s == "0"
|
|
399
|
+
? ""
|
|
400
|
+
: parseInt(s) < 20
|
|
401
|
+
? _this.i18n.atX0SecondsPastTheMinute(s)
|
|
402
|
+
: ((_b = (_a = _this.i18n).atX0SecondsPastTheMinuteGt20) === null || _b === void 0 ? void 0 : _b.call(_a)) || _this.i18n.atX0SecondsPastTheMinute(s);
|
|
403
|
+
},
|
|
404
|
+
bounds: { min: 0, max: 59 },
|
|
405
|
+
});
|
|
431
406
|
};
|
|
432
407
|
ExpressionDescriptor.prototype.getMinutesDescription = function () {
|
|
433
408
|
var _this = this;
|
|
434
409
|
var secondsExpression = this.expressionParts[0];
|
|
435
410
|
var hourExpression = this.expressionParts[2];
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Minutes(s), s);
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
var _a, _b;
|
|
444
|
-
try {
|
|
411
|
+
return this.getSegmentDescription(this.expressionParts[1], {
|
|
412
|
+
all: this.i18n.everyMinute(),
|
|
413
|
+
single: function (s) { return s; },
|
|
414
|
+
increment: function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Minutes(s), s); },
|
|
415
|
+
range: function () { return _this.i18n.minutesX0ThroughX1PastTheHour(); },
|
|
416
|
+
format: function (s) {
|
|
417
|
+
var _a, _b, _c, _d;
|
|
445
418
|
return s == "0" && hourExpression.indexOf("/") == -1 && secondsExpression == ""
|
|
446
419
|
? _this.i18n.everyHour()
|
|
447
420
|
: s == "0"
|
|
448
421
|
? ((_b = (_a = _this.i18n).onTheHour) === null || _b === void 0 ? void 0 : _b.call(_a)) || _this.i18n.atX0MinutesPastTheHour(s)
|
|
449
422
|
: parseInt(s) < 20
|
|
450
423
|
? _this.i18n.atX0MinutesPastTheHour(s)
|
|
451
|
-
: _this.i18n.atX0MinutesPastTheHourGt20() || _this.i18n.atX0MinutesPastTheHour(s);
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
}, { min: 0, max: 59 });
|
|
457
|
-
return description;
|
|
424
|
+
: ((_d = (_c = _this.i18n).atX0MinutesPastTheHourGt20) === null || _d === void 0 ? void 0 : _d.call(_c)) || _this.i18n.atX0MinutesPastTheHour(s);
|
|
425
|
+
},
|
|
426
|
+
bounds: { min: 0, max: 59 },
|
|
427
|
+
});
|
|
458
428
|
};
|
|
459
429
|
ExpressionDescriptor.prototype.getHoursDescription = function () {
|
|
460
430
|
var _this = this;
|
|
@@ -472,23 +442,22 @@ var ExpressionDescriptor = (function () {
|
|
|
472
442
|
hourIndex += rangeParts.length;
|
|
473
443
|
});
|
|
474
444
|
var evaluationIndex = 0;
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
return _this.i18n.
|
|
484
|
-
|
|
485
|
-
return _this.i18n.atX0();
|
|
486
|
-
|
|
487
|
-
|
|
445
|
+
return this.getSegmentDescription(expression, {
|
|
446
|
+
all: this.i18n.everyHour(),
|
|
447
|
+
single: function (s) {
|
|
448
|
+
var match = rangeEndValues.find(function (r) { return r.value === s && r.index === evaluationIndex; });
|
|
449
|
+
var isRangeEndWithNonZeroMinute = match && _this.expressionParts[1] !== "0";
|
|
450
|
+
evaluationIndex++;
|
|
451
|
+
return isRangeEndWithNonZeroMinute ? _this.formatTime(s, "59", "") : _this.formatTime(s, "0", "");
|
|
452
|
+
},
|
|
453
|
+
increment: function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.everyX0Hours(s), s); },
|
|
454
|
+
range: function () { return _this.i18n.betweenX0AndX1(); },
|
|
455
|
+
format: function () { return _this.i18n.atX0(); },
|
|
456
|
+
bounds: { min: 0, max: 23 },
|
|
457
|
+
});
|
|
488
458
|
};
|
|
489
459
|
ExpressionDescriptor.prototype.getDayOfWeekDescription = function (dayOfWeekExpression) {
|
|
490
460
|
var _this = this;
|
|
491
|
-
var _a, _b, _c, _d;
|
|
492
461
|
if (dayOfWeekExpression === void 0) { dayOfWeekExpression = this.expressionParts[5]; }
|
|
493
462
|
var daysOfWeekNames = this.i18n.daysOfTheWeek();
|
|
494
463
|
var description = null;
|
|
@@ -497,92 +466,76 @@ var ExpressionDescriptor = (function () {
|
|
|
497
466
|
}
|
|
498
467
|
else {
|
|
499
468
|
var dayOfWeekItems = dayOfWeekExpression.split(",");
|
|
469
|
+
var describeSeparately = function (items, otherItems) {
|
|
470
|
+
var _a, _b;
|
|
471
|
+
return ((_a = _this.getDayOfWeekDescription(items.join(","))) !== null && _a !== void 0 ? _a : "") +
|
|
472
|
+
"".concat(_this.i18n.spaceAnd(), " ") +
|
|
473
|
+
ExpressionDescriptor.removeLeadingComma((_b = _this.getDayOfWeekDescription(otherItems.join(","))) !== null && _b !== void 0 ? _b : "");
|
|
474
|
+
};
|
|
500
475
|
var nthOrLastItems = dayOfWeekItems.filter(function (s) { return /[#L]/.test(s); });
|
|
501
476
|
var plainItems = dayOfWeekItems.filter(function (s) { return !/[#L]/.test(s); });
|
|
502
477
|
if (plainItems.length > 0 && nthOrLastItems.some(function (s) { return s.indexOf("#") > -1; })) {
|
|
503
|
-
|
|
504
|
-
return (((_b = this.getDayOfWeekDescription(plainItems.join(","))) !== null && _b !== void 0 ? _b : "") +
|
|
505
|
-
"".concat(this.i18n.spaceAnd(), " ") +
|
|
506
|
-
ExpressionDescriptor.removeLeadingComma(nthOrLastDescription));
|
|
478
|
+
return describeSeparately(plainItems, nthOrLastItems);
|
|
507
479
|
}
|
|
508
480
|
var lastItems = dayOfWeekItems.filter(function (s) { return s.indexOf("L") > -1; });
|
|
509
481
|
var otherItems = dayOfWeekItems.filter(function (s) { return s.indexOf("L") === -1; });
|
|
510
482
|
if (lastItems.length > 0 && otherItems.length > 0) {
|
|
511
|
-
|
|
512
|
-
return (((_d = this.getDayOfWeekDescription(otherItems.join(","))) !== null && _d !== void 0 ? _d : "") +
|
|
513
|
-
"".concat(this.i18n.spaceAnd(), " ") +
|
|
514
|
-
ExpressionDescriptor.removeLeadingComma(lastDescription));
|
|
483
|
+
return describeSeparately(otherItems, lastItems);
|
|
515
484
|
}
|
|
516
|
-
description = this.getSegmentDescription(dayOfWeekExpression,
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
exp = s
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
exp = exp.replace("L", "");
|
|
523
|
-
}
|
|
524
|
-
var parsedExp = parseInt(exp);
|
|
525
|
-
var description = _this.i18n.daysOfTheWeekInCase
|
|
526
|
-
? _this.i18n.daysOfTheWeekInCase(form)[parsedExp]
|
|
527
|
-
: daysOfWeekNames[parsedExp];
|
|
528
|
-
if (s.indexOf("#") > -1) {
|
|
529
|
-
var dayOfWeekOfMonthDescription = null;
|
|
530
|
-
var dayOfWeekOfMonthNumber = s.substring(s.indexOf("#") + 1);
|
|
531
|
-
var dayOfWeekNumber = s.substring(0, s.indexOf("#"));
|
|
532
|
-
switch (dayOfWeekOfMonthNumber) {
|
|
533
|
-
case "1":
|
|
534
|
-
dayOfWeekOfMonthDescription = _this.i18n.first(dayOfWeekNumber);
|
|
535
|
-
break;
|
|
536
|
-
case "2":
|
|
537
|
-
dayOfWeekOfMonthDescription = _this.i18n.second(dayOfWeekNumber);
|
|
538
|
-
break;
|
|
539
|
-
case "3":
|
|
540
|
-
dayOfWeekOfMonthDescription = _this.i18n.third(dayOfWeekNumber);
|
|
541
|
-
break;
|
|
542
|
-
case "4":
|
|
543
|
-
dayOfWeekOfMonthDescription = _this.i18n.fourth(dayOfWeekNumber);
|
|
544
|
-
break;
|
|
545
|
-
case "5":
|
|
546
|
-
dayOfWeekOfMonthDescription = _this.i18n.fifth(dayOfWeekNumber);
|
|
547
|
-
break;
|
|
485
|
+
description = this.getSegmentDescription(dayOfWeekExpression, {
|
|
486
|
+
all: this.i18n.commaEveryDay(),
|
|
487
|
+
single: function (s, form) {
|
|
488
|
+
var exp = s;
|
|
489
|
+
if (s.indexOf("#") > -1) {
|
|
490
|
+
exp = s.substring(0, s.indexOf("#"));
|
|
548
491
|
}
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
}
|
|
570
|
-
else if (s.indexOf("L") > -1) {
|
|
571
|
-
format = _this.i18n.commaOnTheLastX0OfTheMonth(s.replace("L", ""));
|
|
572
|
-
}
|
|
573
|
-
else {
|
|
492
|
+
else if (s.indexOf("L") > -1) {
|
|
493
|
+
exp = exp.replace("L", "");
|
|
494
|
+
}
|
|
495
|
+
var parsedExp = parseInt(exp);
|
|
496
|
+
var description = _this.i18n.daysOfTheWeekInCase
|
|
497
|
+
? _this.i18n.daysOfTheWeekInCase(form)[parsedExp]
|
|
498
|
+
: daysOfWeekNames[parsedExp];
|
|
499
|
+
if (s.indexOf("#") > -1) {
|
|
500
|
+
var dayOfWeekOfMonthNumber = parseInt(s.substring(s.indexOf("#") + 1));
|
|
501
|
+
var dayOfWeekNumber = s.substring(0, s.indexOf("#"));
|
|
502
|
+
var ordinal = ExpressionDescriptor.ordinals[dayOfWeekOfMonthNumber - 1];
|
|
503
|
+
description = _this.i18n[ordinal](dayOfWeekNumber) + " " + description;
|
|
504
|
+
}
|
|
505
|
+
return description;
|
|
506
|
+
},
|
|
507
|
+
increment: function (s) {
|
|
508
|
+
return parseInt(s) == 1 ? "" : stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0DaysOfTheWeek(s), s);
|
|
509
|
+
},
|
|
510
|
+
range: function (s) {
|
|
511
|
+
var beginFrom = s.substring(0, s.indexOf("-"));
|
|
574
512
|
var domSpecified = _this.expressionParts[3] != "*";
|
|
575
|
-
|
|
576
|
-
|
|
513
|
+
return domSpecified ? _this.i18n.commaAndX0ThroughX1(beginFrom) : _this.i18n.commaX0ThroughX1(beginFrom);
|
|
514
|
+
},
|
|
515
|
+
format: function (s) {
|
|
516
|
+
var format = null;
|
|
517
|
+
if (s.indexOf("#") > -1) {
|
|
518
|
+
var dayOfWeekOfMonthNumber = s.substring(s.indexOf("#") + 1);
|
|
519
|
+
var dayOfWeek = s.substring(0, s.indexOf("#"));
|
|
520
|
+
format = _this.i18n.commaOnThe(dayOfWeekOfMonthNumber, dayOfWeek).trim() + _this.i18n.spaceX0OfTheMonth();
|
|
577
521
|
}
|
|
578
|
-
else if (
|
|
579
|
-
format = _this.i18n.
|
|
522
|
+
else if (s.indexOf("L") > -1) {
|
|
523
|
+
format = _this.i18n.commaOnTheLastX0OfTheMonth(s.split(",")[0].replace("L", ""));
|
|
580
524
|
}
|
|
581
525
|
else {
|
|
582
|
-
|
|
526
|
+
var domSpecified = _this.expressionParts[3] != "*";
|
|
527
|
+
if (!domSpecified) {
|
|
528
|
+
format = _this.i18n.commaOnlyOnX0(s);
|
|
529
|
+
}
|
|
530
|
+
else if (_this.options.logicalAndDayFields) {
|
|
531
|
+
format = _this.i18n.commaOnlyOnX0(s);
|
|
532
|
+
}
|
|
533
|
+
else {
|
|
534
|
+
format = _this.i18n.commaAndOnX0();
|
|
535
|
+
}
|
|
583
536
|
}
|
|
584
|
-
|
|
585
|
-
|
|
537
|
+
return format;
|
|
538
|
+
},
|
|
586
539
|
});
|
|
587
540
|
}
|
|
588
541
|
return description;
|
|
@@ -590,23 +543,19 @@ var ExpressionDescriptor = (function () {
|
|
|
590
543
|
ExpressionDescriptor.prototype.getMonthDescription = function () {
|
|
591
544
|
var _this = this;
|
|
592
545
|
var monthNames = this.i18n.monthsOfTheYear();
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
return _this.i18n.commaMonthX0ThroughMonthX1() || _this.i18n.commaX0ThroughX1();
|
|
606
|
-
}, function (s) {
|
|
607
|
-
return _this.i18n.commaOnlyInMonthX0 ? _this.i18n.commaOnlyInMonthX0() : _this.i18n.commaOnlyInX0();
|
|
546
|
+
return this.getSegmentDescription(this.expressionParts[4], {
|
|
547
|
+
all: "",
|
|
548
|
+
single: function (s, form) {
|
|
549
|
+
return form && _this.i18n.monthsOfTheYearInCase
|
|
550
|
+
? _this.i18n.monthsOfTheYearInCase(form)[parseInt(s) - 1]
|
|
551
|
+
: monthNames[parseInt(s) - 1];
|
|
552
|
+
},
|
|
553
|
+
increment: function (s) {
|
|
554
|
+
return parseInt(s) == 1 ? "" : stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0Months(s), s);
|
|
555
|
+
},
|
|
556
|
+
range: function () { var _a, _b; return ((_b = (_a = _this.i18n).commaMonthX0ThroughMonthX1) === null || _b === void 0 ? void 0 : _b.call(_a)) || _this.i18n.commaX0ThroughX1(); },
|
|
557
|
+
format: function () { return (_this.i18n.commaOnlyInMonthX0 ? _this.i18n.commaOnlyInMonthX0() : _this.i18n.commaOnlyInX0()); },
|
|
608
558
|
});
|
|
609
|
-
return description;
|
|
610
559
|
};
|
|
611
560
|
ExpressionDescriptor.removeLeadingComma = function (description) {
|
|
612
561
|
return description.replace(/^[,،,、] ?/, "");
|
|
@@ -662,10 +611,12 @@ var ExpressionDescriptor = (function () {
|
|
|
662
611
|
description = stringUtilities_1.StringUtilities.format(this.i18n.commaOnTheX0OfTheMonth(), dayString);
|
|
663
612
|
}
|
|
664
613
|
else if (weekDayNumberMatches[3] == "-") {
|
|
665
|
-
description = stringUtilities_1.StringUtilities.format(((_b = (_a = this.i18n).commaDaysBeforeTheX0OfTheMonth) === null || _b === void 0 ? void 0 : _b.call(_a, offsetDays)) ||
|
|
614
|
+
description = stringUtilities_1.StringUtilities.format(((_b = (_a = this.i18n).commaDaysBeforeTheX0OfTheMonth) === null || _b === void 0 ? void 0 : _b.call(_a, offsetDays)) ||
|
|
615
|
+
english.commaDaysBeforeTheX0OfTheMonth(offsetDays), offsetDays, dayString);
|
|
666
616
|
}
|
|
667
617
|
else {
|
|
668
|
-
description = stringUtilities_1.StringUtilities.format(((_d = (_c = this.i18n).commaDaysAfterTheX0OfTheMonth) === null || _d === void 0 ? void 0 : _d.call(_c, offsetDays)) ||
|
|
618
|
+
description = stringUtilities_1.StringUtilities.format(((_d = (_c = this.i18n).commaDaysAfterTheX0OfTheMonth) === null || _d === void 0 ? void 0 : _d.call(_c, offsetDays)) ||
|
|
619
|
+
english.commaDaysAfterTheX0OfTheMonth(offsetDays), offsetDays, dayString);
|
|
669
620
|
}
|
|
670
621
|
break;
|
|
671
622
|
}
|
|
@@ -680,18 +631,14 @@ var ExpressionDescriptor = (function () {
|
|
|
680
631
|
return "";
|
|
681
632
|
}
|
|
682
633
|
else {
|
|
683
|
-
description = this.getSegmentDescription(expression,
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
: _this.i18n.dayX0
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
return s == "
|
|
691
|
-
}, function (s) {
|
|
692
|
-
return _this.i18n.commaBetweenDayX0AndX1OfTheMonth(s);
|
|
693
|
-
}, function (s) {
|
|
694
|
-
return s == "L" ? _this.i18n.commaOnTheLastDayOfTheMonth() : _this.i18n.commaOnDayX0OfTheMonth(s);
|
|
634
|
+
description = this.getSegmentDescription(expression, {
|
|
635
|
+
all: this.i18n.commaEveryDay(),
|
|
636
|
+
single: function (s) {
|
|
637
|
+
return s == "L" ? _this.i18n.lastDay() : _this.i18n.dayX0 ? stringUtilities_1.StringUtilities.format(_this.i18n.dayX0(), s) : s;
|
|
638
|
+
},
|
|
639
|
+
increment: function (s) { return (s == "1" ? _this.i18n.commaEveryDay() : _this.i18n.commaEveryX0Days(s)); },
|
|
640
|
+
range: function (s) { return _this.i18n.commaBetweenDayX0AndX1OfTheMonth(s); },
|
|
641
|
+
format: function (s) { return (s == "L" ? _this.i18n.commaOnTheLastDayOfTheMonth() : _this.i18n.commaOnDayX0OfTheMonth(s)); },
|
|
695
642
|
});
|
|
696
643
|
}
|
|
697
644
|
break;
|
|
@@ -701,18 +648,16 @@ var ExpressionDescriptor = (function () {
|
|
|
701
648
|
};
|
|
702
649
|
ExpressionDescriptor.prototype.getYearDescription = function () {
|
|
703
650
|
var _this = this;
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
return stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0Years(s), s);
|
|
708
|
-
|
|
709
|
-
return _this.i18n.
|
|
710
|
-
}, function (s) {
|
|
711
|
-
return _this.i18n.commaOnlyInYearX0 ? _this.i18n.commaOnlyInYearX0() : _this.i18n.commaOnlyInX0();
|
|
651
|
+
return this.getSegmentDescription(this.expressionParts[6], {
|
|
652
|
+
all: "",
|
|
653
|
+
single: function (s) { return (/^\d+$/.test(s) ? new Date(parseInt(s), 1).getFullYear().toString() : s); },
|
|
654
|
+
increment: function (s) { return stringUtilities_1.StringUtilities.format(_this.i18n.commaEveryX0Years(s), s); },
|
|
655
|
+
range: function () { var _a, _b; return ((_b = (_a = _this.i18n).commaYearX0ThroughYearX1) === null || _b === void 0 ? void 0 : _b.call(_a)) || _this.i18n.commaX0ThroughX1(); },
|
|
656
|
+
format: function () { return (_this.i18n.commaOnlyInYearX0 ? _this.i18n.commaOnlyInYearX0() : _this.i18n.commaOnlyInX0()); },
|
|
712
657
|
});
|
|
713
|
-
return description;
|
|
714
658
|
};
|
|
715
|
-
ExpressionDescriptor.prototype.getSegmentDescription = function (expression,
|
|
659
|
+
ExpressionDescriptor.prototype.getSegmentDescription = function (expression, describers) {
|
|
660
|
+
var itemDescribers = __assign(__assign({}, describers), { bounds: undefined });
|
|
716
661
|
var description = null;
|
|
717
662
|
var doesExpressionContainIncrement = expression.indexOf("/") > -1;
|
|
718
663
|
var doesExpressionContainRange = expression.indexOf("-") > -1;
|
|
@@ -721,10 +666,10 @@ var ExpressionDescriptor = (function () {
|
|
|
721
666
|
description = "";
|
|
722
667
|
}
|
|
723
668
|
else if (expression === "*") {
|
|
724
|
-
description =
|
|
669
|
+
description = describers.all;
|
|
725
670
|
}
|
|
726
671
|
else if (!doesExpressionContainIncrement && !doesExpressionContainRange && !doesExpressionContainMultipleValues) {
|
|
727
|
-
description = stringUtilities_1.StringUtilities.format(
|
|
672
|
+
description = stringUtilities_1.StringUtilities.format(describers.format(expression), describers.single(expression));
|
|
728
673
|
}
|
|
729
674
|
else if (doesExpressionContainMultipleValues) {
|
|
730
675
|
var segments = expression.split(",");
|
|
@@ -742,17 +687,17 @@ var ExpressionDescriptor = (function () {
|
|
|
742
687
|
}
|
|
743
688
|
if (segments[i].indexOf("/") > -1 || segments[i].indexOf("-") > -1) {
|
|
744
689
|
var isSegmentRangeWithoutIncrement = segments[i].indexOf("-") > -1 && segments[i].indexOf("/") == -1;
|
|
745
|
-
var currentDescriptionContent = this.getSegmentDescription(segments[i],
|
|
690
|
+
var currentDescriptionContent = this.getSegmentDescription(segments[i], isSegmentRangeWithoutIncrement ? __assign(__assign({}, itemDescribers), { range: this.i18n.commaX0ThroughX1 }) : itemDescribers);
|
|
746
691
|
if (isSegmentRangeWithoutIncrement || i > 0) {
|
|
747
692
|
currentDescriptionContent = ExpressionDescriptor.removeLeadingComma(currentDescriptionContent);
|
|
748
693
|
}
|
|
749
694
|
descriptionContent += currentDescriptionContent;
|
|
750
695
|
}
|
|
751
696
|
else if (!doesExpressionContainIncrement) {
|
|
752
|
-
descriptionContent +=
|
|
697
|
+
descriptionContent += describers.single(segments[i]);
|
|
753
698
|
}
|
|
754
699
|
else {
|
|
755
|
-
var segmentDescription = this.getSegmentDescription(segments[i],
|
|
700
|
+
var segmentDescription = this.getSegmentDescription(segments[i], itemDescribers);
|
|
756
701
|
if (i > 0 && segmentDescription) {
|
|
757
702
|
segmentDescription = ExpressionDescriptor.removeLeadingComma(segmentDescription);
|
|
758
703
|
}
|
|
@@ -760,7 +705,7 @@ var ExpressionDescriptor = (function () {
|
|
|
760
705
|
}
|
|
761
706
|
}
|
|
762
707
|
if (!doesExpressionContainIncrement) {
|
|
763
|
-
description = stringUtilities_1.StringUtilities.format(
|
|
708
|
+
description = stringUtilities_1.StringUtilities.format(describers.format(expression), descriptionContent);
|
|
764
709
|
}
|
|
765
710
|
else {
|
|
766
711
|
description = descriptionContent;
|
|
@@ -768,27 +713,28 @@ var ExpressionDescriptor = (function () {
|
|
|
768
713
|
}
|
|
769
714
|
else if (doesExpressionContainIncrement) {
|
|
770
715
|
var segments = expression.split("/");
|
|
771
|
-
description = stringUtilities_1.StringUtilities.format(
|
|
716
|
+
description = stringUtilities_1.StringUtilities.format(describers.increment(segments[1]), segments[1]);
|
|
772
717
|
if (segments[0].indexOf("-") > -1) {
|
|
773
|
-
var rangeSegmentDescription = this.generateRangeSegmentDescription(segments[0],
|
|
718
|
+
var rangeSegmentDescription = this.generateRangeSegmentDescription(segments[0], describers);
|
|
774
719
|
if (!ExpressionDescriptor.hasLeadingComma(rangeSegmentDescription)) {
|
|
775
720
|
description += ", ";
|
|
776
721
|
}
|
|
777
722
|
description += rangeSegmentDescription;
|
|
778
723
|
}
|
|
779
724
|
else if (segments[0].indexOf("*") == -1) {
|
|
780
|
-
var rangeItemDescription = stringUtilities_1.StringUtilities.format(
|
|
725
|
+
var rangeItemDescription = stringUtilities_1.StringUtilities.format(describers.format(segments[0]), describers.single(segments[0]));
|
|
781
726
|
rangeItemDescription = ExpressionDescriptor.removeLeadingComma(rangeItemDescription);
|
|
782
727
|
description += stringUtilities_1.StringUtilities.format(this.i18n.commaStartingX0(), rangeItemDescription);
|
|
783
728
|
}
|
|
784
|
-
description += this.getWrappingIncrementDescription(expression,
|
|
729
|
+
description += this.getWrappingIncrementDescription(expression, describers);
|
|
785
730
|
}
|
|
786
731
|
else if (doesExpressionContainRange) {
|
|
787
|
-
description = this.generateRangeSegmentDescription(expression,
|
|
732
|
+
description = this.generateRangeSegmentDescription(expression, describers);
|
|
788
733
|
}
|
|
789
734
|
return description;
|
|
790
735
|
};
|
|
791
|
-
ExpressionDescriptor.prototype.getWrappingIncrementDescription = function (expression,
|
|
736
|
+
ExpressionDescriptor.prototype.getWrappingIncrementDescription = function (expression, describers) {
|
|
737
|
+
var range = describers.bounds;
|
|
792
738
|
if (!this.options.verbose || !range) {
|
|
793
739
|
return "";
|
|
794
740
|
}
|
|
@@ -808,37 +754,16 @@ var ExpressionDescriptor = (function () {
|
|
|
808
754
|
if (values.length < 2) {
|
|
809
755
|
return "";
|
|
810
756
|
}
|
|
811
|
-
var valuesDescription = this.getSegmentDescription(values.join(","),
|
|
757
|
+
var valuesDescription = this.getSegmentDescription(values.join(","), __assign(__assign({}, describers), { bounds: undefined }));
|
|
812
758
|
return valuesDescription ? ", ".concat(valuesDescription) : "";
|
|
813
759
|
};
|
|
814
|
-
ExpressionDescriptor.prototype.generateRangeSegmentDescription = function (rangeExpression,
|
|
815
|
-
var description = "";
|
|
760
|
+
ExpressionDescriptor.prototype.generateRangeSegmentDescription = function (rangeExpression, describers) {
|
|
816
761
|
var rangeSegments = rangeExpression.split("-");
|
|
817
|
-
|
|
818
|
-
var rangeSegment2Description = getSingleItemDescription(rangeSegments[1], 2);
|
|
819
|
-
var rangeDescriptionFormat = getRangeDescriptionFormat(rangeExpression);
|
|
820
|
-
description += stringUtilities_1.StringUtilities.format(rangeDescriptionFormat, rangeSegment1Description, rangeSegment2Description);
|
|
821
|
-
return description;
|
|
762
|
+
return stringUtilities_1.StringUtilities.format(describers.range(rangeExpression), describers.single(rangeSegments[0], 1), describers.single(rangeSegments[1], 2));
|
|
822
763
|
};
|
|
823
764
|
ExpressionDescriptor.prototype.formatTime = function (hourExpression, minuteExpression, secondExpression) {
|
|
824
|
-
var
|
|
825
|
-
var
|
|
826
|
-
var hour = parseInt(hourExpression) + hourOffset;
|
|
827
|
-
var minute = parseInt(minuteExpression) + minuteOffset;
|
|
828
|
-
if (minute >= 60) {
|
|
829
|
-
minute -= 60;
|
|
830
|
-
hour += 1;
|
|
831
|
-
}
|
|
832
|
-
else if (minute < 0) {
|
|
833
|
-
minute += 60;
|
|
834
|
-
hour -= 1;
|
|
835
|
-
}
|
|
836
|
-
if (hour >= 24) {
|
|
837
|
-
hour = hour - 24;
|
|
838
|
-
}
|
|
839
|
-
else if (hour < 0) {
|
|
840
|
-
hour = 24 + hour;
|
|
841
|
-
}
|
|
765
|
+
var hour = parseInt(hourExpression);
|
|
766
|
+
var minute = parseInt(minuteExpression);
|
|
842
767
|
var period = "";
|
|
843
768
|
var setPeriodBeforeTime = false;
|
|
844
769
|
if (!this.options.use24HourTimeFormat) {
|
|
@@ -878,9 +803,11 @@ var ExpressionDescriptor = (function () {
|
|
|
878
803
|
return description;
|
|
879
804
|
};
|
|
880
805
|
ExpressionDescriptor.prototype.getPeriod = function (hour) {
|
|
881
|
-
|
|
806
|
+
var _a, _b, _c, _d;
|
|
807
|
+
return hour >= 12 ? ((_b = (_a = this.i18n).pm) === null || _b === void 0 ? void 0 : _b.call(_a)) || english.pm() : ((_d = (_c = this.i18n).am) === null || _d === void 0 ? void 0 : _d.call(_c)) || english.am();
|
|
882
808
|
};
|
|
883
809
|
ExpressionDescriptor.locales = {};
|
|
810
|
+
ExpressionDescriptor.ordinals = ["first", "second", "third", "fourth", "fifth"];
|
|
884
811
|
return ExpressionDescriptor;
|
|
885
812
|
}());
|
|
886
813
|
exports.ExpressionDescriptor = ExpressionDescriptor;
|
|
@@ -918,18 +845,6 @@ var isOne = function (s) { return Number(s) === 1; };
|
|
|
918
845
|
var en = (function () {
|
|
919
846
|
function en() {
|
|
920
847
|
}
|
|
921
|
-
en.prototype.atX0SecondsPastTheMinuteGt20 = function () {
|
|
922
|
-
return null;
|
|
923
|
-
};
|
|
924
|
-
en.prototype.atX0MinutesPastTheHourGt20 = function () {
|
|
925
|
-
return null;
|
|
926
|
-
};
|
|
927
|
-
en.prototype.commaMonthX0ThroughMonthX1 = function () {
|
|
928
|
-
return null;
|
|
929
|
-
};
|
|
930
|
-
en.prototype.commaYearX0ThroughYearX1 = function () {
|
|
931
|
-
return null;
|
|
932
|
-
};
|
|
933
848
|
en.prototype.use24HourTimeFormatByDefault = function () {
|
|
934
849
|
return false;
|
|
935
850
|
};
|
|
@@ -1096,6 +1011,12 @@ var en = (function () {
|
|
|
1096
1011
|
"December",
|
|
1097
1012
|
];
|
|
1098
1013
|
};
|
|
1014
|
+
en.prototype.am = function () {
|
|
1015
|
+
return "AM";
|
|
1016
|
+
};
|
|
1017
|
+
en.prototype.pm = function () {
|
|
1018
|
+
return "PM";
|
|
1019
|
+
};
|
|
1099
1020
|
en.prototype.atReboot = function () {
|
|
1100
1021
|
return "Run once, at startup";
|
|
1101
1022
|
};
|
|
@@ -1130,73 +1051,49 @@ function rangeValues(part) {
|
|
|
1130
1051
|
}
|
|
1131
1052
|
return values;
|
|
1132
1053
|
}
|
|
1054
|
+
function assertInRange(parse, min, max, message) {
|
|
1055
|
+
for (var _i = 0, _a = parse.split(","); _i < _a.length; _i++) {
|
|
1056
|
+
var part = _a[_i];
|
|
1057
|
+
for (var _b = 0, _c = rangeValues(part); _b < _c.length; _b++) {
|
|
1058
|
+
var value = _c[_b];
|
|
1059
|
+
assert(value >= min && value <= max, message);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1133
1063
|
var RangeValidator = (function () {
|
|
1134
1064
|
function RangeValidator() {
|
|
1135
1065
|
}
|
|
1136
1066
|
RangeValidator.stepRange = function (parse) {
|
|
1137
|
-
var
|
|
1138
|
-
|
|
1139
|
-
var step =
|
|
1140
|
-
assert(step === undefined || !/^0+$/.test(step),
|
|
1067
|
+
for (var _i = 0, _a = parse.split(","); _i < _a.length; _i++) {
|
|
1068
|
+
var part = _a[_i];
|
|
1069
|
+
var step = part.split("/")[1];
|
|
1070
|
+
assert(step === undefined || !/^0+$/.test(step), "step value must be greater than 0");
|
|
1141
1071
|
}
|
|
1142
1072
|
};
|
|
1143
1073
|
RangeValidator.secondRange = function (parse) {
|
|
1144
|
-
|
|
1145
|
-
for (var i = 0; i < parsed.length; i++) {
|
|
1146
|
-
for (var _i = 0, _a = rangeValues(parsed[i]); _i < _a.length; _i++) {
|
|
1147
|
-
var second = _a[_i];
|
|
1148
|
-
assert(second >= 0 && second <= 59, 'seconds part must be >= 0 and <= 59');
|
|
1149
|
-
}
|
|
1150
|
-
}
|
|
1074
|
+
assertInRange(parse, 0, 59, "seconds part must be >= 0 and <= 59");
|
|
1151
1075
|
};
|
|
1152
1076
|
RangeValidator.minuteRange = function (parse) {
|
|
1153
|
-
|
|
1154
|
-
for (var i = 0; i < parsed.length; i++) {
|
|
1155
|
-
for (var _i = 0, _a = rangeValues(parsed[i]); _i < _a.length; _i++) {
|
|
1156
|
-
var minute = _a[_i];
|
|
1157
|
-
assert(minute >= 0 && minute <= 59, 'minutes part must be >= 0 and <= 59');
|
|
1158
|
-
}
|
|
1159
|
-
}
|
|
1077
|
+
assertInRange(parse, 0, 59, "minutes part must be >= 0 and <= 59");
|
|
1160
1078
|
};
|
|
1161
1079
|
RangeValidator.hourRange = function (parse) {
|
|
1162
|
-
|
|
1163
|
-
for (var i = 0; i < parsed.length; i++) {
|
|
1164
|
-
for (var _i = 0, _a = rangeValues(parsed[i]); _i < _a.length; _i++) {
|
|
1165
|
-
var hour = _a[_i];
|
|
1166
|
-
assert(hour >= 0 && hour <= 23, 'hours part must be >= 0 and <= 23');
|
|
1167
|
-
}
|
|
1168
|
-
}
|
|
1080
|
+
assertInRange(parse, 0, 23, "hours part must be >= 0 and <= 23");
|
|
1169
1081
|
};
|
|
1170
1082
|
RangeValidator.dayOfMonthRange = function (parse) {
|
|
1171
|
-
|
|
1172
|
-
for (var i = 0; i < parsed.length; i++) {
|
|
1173
|
-
for (var _i = 0, _a = rangeValues(parsed[i]); _i < _a.length; _i++) {
|
|
1174
|
-
var dayOfMonth = _a[_i];
|
|
1175
|
-
assert(dayOfMonth >= 1 && dayOfMonth <= 31, 'DOM part must be >= 1 and <= 31');
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1083
|
+
assertInRange(parse, 1, 31, "DOM part must be >= 1 and <= 31");
|
|
1178
1084
|
};
|
|
1179
1085
|
RangeValidator.monthRange = function (parse, monthStartIndexZero) {
|
|
1180
|
-
|
|
1181
|
-
for (var i = 0; i < parsed.length; i++) {
|
|
1182
|
-
for (var _i = 0, _a = rangeValues(parsed[i]); _i < _a.length; _i++) {
|
|
1183
|
-
var month = _a[_i];
|
|
1184
|
-
assert(month >= 1 && month <= 12, monthStartIndexZero ? 'month part must be >= 0 and <= 11' : 'month part must be >= 1 and <= 12');
|
|
1185
|
-
}
|
|
1186
|
-
}
|
|
1086
|
+
assertInRange(parse, 1, 12, monthStartIndexZero ? "month part must be >= 0 and <= 11" : "month part must be >= 1 and <= 12");
|
|
1187
1087
|
};
|
|
1188
1088
|
RangeValidator.dayOfWeekRange = function (parse, dayOfWeekStartIndexZero) {
|
|
1189
|
-
var
|
|
1190
|
-
|
|
1191
|
-
if (
|
|
1192
|
-
var nthString =
|
|
1193
|
-
assert(/^[1-5]$/.test(nthString),
|
|
1194
|
-
}
|
|
1195
|
-
for (var _i = 0, _a = rangeValues(parsed[i]); _i < _a.length; _i++) {
|
|
1196
|
-
var dayOfWeek = _a[_i];
|
|
1197
|
-
assert(dayOfWeek >= 0 && dayOfWeek <= 6, dayOfWeekStartIndexZero ? 'DOW part must be >= 0 and <= 6' : 'DOW part must be >= 1 and <= 7');
|
|
1089
|
+
for (var _i = 0, _a = parse.split(","); _i < _a.length; _i++) {
|
|
1090
|
+
var part = _a[_i];
|
|
1091
|
+
if (part.indexOf("#") > -1) {
|
|
1092
|
+
var nthString = part.substring(part.indexOf("#") + 1);
|
|
1093
|
+
assert(/^[1-5]$/.test(nthString), "DOW nth weekday must be >= 1 and <= 5");
|
|
1198
1094
|
}
|
|
1199
1095
|
}
|
|
1096
|
+
assertInRange(parse, 0, 6, dayOfWeekStartIndexZero ? "DOW part must be >= 0 and <= 6" : "DOW part must be >= 1 and <= 7");
|
|
1200
1097
|
};
|
|
1201
1098
|
return RangeValidator;
|
|
1202
1099
|
}());
|
|
@@ -1259,7 +1156,7 @@ exports.StringUtilities = StringUtilities;
|
|
|
1259
1156
|
/******/ };
|
|
1260
1157
|
/******/
|
|
1261
1158
|
/******/ // Execute the module function
|
|
1262
|
-
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
1159
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
1263
1160
|
/******/
|
|
1264
1161
|
/******/ // Return the exports of the module
|
|
1265
1162
|
/******/ return module.exports;
|