cronli5 0.2.0 → 0.2.1
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/CHANGELOG.md +25 -0
- package/README.md +4 -4
- package/cronli5.min.js +2 -2
- package/dist/cronli5.cjs +123 -104
- package/dist/cronli5.js +123 -104
- package/dist/lang/de.cjs +65 -65
- package/dist/lang/de.js +65 -65
- package/dist/lang/en.cjs +122 -101
- package/dist/lang/en.js +122 -101
- package/dist/lang/es.cjs +71 -72
- package/dist/lang/es.js +71 -72
- package/dist/lang/fi.cjs +71 -66
- package/dist/lang/fi.js +71 -66
- package/dist/lang/zh.cjs +36 -36
- package/dist/lang/zh.js +36 -36
- package/package.json +1 -1
- package/src/core/analyze.ts +14 -13
- package/src/core/ir.ts +8 -8
- package/src/core/shapes.ts +8 -1
- package/src/core/util.ts +86 -3
- package/src/core/validate.ts +1 -1
- package/src/cronli5.ts +3 -3
- package/src/lang/de/index.ts +30 -99
- package/src/lang/en/index.ts +163 -188
- package/src/lang/es/index.ts +36 -120
- package/src/lang/fi/index.ts +33 -104
- package/src/lang/zh/index.ts +23 -48
- package/src/types.ts +2 -2
- package/types/core/analyze.d.ts +2 -2
- package/types/core/ir.d.ts +7 -7
- package/types/core/shapes.d.ts +2 -1
- package/types/core/util.d.ts +17 -2
- package/types/types.d.ts +1 -1
package/dist/cronli5.js
CHANGED
|
@@ -107,6 +107,43 @@ function orderWeekdaysForDisplay(segments) {
|
|
|
107
107
|
function toFieldNumber(token, numberMap) {
|
|
108
108
|
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
109
109
|
}
|
|
110
|
+
function segmentsOf(ir, field) {
|
|
111
|
+
return ir.analyses.segments[field] ?? [];
|
|
112
|
+
}
|
|
113
|
+
function stepSegment(ir, field) {
|
|
114
|
+
return segmentsOf(ir, field)[0];
|
|
115
|
+
}
|
|
116
|
+
function singleValues(segments) {
|
|
117
|
+
const values = [];
|
|
118
|
+
for (const segment of segments) {
|
|
119
|
+
if (segment.kind !== "single") {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
values.push(+segment.value);
|
|
123
|
+
}
|
|
124
|
+
return values;
|
|
125
|
+
}
|
|
126
|
+
function offsetCleanStride(stride) {
|
|
127
|
+
return stride.start < stride.interval && 24 % stride.interval === 0;
|
|
128
|
+
}
|
|
129
|
+
function hourListStride(values) {
|
|
130
|
+
if (values.length < 2) {
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
const interval = values[1] - values[0];
|
|
134
|
+
if (interval < 2) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
for (let i = 2; i < values.length; i += 1) {
|
|
138
|
+
if (values[i] - values[i - 1] !== interval) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
if (values[0] !== 0 && values.length < 5) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
return { interval, last: values[values.length - 1], start: values[0] };
|
|
146
|
+
}
|
|
110
147
|
|
|
111
148
|
// src/core/validate.ts
|
|
112
149
|
function validateCronPattern(cronPattern) {
|
|
@@ -455,6 +492,9 @@ function isDiscreteList(field) {
|
|
|
455
492
|
function isDiscreteHours(hourField) {
|
|
456
493
|
return hourField !== "*" && !isPlainRange(hourField) && !isPlainStep(hourField);
|
|
457
494
|
}
|
|
495
|
+
function isOpenStep(field) {
|
|
496
|
+
return field.indexOf("/") !== -1 && field.indexOf("-") === -1 && field.indexOf(",") === -1;
|
|
497
|
+
}
|
|
458
498
|
|
|
459
499
|
// src/core/analyze.ts
|
|
460
500
|
function getOccurrences(start, interval, max) {
|
|
@@ -591,9 +631,9 @@ function analyze(pattern) {
|
|
|
591
631
|
segments
|
|
592
632
|
};
|
|
593
633
|
const content = { analyses, pattern, shapes };
|
|
594
|
-
return { ...content, plan:
|
|
634
|
+
return { ...content, plan: selectPlan(content) };
|
|
595
635
|
}
|
|
596
|
-
function
|
|
636
|
+
function selectPlan(content) {
|
|
597
637
|
const { analyses, pattern, shapes } = content;
|
|
598
638
|
if (pattern.second !== "0") {
|
|
599
639
|
const seconds = planSeconds(pattern, shapes, analyses);
|
|
@@ -1026,7 +1066,7 @@ function secondsClause(ir, anchor, opts) {
|
|
|
1026
1066
|
}
|
|
1027
1067
|
if (shape === "step") {
|
|
1028
1068
|
return stepCycle60(
|
|
1029
|
-
ir
|
|
1069
|
+
stepSegment(ir, "second"),
|
|
1030
1070
|
"second",
|
|
1031
1071
|
anchor,
|
|
1032
1072
|
opts
|
|
@@ -1041,12 +1081,12 @@ function secondsClause(ir, anchor, opts) {
|
|
|
1041
1081
|
return "at " + getNumber(secondField, opts) + " " + pluralize(secondField, "second") + " past the " + anchor;
|
|
1042
1082
|
}
|
|
1043
1083
|
return strideFromSegments(
|
|
1044
|
-
ir
|
|
1084
|
+
segmentsOf(ir, "second"),
|
|
1045
1085
|
"second",
|
|
1046
1086
|
anchor,
|
|
1047
1087
|
opts
|
|
1048
1088
|
) ?? listPastThe(
|
|
1049
|
-
segmentWords(ir
|
|
1089
|
+
segmentWords(segmentsOf(ir, "second"), opts),
|
|
1050
1090
|
"second",
|
|
1051
1091
|
anchor,
|
|
1052
1092
|
opts
|
|
@@ -1063,15 +1103,15 @@ function renderRangeOfMinutes(ir, plan, opts) {
|
|
|
1063
1103
|
return minuteRangeLead(ir.pattern.minute, opts) + trailingQualifier(ir, opts);
|
|
1064
1104
|
}
|
|
1065
1105
|
function renderMultipleMinutes(ir, plan, opts) {
|
|
1066
|
-
const stride = strideFromSegments(ir
|
|
1106
|
+
const stride = strideFromSegments(segmentsOf(ir, "minute"), "minute", "hour", opts);
|
|
1067
1107
|
return (stride ?? listPastThe(segmentWords(
|
|
1068
|
-
ir
|
|
1108
|
+
segmentsOf(ir, "minute"),
|
|
1069
1109
|
opts
|
|
1070
1110
|
), "minute", "hour", opts)) + trailingQualifier(ir, opts);
|
|
1071
1111
|
}
|
|
1072
1112
|
function renderMinuteFrequency(ir, plan, opts) {
|
|
1073
1113
|
let phrase = stepCycle60(
|
|
1074
|
-
ir
|
|
1114
|
+
stepSegment(ir, "minute"),
|
|
1075
1115
|
"minute",
|
|
1076
1116
|
"hour",
|
|
1077
1117
|
opts
|
|
@@ -1080,9 +1120,14 @@ function renderMinuteFrequency(ir, plan, opts) {
|
|
|
1080
1120
|
const cadence = unevenHourCadence(ir, opts);
|
|
1081
1121
|
phrase += cadence ? ", " + cadence : " during the " + hourTimesFromPlan(ir, plan.hours.times, false, opts) + " hours";
|
|
1082
1122
|
} else if (plan.hours.kind === "window") {
|
|
1083
|
-
phrase += " " +
|
|
1123
|
+
phrase += " " + rangeWindow({
|
|
1124
|
+
continuous: false,
|
|
1125
|
+
from: plan.hours.from,
|
|
1126
|
+
throughMinute: plan.hours.last,
|
|
1127
|
+
to: plan.hours.to
|
|
1128
|
+
}, opts);
|
|
1084
1129
|
} else if (plan.hours.kind === "step") {
|
|
1085
|
-
phrase += " " + everyNthHour(ir
|
|
1130
|
+
phrase += " " + everyNthHour(stepSegment(ir, "hour"), opts);
|
|
1086
1131
|
}
|
|
1087
1132
|
return phrase + trailingQualifier(ir, opts);
|
|
1088
1133
|
}
|
|
@@ -1110,8 +1155,8 @@ function renderMinutesAcrossHours(ir, plan, opts) {
|
|
|
1110
1155
|
}
|
|
1111
1156
|
return lead2 + " during the " + hourTimesFromPlan(ir, plan.times, false, opts) + " hours" + trailingQualifier(ir, opts);
|
|
1112
1157
|
}
|
|
1113
|
-
const lead = strideFromSegments(ir
|
|
1114
|
-
segmentWords(ir
|
|
1158
|
+
const lead = strideFromSegments(segmentsOf(ir, "minute"), "minute", "hour", opts) ?? listPastThe(
|
|
1159
|
+
segmentWords(segmentsOf(ir, "minute"), opts),
|
|
1115
1160
|
"minute",
|
|
1116
1161
|
"hour",
|
|
1117
1162
|
opts
|
|
@@ -1136,12 +1181,12 @@ function everyNthHour(segment, opts) {
|
|
|
1136
1181
|
return start === 0 ? base : base + " starting at " + getTime({ hour: start, minute: 0 }, opts);
|
|
1137
1182
|
}
|
|
1138
1183
|
function renderMinuteSpanAcrossHourStep(ir, plan, opts) {
|
|
1139
|
-
const segment = ir
|
|
1184
|
+
const segment = stepSegment(ir, "hour");
|
|
1140
1185
|
if (plan.form === "wildcard") {
|
|
1141
1186
|
return "every minute " + everyNthHour(segment, opts) + trailingQualifier(ir, opts);
|
|
1142
1187
|
}
|
|
1143
|
-
const lead = plan.form === "list" ? strideFromSegments(ir
|
|
1144
|
-
segmentWords(ir
|
|
1188
|
+
const lead = plan.form === "list" ? strideFromSegments(segmentsOf(ir, "minute"), "minute", "hour", opts) ?? listPastThe(
|
|
1189
|
+
segmentWords(segmentsOf(ir, "minute"), opts),
|
|
1145
1190
|
"minute",
|
|
1146
1191
|
"hour",
|
|
1147
1192
|
opts
|
|
@@ -1172,12 +1217,12 @@ function rangeMinuteLead(ir, opts) {
|
|
|
1172
1217
|
return "every hour";
|
|
1173
1218
|
}
|
|
1174
1219
|
return strideFromSegments(
|
|
1175
|
-
ir
|
|
1220
|
+
segmentsOf(ir, "minute"),
|
|
1176
1221
|
"minute",
|
|
1177
1222
|
"hour",
|
|
1178
1223
|
opts
|
|
1179
1224
|
) ?? listPastThe(
|
|
1180
|
-
segmentWords(ir
|
|
1225
|
+
segmentWords(segmentsOf(ir, "minute"), opts),
|
|
1181
1226
|
"minute",
|
|
1182
1227
|
"hour",
|
|
1183
1228
|
opts
|
|
@@ -1188,21 +1233,28 @@ function renderHourStep(ir, plan, opts) {
|
|
|
1188
1233
|
if (cadence !== null) {
|
|
1189
1234
|
return cadence + trailingQualifier(ir, opts);
|
|
1190
1235
|
}
|
|
1191
|
-
return stepHours(ir
|
|
1236
|
+
return stepHours(stepSegment(ir, "hour"), opts) + trailingQualifier(ir, opts);
|
|
1192
1237
|
}
|
|
1193
1238
|
function boundedWindow(plan) {
|
|
1194
|
-
const
|
|
1195
|
-
|
|
1239
|
+
const continuous = plan.minuteForm === "wildcard";
|
|
1240
|
+
const closeMinute = continuous ? plan.boundMinute ?? 0 : 0;
|
|
1241
|
+
return { from: plan.from, closeMinute, to: plan.to, continuous };
|
|
1196
1242
|
}
|
|
1197
|
-
function rangeWindow(
|
|
1243
|
+
function rangeWindow(window, opts) {
|
|
1244
|
+
const { from, to, throughMinute, continuous } = window;
|
|
1198
1245
|
const open = "from " + getTime({ hour: from, minute: 0 }, opts);
|
|
1199
1246
|
if (opts.style.untilWindow && !opts.short && from !== to) {
|
|
1200
|
-
return open + " until " + getTime({ hour: (to + 1) % 24, minute: 0 }, opts);
|
|
1247
|
+
return continuous ? open + " until " + getTime({ hour: (to + 1) % 24, minute: 0 }, opts) : open + through(opts) + getTime({ hour: to, minute: 0 }, opts);
|
|
1201
1248
|
}
|
|
1202
1249
|
return open + through(opts) + getTime({ hour: to, minute: throughMinute }, opts);
|
|
1203
1250
|
}
|
|
1204
1251
|
function hourWindow(window, opts) {
|
|
1205
|
-
return rangeWindow(
|
|
1252
|
+
return rangeWindow({
|
|
1253
|
+
continuous: window.continuous,
|
|
1254
|
+
from: window.from,
|
|
1255
|
+
throughMinute: window.closeMinute,
|
|
1256
|
+
to: window.to
|
|
1257
|
+
}, opts);
|
|
1206
1258
|
}
|
|
1207
1259
|
function renderClockTimes(ir, plan, opts) {
|
|
1208
1260
|
if (ir.shapes.minute === "single") {
|
|
@@ -1232,7 +1284,7 @@ function renderCompactClockTimes(ir, plan, opts) {
|
|
|
1232
1284
|
if (cadence2 !== null) {
|
|
1233
1285
|
return cadence2;
|
|
1234
1286
|
}
|
|
1235
|
-
const hasRange = ir
|
|
1287
|
+
const hasRange = segmentsOf(ir, "hour").some(function range(segment) {
|
|
1236
1288
|
return segment.kind === "range";
|
|
1237
1289
|
});
|
|
1238
1290
|
if (hasRange && !ir.analyses.clockSecond) {
|
|
@@ -1244,8 +1296,8 @@ function renderCompactClockTimes(ir, plan, opts) {
|
|
|
1244
1296
|
const minuteLead = (
|
|
1245
1297
|
// The non-fold branch is a minute list, which has segments. An
|
|
1246
1298
|
// offset/uneven step enumerated to that list reads as a stride.
|
|
1247
|
-
strideFromSegments(ir
|
|
1248
|
-
segmentWords(ir
|
|
1299
|
+
strideFromSegments(segmentsOf(ir, "minute"), "minute", "hour", opts) ?? listPastThe(
|
|
1300
|
+
segmentWords(segmentsOf(ir, "minute"), opts),
|
|
1249
1301
|
"minute",
|
|
1250
1302
|
"hour",
|
|
1251
1303
|
opts
|
|
@@ -1258,42 +1310,38 @@ function renderCompactClockTimes(ir, plan, opts) {
|
|
|
1258
1310
|
function foldedHourWindows(ir, plan, opts) {
|
|
1259
1311
|
const minute = plan.minute;
|
|
1260
1312
|
const windows = [];
|
|
1261
|
-
const
|
|
1262
|
-
const times = outliers.hours.map(function time(hour) {
|
|
1313
|
+
const times = collectHourOutliers(ir).map(function time(hour) {
|
|
1263
1314
|
return getTime({ hour, minute }, opts);
|
|
1264
1315
|
});
|
|
1265
|
-
ir
|
|
1316
|
+
segmentsOf(ir, "hour").forEach(function classify(segment) {
|
|
1266
1317
|
if (segment.kind === "range") {
|
|
1267
|
-
windows.push(rangeWindow(
|
|
1268
|
-
|
|
1269
|
-
+segment.bounds[
|
|
1270
|
-
minute,
|
|
1271
|
-
|
|
1272
|
-
));
|
|
1318
|
+
windows.push(rangeWindow({
|
|
1319
|
+
continuous: false,
|
|
1320
|
+
from: +segment.bounds[0],
|
|
1321
|
+
throughMinute: minute,
|
|
1322
|
+
to: +segment.bounds[1]
|
|
1323
|
+
}, opts));
|
|
1273
1324
|
}
|
|
1274
1325
|
});
|
|
1275
1326
|
const phrase = rangeMinuteLead(ir, opts) + " " + joinList(windows, opts);
|
|
1276
|
-
return phrase + outlierTail(times,
|
|
1327
|
+
return phrase + outlierTail(times, opts);
|
|
1277
1328
|
}
|
|
1278
1329
|
function collectHourOutliers(ir) {
|
|
1279
1330
|
const hours = [];
|
|
1280
|
-
|
|
1281
|
-
ir.analyses.segments.hour.forEach(function classify(segment) {
|
|
1331
|
+
segmentsOf(ir, "hour").forEach(function classify(segment) {
|
|
1282
1332
|
if (segment.kind === "step") {
|
|
1283
1333
|
hours.push(...segment.fires);
|
|
1284
|
-
pureStrays = false;
|
|
1285
1334
|
} else if (segment.kind !== "range") {
|
|
1286
1335
|
hours.push(+segment.value);
|
|
1287
1336
|
}
|
|
1288
1337
|
});
|
|
1289
|
-
return
|
|
1338
|
+
return hours;
|
|
1290
1339
|
}
|
|
1291
|
-
function outlierTail(times,
|
|
1340
|
+
function outlierTail(times, opts) {
|
|
1292
1341
|
if (!times.length) {
|
|
1293
1342
|
return "";
|
|
1294
1343
|
}
|
|
1295
|
-
|
|
1296
|
-
return connector + joinList(times, opts);
|
|
1344
|
+
return " and at " + joinList(times, opts);
|
|
1297
1345
|
}
|
|
1298
1346
|
function isCadenceField(token) {
|
|
1299
1347
|
return token === "*" || token.startsWith("*/") && token.indexOf("-") === -1;
|
|
@@ -1307,7 +1355,7 @@ function leadingCadence(ir, opts) {
|
|
|
1307
1355
|
const text = minute === "*" ? "every minute" : (
|
|
1308
1356
|
// A clean minute step's first segment is a step segment.
|
|
1309
1357
|
stepCycle60(
|
|
1310
|
-
ir
|
|
1358
|
+
stepSegment(ir, "minute"),
|
|
1311
1359
|
"minute",
|
|
1312
1360
|
"hour",
|
|
1313
1361
|
opts
|
|
@@ -1325,7 +1373,7 @@ function minuteConfinement(ir, opts) {
|
|
|
1325
1373
|
if (isCadenceField(minute)) {
|
|
1326
1374
|
return " of every other minute";
|
|
1327
1375
|
}
|
|
1328
|
-
const segments = ir
|
|
1376
|
+
const segments = segmentsOf(ir, "minute");
|
|
1329
1377
|
if (ir.shapes.minute === "single") {
|
|
1330
1378
|
return " during minute :" + pad(minute);
|
|
1331
1379
|
}
|
|
@@ -1359,7 +1407,12 @@ function hourConfinement(ir, opts) {
|
|
|
1359
1407
|
}
|
|
1360
1408
|
if (ir.shapes.hour === "range") {
|
|
1361
1409
|
const bounds = hour.split("-");
|
|
1362
|
-
return " " + rangeWindow(
|
|
1410
|
+
return " " + rangeWindow({
|
|
1411
|
+
continuous: ir.pattern.minute === "*",
|
|
1412
|
+
from: +bounds[0],
|
|
1413
|
+
throughMinute: 0,
|
|
1414
|
+
to: +bounds[1]
|
|
1415
|
+
}, opts);
|
|
1363
1416
|
}
|
|
1364
1417
|
return " during the " + hourSegmentTimes(ir, { minute: 0, second: null }, false, opts) + " hours";
|
|
1365
1418
|
}
|
|
@@ -1370,14 +1423,14 @@ function confinableHour(ir) {
|
|
|
1370
1423
|
if (ir.shapes.hour !== "step") {
|
|
1371
1424
|
return true;
|
|
1372
1425
|
}
|
|
1373
|
-
const segment = ir
|
|
1426
|
+
const segment = stepSegment(ir, "hour");
|
|
1374
1427
|
return ir.pattern.hour === "*/2" || segment.startToken.indexOf("-") !== -1;
|
|
1375
1428
|
}
|
|
1376
1429
|
function isMinuteStride(ir) {
|
|
1377
1430
|
if (ir.shapes.minute !== "list") {
|
|
1378
1431
|
return false;
|
|
1379
1432
|
}
|
|
1380
|
-
const values = singleValues(ir
|
|
1433
|
+
const values = singleValues(segmentsOf(ir, "minute"));
|
|
1381
1434
|
return values !== null && arithmeticStep(values) !== null;
|
|
1382
1435
|
}
|
|
1383
1436
|
function confinementEligible(ir, lead) {
|
|
@@ -1447,16 +1500,6 @@ function renderStride(stride, opts) {
|
|
|
1447
1500
|
const num = seriesNumber();
|
|
1448
1501
|
return cadence + " from " + num(start) + through(opts) + num(last) + " " + pluralize(last, unit) + " past the " + anchor;
|
|
1449
1502
|
}
|
|
1450
|
-
function singleValues(segments) {
|
|
1451
|
-
const values = [];
|
|
1452
|
-
for (const segment of segments) {
|
|
1453
|
-
if (segment.kind !== "single") {
|
|
1454
|
-
return null;
|
|
1455
|
-
}
|
|
1456
|
-
values.push(+segment.value);
|
|
1457
|
-
}
|
|
1458
|
-
return values;
|
|
1459
|
-
}
|
|
1460
1503
|
function strideFromSegments(segments, unit, anchor, opts) {
|
|
1461
1504
|
const values = singleValues(segments);
|
|
1462
1505
|
const step = values && arithmeticStep(values);
|
|
@@ -1505,9 +1548,6 @@ function hourStrideCadence(stride, opts) {
|
|
|
1505
1548
|
}
|
|
1506
1549
|
return cadence + " from " + getTime({ hour: start, minute: 0 }, opts) + through(opts) + getTime({ hour: last, minute: 0 }, opts);
|
|
1507
1550
|
}
|
|
1508
|
-
function offsetCleanStride(stride) {
|
|
1509
|
-
return stride.start < stride.interval && 24 % stride.interval === 0;
|
|
1510
|
-
}
|
|
1511
1551
|
function unevenHourCadence(ir, opts) {
|
|
1512
1552
|
const stride = hourStride(ir);
|
|
1513
1553
|
if (!stride || offsetCleanStride(stride)) {
|
|
@@ -1515,26 +1555,8 @@ function unevenHourCadence(ir, opts) {
|
|
|
1515
1555
|
}
|
|
1516
1556
|
return hourStrideCadence(stride, opts);
|
|
1517
1557
|
}
|
|
1518
|
-
function hourListStride(values) {
|
|
1519
|
-
if (values.length < 2) {
|
|
1520
|
-
return null;
|
|
1521
|
-
}
|
|
1522
|
-
const interval = values[1] - values[0];
|
|
1523
|
-
if (interval < 2) {
|
|
1524
|
-
return null;
|
|
1525
|
-
}
|
|
1526
|
-
for (let i = 2; i < values.length; i += 1) {
|
|
1527
|
-
if (values[i] - values[i - 1] !== interval) {
|
|
1528
|
-
return null;
|
|
1529
|
-
}
|
|
1530
|
-
}
|
|
1531
|
-
if (values[0] !== 0 && values.length < 5) {
|
|
1532
|
-
return null;
|
|
1533
|
-
}
|
|
1534
|
-
return { interval, last: values[values.length - 1], start: values[0] };
|
|
1535
|
-
}
|
|
1536
1558
|
function hourStride(ir) {
|
|
1537
|
-
const segments = ir
|
|
1559
|
+
const segments = segmentsOf(ir, "hour");
|
|
1538
1560
|
if (segments.length === 1 && segments[0].kind === "step") {
|
|
1539
1561
|
const segment = segments[0];
|
|
1540
1562
|
if (segment.fires.length < 2) {
|
|
@@ -1581,7 +1603,7 @@ function hourCadence(ir, minute, opts) {
|
|
|
1581
1603
|
return hourCadenceLead(ir, minute, opts) + ", " + hourStrideCadence(stride, opts) + trailingQualifier(ir, opts);
|
|
1582
1604
|
}
|
|
1583
1605
|
function cleanStrideSegment(ir) {
|
|
1584
|
-
const segments = ir
|
|
1606
|
+
const segments = segmentsOf(ir, "hour");
|
|
1585
1607
|
const segment = segments.length === 1 && segments[0];
|
|
1586
1608
|
if (!segment || segment.kind !== "step" || segment.startToken.indexOf("-") !== -1 || !(segment.interval in stepOrdinals)) {
|
|
1587
1609
|
return null;
|
|
@@ -1589,28 +1611,28 @@ function cleanStrideSegment(ir) {
|
|
|
1589
1611
|
return segment;
|
|
1590
1612
|
}
|
|
1591
1613
|
function hasHourWindow(ir) {
|
|
1592
|
-
return ir
|
|
1614
|
+
return segmentsOf(ir, "hour").some(function range(segment) {
|
|
1593
1615
|
return segment.kind === "range";
|
|
1594
1616
|
});
|
|
1595
1617
|
}
|
|
1596
1618
|
function hourRangeWindowTail(ir, opts) {
|
|
1597
1619
|
const windows = [];
|
|
1598
|
-
const
|
|
1599
|
-
ir
|
|
1620
|
+
const outlierHours = collectHourOutliers(ir);
|
|
1621
|
+
segmentsOf(ir, "hour").forEach(function classify(segment) {
|
|
1600
1622
|
if (segment.kind === "range") {
|
|
1601
|
-
windows.push(rangeWindow(
|
|
1602
|
-
|
|
1603
|
-
+segment.bounds[
|
|
1604
|
-
0,
|
|
1605
|
-
|
|
1606
|
-
));
|
|
1623
|
+
windows.push(rangeWindow({
|
|
1624
|
+
continuous: false,
|
|
1625
|
+
from: +segment.bounds[0],
|
|
1626
|
+
throughMinute: 0,
|
|
1627
|
+
to: +segment.bounds[1]
|
|
1628
|
+
}, opts));
|
|
1607
1629
|
}
|
|
1608
1630
|
});
|
|
1609
1631
|
const phrase = "every hour " + joinList(windows, opts);
|
|
1610
|
-
const times =
|
|
1632
|
+
const times = outlierHours.map(function time(hour) {
|
|
1611
1633
|
return getTime({ hour, minute: 0 }, opts);
|
|
1612
1634
|
});
|
|
1613
|
-
return phrase + outlierTail(times,
|
|
1635
|
+
return phrase + outlierTail(times, opts);
|
|
1614
1636
|
}
|
|
1615
1637
|
function hourRangeCadence(ir, minute, opts) {
|
|
1616
1638
|
if (minute !== 0 || !hasHourWindow(ir)) {
|
|
@@ -1695,7 +1717,7 @@ function segmentHours(segment) {
|
|
|
1695
1717
|
}
|
|
1696
1718
|
function hourSegmentTimes(ir, fold, atContext, opts) {
|
|
1697
1719
|
const { minute, second } = fold;
|
|
1698
|
-
const segments = ir
|
|
1720
|
+
const segments = segmentsOf(ir, "hour");
|
|
1699
1721
|
const plain = mixedTwelve(segments.flatMap(function entries(segment) {
|
|
1700
1722
|
return segmentHours(segment).map(function entry(hour) {
|
|
1701
1723
|
return { hour: +hour, minute, second };
|
|
@@ -1815,7 +1837,7 @@ function datePhrase(ir, words, opts) {
|
|
|
1815
1837
|
}
|
|
1816
1838
|
function monthFoldsIntoDate(ir) {
|
|
1817
1839
|
return !oddEvenMonth(ir.pattern.month) && // Reached only with a restricted month, which has segments.
|
|
1818
|
-
ir
|
|
1840
|
+
segmentsOf(ir, "month").every(function flat(segment) {
|
|
1819
1841
|
return segment.kind !== "range";
|
|
1820
1842
|
});
|
|
1821
1843
|
}
|
|
@@ -1846,7 +1868,7 @@ function dayUnionDatePieces(ir, opts) {
|
|
|
1846
1868
|
return [oddEven];
|
|
1847
1869
|
}
|
|
1848
1870
|
const pieces = [];
|
|
1849
|
-
ir
|
|
1871
|
+
segmentsOf(ir, "date").forEach(function expand(segment) {
|
|
1850
1872
|
if (segment.kind === "range") {
|
|
1851
1873
|
pieces.push("from the " + getOrdinal(segment.bounds[0]) + through(opts) + "the " + getOrdinal(segment.bounds[1]));
|
|
1852
1874
|
} else if (segment.kind === "step") {
|
|
@@ -1866,7 +1888,7 @@ function dayUnionWeekdayPieces(ir, opts) {
|
|
|
1866
1888
|
return [quartz.replace(/^on /, "")];
|
|
1867
1889
|
}
|
|
1868
1890
|
const pieces = [];
|
|
1869
|
-
ir
|
|
1891
|
+
segmentsOf(ir, "weekday").forEach(function expand(segment) {
|
|
1870
1892
|
if (segment.kind === "range" && segment.bounds[0] === "1" && segment.bounds[1] === "5") {
|
|
1871
1893
|
pieces.push("a weekday");
|
|
1872
1894
|
} else if (segment.kind === "range") {
|
|
@@ -1947,7 +1969,7 @@ function quartzWeekdayPhrase(weekdayField, opts) {
|
|
|
1947
1969
|
function monthDatePhrase(ir, opts) {
|
|
1948
1970
|
const month = monthName(ir, opts);
|
|
1949
1971
|
const days = renderSegments(
|
|
1950
|
-
ir
|
|
1972
|
+
segmentsOf(ir, "date"),
|
|
1951
1973
|
opts.style.ordinals ? getOrdinal : cardinalDay,
|
|
1952
1974
|
opts
|
|
1953
1975
|
);
|
|
@@ -1990,14 +2012,14 @@ function stepDates(dateField) {
|
|
|
1990
2012
|
return phrase;
|
|
1991
2013
|
}
|
|
1992
2014
|
function dateOrdinals(ir, opts) {
|
|
1993
|
-
return renderSegments(ir
|
|
2015
|
+
return renderSegments(segmentsOf(ir, "date"), getOrdinal, opts);
|
|
1994
2016
|
}
|
|
1995
2017
|
function monthName(ir, opts) {
|
|
1996
2018
|
const oddEven = oddEvenMonth(ir.pattern.month);
|
|
1997
2019
|
if (oddEven) {
|
|
1998
2020
|
return oddEven;
|
|
1999
2021
|
}
|
|
2000
|
-
return renderSegments(ir
|
|
2022
|
+
return renderSegments(segmentsOf(ir, "month"), function name(value) {
|
|
2001
2023
|
return getMonth(value, opts);
|
|
2002
2024
|
}, opts);
|
|
2003
2025
|
}
|
|
@@ -2015,7 +2037,7 @@ function oddEvenMonth(monthField) {
|
|
|
2015
2037
|
return start === "2" ? "every even-numbered month" : null;
|
|
2016
2038
|
}
|
|
2017
2039
|
function weekdayPhrase(ir, recurring, opts) {
|
|
2018
|
-
const segments = orderWeekdaysForDisplay(ir
|
|
2040
|
+
const segments = orderWeekdaysForDisplay(segmentsOf(ir, "weekday"));
|
|
2019
2041
|
const hasRange = segments.some(function range(segment) {
|
|
2020
2042
|
return segment.kind === "range";
|
|
2021
2043
|
});
|
|
@@ -2043,9 +2065,6 @@ function renderSegments(segments, word, opts) {
|
|
|
2043
2065
|
});
|
|
2044
2066
|
return joinList(pieces, opts);
|
|
2045
2067
|
}
|
|
2046
|
-
function isOpenStep(field) {
|
|
2047
|
-
return field.indexOf("/") !== -1 && field.indexOf("-") === -1 && field.indexOf(",") === -1;
|
|
2048
|
-
}
|
|
2049
2068
|
function applyYear(description, ir, opts) {
|
|
2050
2069
|
const yearField = ir.pattern.year;
|
|
2051
2070
|
if (yearField === "*") {
|
|
@@ -2179,7 +2198,7 @@ function interpretCronPattern(cronPattern, lang, opts) {
|
|
|
2179
2198
|
return lang.reboot;
|
|
2180
2199
|
}
|
|
2181
2200
|
const ir = analyze(prepare(cronPattern, opts));
|
|
2182
|
-
const plan = lang.
|
|
2201
|
+
const plan = lang.plan ? lang.plan(ir, ir.plan) : ir.plan;
|
|
2183
2202
|
return lang.describe({ ...ir, plan }, opts);
|
|
2184
2203
|
}
|
|
2185
2204
|
var cronli5_default = cronli5;
|