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.cjs
CHANGED
|
@@ -133,6 +133,43 @@ function orderWeekdaysForDisplay(segments) {
|
|
|
133
133
|
function toFieldNumber(token, numberMap) {
|
|
134
134
|
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
135
135
|
}
|
|
136
|
+
function segmentsOf(ir, field) {
|
|
137
|
+
return ir.analyses.segments[field] ?? [];
|
|
138
|
+
}
|
|
139
|
+
function stepSegment(ir, field) {
|
|
140
|
+
return segmentsOf(ir, field)[0];
|
|
141
|
+
}
|
|
142
|
+
function singleValues(segments) {
|
|
143
|
+
const values = [];
|
|
144
|
+
for (const segment of segments) {
|
|
145
|
+
if (segment.kind !== "single") {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
values.push(+segment.value);
|
|
149
|
+
}
|
|
150
|
+
return values;
|
|
151
|
+
}
|
|
152
|
+
function offsetCleanStride(stride) {
|
|
153
|
+
return stride.start < stride.interval && 24 % stride.interval === 0;
|
|
154
|
+
}
|
|
155
|
+
function hourListStride(values) {
|
|
156
|
+
if (values.length < 2) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
const interval = values[1] - values[0];
|
|
160
|
+
if (interval < 2) {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
for (let i = 2; i < values.length; i += 1) {
|
|
164
|
+
if (values[i] - values[i - 1] !== interval) {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
if (values[0] !== 0 && values.length < 5) {
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
return { interval, last: values[values.length - 1], start: values[0] };
|
|
172
|
+
}
|
|
136
173
|
|
|
137
174
|
// src/core/validate.ts
|
|
138
175
|
function validateCronPattern(cronPattern) {
|
|
@@ -481,6 +518,9 @@ function isDiscreteList(field) {
|
|
|
481
518
|
function isDiscreteHours(hourField) {
|
|
482
519
|
return hourField !== "*" && !isPlainRange(hourField) && !isPlainStep(hourField);
|
|
483
520
|
}
|
|
521
|
+
function isOpenStep(field) {
|
|
522
|
+
return field.indexOf("/") !== -1 && field.indexOf("-") === -1 && field.indexOf(",") === -1;
|
|
523
|
+
}
|
|
484
524
|
|
|
485
525
|
// src/core/analyze.ts
|
|
486
526
|
function getOccurrences(start, interval, max) {
|
|
@@ -617,9 +657,9 @@ function analyze(pattern) {
|
|
|
617
657
|
segments
|
|
618
658
|
};
|
|
619
659
|
const content = { analyses, pattern, shapes };
|
|
620
|
-
return { ...content, plan:
|
|
660
|
+
return { ...content, plan: selectPlan(content) };
|
|
621
661
|
}
|
|
622
|
-
function
|
|
662
|
+
function selectPlan(content) {
|
|
623
663
|
const { analyses, pattern, shapes } = content;
|
|
624
664
|
if (pattern.second !== "0") {
|
|
625
665
|
const seconds = planSeconds(pattern, shapes, analyses);
|
|
@@ -1052,7 +1092,7 @@ function secondsClause(ir, anchor, opts) {
|
|
|
1052
1092
|
}
|
|
1053
1093
|
if (shape === "step") {
|
|
1054
1094
|
return stepCycle60(
|
|
1055
|
-
ir
|
|
1095
|
+
stepSegment(ir, "second"),
|
|
1056
1096
|
"second",
|
|
1057
1097
|
anchor,
|
|
1058
1098
|
opts
|
|
@@ -1067,12 +1107,12 @@ function secondsClause(ir, anchor, opts) {
|
|
|
1067
1107
|
return "at " + getNumber(secondField, opts) + " " + pluralize(secondField, "second") + " past the " + anchor;
|
|
1068
1108
|
}
|
|
1069
1109
|
return strideFromSegments(
|
|
1070
|
-
ir
|
|
1110
|
+
segmentsOf(ir, "second"),
|
|
1071
1111
|
"second",
|
|
1072
1112
|
anchor,
|
|
1073
1113
|
opts
|
|
1074
1114
|
) ?? listPastThe(
|
|
1075
|
-
segmentWords(ir
|
|
1115
|
+
segmentWords(segmentsOf(ir, "second"), opts),
|
|
1076
1116
|
"second",
|
|
1077
1117
|
anchor,
|
|
1078
1118
|
opts
|
|
@@ -1089,15 +1129,15 @@ function renderRangeOfMinutes(ir, plan, opts) {
|
|
|
1089
1129
|
return minuteRangeLead(ir.pattern.minute, opts) + trailingQualifier(ir, opts);
|
|
1090
1130
|
}
|
|
1091
1131
|
function renderMultipleMinutes(ir, plan, opts) {
|
|
1092
|
-
const stride = strideFromSegments(ir
|
|
1132
|
+
const stride = strideFromSegments(segmentsOf(ir, "minute"), "minute", "hour", opts);
|
|
1093
1133
|
return (stride ?? listPastThe(segmentWords(
|
|
1094
|
-
ir
|
|
1134
|
+
segmentsOf(ir, "minute"),
|
|
1095
1135
|
opts
|
|
1096
1136
|
), "minute", "hour", opts)) + trailingQualifier(ir, opts);
|
|
1097
1137
|
}
|
|
1098
1138
|
function renderMinuteFrequency(ir, plan, opts) {
|
|
1099
1139
|
let phrase = stepCycle60(
|
|
1100
|
-
ir
|
|
1140
|
+
stepSegment(ir, "minute"),
|
|
1101
1141
|
"minute",
|
|
1102
1142
|
"hour",
|
|
1103
1143
|
opts
|
|
@@ -1106,9 +1146,14 @@ function renderMinuteFrequency(ir, plan, opts) {
|
|
|
1106
1146
|
const cadence = unevenHourCadence(ir, opts);
|
|
1107
1147
|
phrase += cadence ? ", " + cadence : " during the " + hourTimesFromPlan(ir, plan.hours.times, false, opts) + " hours";
|
|
1108
1148
|
} else if (plan.hours.kind === "window") {
|
|
1109
|
-
phrase += " " +
|
|
1149
|
+
phrase += " " + rangeWindow({
|
|
1150
|
+
continuous: false,
|
|
1151
|
+
from: plan.hours.from,
|
|
1152
|
+
throughMinute: plan.hours.last,
|
|
1153
|
+
to: plan.hours.to
|
|
1154
|
+
}, opts);
|
|
1110
1155
|
} else if (plan.hours.kind === "step") {
|
|
1111
|
-
phrase += " " + everyNthHour(ir
|
|
1156
|
+
phrase += " " + everyNthHour(stepSegment(ir, "hour"), opts);
|
|
1112
1157
|
}
|
|
1113
1158
|
return phrase + trailingQualifier(ir, opts);
|
|
1114
1159
|
}
|
|
@@ -1136,8 +1181,8 @@ function renderMinutesAcrossHours(ir, plan, opts) {
|
|
|
1136
1181
|
}
|
|
1137
1182
|
return lead2 + " during the " + hourTimesFromPlan(ir, plan.times, false, opts) + " hours" + trailingQualifier(ir, opts);
|
|
1138
1183
|
}
|
|
1139
|
-
const lead = strideFromSegments(ir
|
|
1140
|
-
segmentWords(ir
|
|
1184
|
+
const lead = strideFromSegments(segmentsOf(ir, "minute"), "minute", "hour", opts) ?? listPastThe(
|
|
1185
|
+
segmentWords(segmentsOf(ir, "minute"), opts),
|
|
1141
1186
|
"minute",
|
|
1142
1187
|
"hour",
|
|
1143
1188
|
opts
|
|
@@ -1162,12 +1207,12 @@ function everyNthHour(segment, opts) {
|
|
|
1162
1207
|
return start === 0 ? base : base + " starting at " + getTime({ hour: start, minute: 0 }, opts);
|
|
1163
1208
|
}
|
|
1164
1209
|
function renderMinuteSpanAcrossHourStep(ir, plan, opts) {
|
|
1165
|
-
const segment = ir
|
|
1210
|
+
const segment = stepSegment(ir, "hour");
|
|
1166
1211
|
if (plan.form === "wildcard") {
|
|
1167
1212
|
return "every minute " + everyNthHour(segment, opts) + trailingQualifier(ir, opts);
|
|
1168
1213
|
}
|
|
1169
|
-
const lead = plan.form === "list" ? strideFromSegments(ir
|
|
1170
|
-
segmentWords(ir
|
|
1214
|
+
const lead = plan.form === "list" ? strideFromSegments(segmentsOf(ir, "minute"), "minute", "hour", opts) ?? listPastThe(
|
|
1215
|
+
segmentWords(segmentsOf(ir, "minute"), opts),
|
|
1171
1216
|
"minute",
|
|
1172
1217
|
"hour",
|
|
1173
1218
|
opts
|
|
@@ -1198,12 +1243,12 @@ function rangeMinuteLead(ir, opts) {
|
|
|
1198
1243
|
return "every hour";
|
|
1199
1244
|
}
|
|
1200
1245
|
return strideFromSegments(
|
|
1201
|
-
ir
|
|
1246
|
+
segmentsOf(ir, "minute"),
|
|
1202
1247
|
"minute",
|
|
1203
1248
|
"hour",
|
|
1204
1249
|
opts
|
|
1205
1250
|
) ?? listPastThe(
|
|
1206
|
-
segmentWords(ir
|
|
1251
|
+
segmentWords(segmentsOf(ir, "minute"), opts),
|
|
1207
1252
|
"minute",
|
|
1208
1253
|
"hour",
|
|
1209
1254
|
opts
|
|
@@ -1214,21 +1259,28 @@ function renderHourStep(ir, plan, opts) {
|
|
|
1214
1259
|
if (cadence !== null) {
|
|
1215
1260
|
return cadence + trailingQualifier(ir, opts);
|
|
1216
1261
|
}
|
|
1217
|
-
return stepHours(ir
|
|
1262
|
+
return stepHours(stepSegment(ir, "hour"), opts) + trailingQualifier(ir, opts);
|
|
1218
1263
|
}
|
|
1219
1264
|
function boundedWindow(plan) {
|
|
1220
|
-
const
|
|
1221
|
-
|
|
1265
|
+
const continuous = plan.minuteForm === "wildcard";
|
|
1266
|
+
const closeMinute = continuous ? plan.boundMinute ?? 0 : 0;
|
|
1267
|
+
return { from: plan.from, closeMinute, to: plan.to, continuous };
|
|
1222
1268
|
}
|
|
1223
|
-
function rangeWindow(
|
|
1269
|
+
function rangeWindow(window, opts) {
|
|
1270
|
+
const { from, to, throughMinute, continuous } = window;
|
|
1224
1271
|
const open = "from " + getTime({ hour: from, minute: 0 }, opts);
|
|
1225
1272
|
if (opts.style.untilWindow && !opts.short && from !== to) {
|
|
1226
|
-
return open + " until " + getTime({ hour: (to + 1) % 24, minute: 0 }, opts);
|
|
1273
|
+
return continuous ? open + " until " + getTime({ hour: (to + 1) % 24, minute: 0 }, opts) : open + through(opts) + getTime({ hour: to, minute: 0 }, opts);
|
|
1227
1274
|
}
|
|
1228
1275
|
return open + through(opts) + getTime({ hour: to, minute: throughMinute }, opts);
|
|
1229
1276
|
}
|
|
1230
1277
|
function hourWindow(window, opts) {
|
|
1231
|
-
return rangeWindow(
|
|
1278
|
+
return rangeWindow({
|
|
1279
|
+
continuous: window.continuous,
|
|
1280
|
+
from: window.from,
|
|
1281
|
+
throughMinute: window.closeMinute,
|
|
1282
|
+
to: window.to
|
|
1283
|
+
}, opts);
|
|
1232
1284
|
}
|
|
1233
1285
|
function renderClockTimes(ir, plan, opts) {
|
|
1234
1286
|
if (ir.shapes.minute === "single") {
|
|
@@ -1258,7 +1310,7 @@ function renderCompactClockTimes(ir, plan, opts) {
|
|
|
1258
1310
|
if (cadence2 !== null) {
|
|
1259
1311
|
return cadence2;
|
|
1260
1312
|
}
|
|
1261
|
-
const hasRange = ir
|
|
1313
|
+
const hasRange = segmentsOf(ir, "hour").some(function range(segment) {
|
|
1262
1314
|
return segment.kind === "range";
|
|
1263
1315
|
});
|
|
1264
1316
|
if (hasRange && !ir.analyses.clockSecond) {
|
|
@@ -1270,8 +1322,8 @@ function renderCompactClockTimes(ir, plan, opts) {
|
|
|
1270
1322
|
const minuteLead = (
|
|
1271
1323
|
// The non-fold branch is a minute list, which has segments. An
|
|
1272
1324
|
// offset/uneven step enumerated to that list reads as a stride.
|
|
1273
|
-
strideFromSegments(ir
|
|
1274
|
-
segmentWords(ir
|
|
1325
|
+
strideFromSegments(segmentsOf(ir, "minute"), "minute", "hour", opts) ?? listPastThe(
|
|
1326
|
+
segmentWords(segmentsOf(ir, "minute"), opts),
|
|
1275
1327
|
"minute",
|
|
1276
1328
|
"hour",
|
|
1277
1329
|
opts
|
|
@@ -1284,42 +1336,38 @@ function renderCompactClockTimes(ir, plan, opts) {
|
|
|
1284
1336
|
function foldedHourWindows(ir, plan, opts) {
|
|
1285
1337
|
const minute = plan.minute;
|
|
1286
1338
|
const windows = [];
|
|
1287
|
-
const
|
|
1288
|
-
const times = outliers.hours.map(function time(hour) {
|
|
1339
|
+
const times = collectHourOutliers(ir).map(function time(hour) {
|
|
1289
1340
|
return getTime({ hour, minute }, opts);
|
|
1290
1341
|
});
|
|
1291
|
-
ir
|
|
1342
|
+
segmentsOf(ir, "hour").forEach(function classify(segment) {
|
|
1292
1343
|
if (segment.kind === "range") {
|
|
1293
|
-
windows.push(rangeWindow(
|
|
1294
|
-
|
|
1295
|
-
+segment.bounds[
|
|
1296
|
-
minute,
|
|
1297
|
-
|
|
1298
|
-
));
|
|
1344
|
+
windows.push(rangeWindow({
|
|
1345
|
+
continuous: false,
|
|
1346
|
+
from: +segment.bounds[0],
|
|
1347
|
+
throughMinute: minute,
|
|
1348
|
+
to: +segment.bounds[1]
|
|
1349
|
+
}, opts));
|
|
1299
1350
|
}
|
|
1300
1351
|
});
|
|
1301
1352
|
const phrase = rangeMinuteLead(ir, opts) + " " + joinList(windows, opts);
|
|
1302
|
-
return phrase + outlierTail(times,
|
|
1353
|
+
return phrase + outlierTail(times, opts);
|
|
1303
1354
|
}
|
|
1304
1355
|
function collectHourOutliers(ir) {
|
|
1305
1356
|
const hours = [];
|
|
1306
|
-
|
|
1307
|
-
ir.analyses.segments.hour.forEach(function classify(segment) {
|
|
1357
|
+
segmentsOf(ir, "hour").forEach(function classify(segment) {
|
|
1308
1358
|
if (segment.kind === "step") {
|
|
1309
1359
|
hours.push(...segment.fires);
|
|
1310
|
-
pureStrays = false;
|
|
1311
1360
|
} else if (segment.kind !== "range") {
|
|
1312
1361
|
hours.push(+segment.value);
|
|
1313
1362
|
}
|
|
1314
1363
|
});
|
|
1315
|
-
return
|
|
1364
|
+
return hours;
|
|
1316
1365
|
}
|
|
1317
|
-
function outlierTail(times,
|
|
1366
|
+
function outlierTail(times, opts) {
|
|
1318
1367
|
if (!times.length) {
|
|
1319
1368
|
return "";
|
|
1320
1369
|
}
|
|
1321
|
-
|
|
1322
|
-
return connector + joinList(times, opts);
|
|
1370
|
+
return " and at " + joinList(times, opts);
|
|
1323
1371
|
}
|
|
1324
1372
|
function isCadenceField(token) {
|
|
1325
1373
|
return token === "*" || token.startsWith("*/") && token.indexOf("-") === -1;
|
|
@@ -1333,7 +1381,7 @@ function leadingCadence(ir, opts) {
|
|
|
1333
1381
|
const text = minute === "*" ? "every minute" : (
|
|
1334
1382
|
// A clean minute step's first segment is a step segment.
|
|
1335
1383
|
stepCycle60(
|
|
1336
|
-
ir
|
|
1384
|
+
stepSegment(ir, "minute"),
|
|
1337
1385
|
"minute",
|
|
1338
1386
|
"hour",
|
|
1339
1387
|
opts
|
|
@@ -1351,7 +1399,7 @@ function minuteConfinement(ir, opts) {
|
|
|
1351
1399
|
if (isCadenceField(minute)) {
|
|
1352
1400
|
return " of every other minute";
|
|
1353
1401
|
}
|
|
1354
|
-
const segments = ir
|
|
1402
|
+
const segments = segmentsOf(ir, "minute");
|
|
1355
1403
|
if (ir.shapes.minute === "single") {
|
|
1356
1404
|
return " during minute :" + pad(minute);
|
|
1357
1405
|
}
|
|
@@ -1385,7 +1433,12 @@ function hourConfinement(ir, opts) {
|
|
|
1385
1433
|
}
|
|
1386
1434
|
if (ir.shapes.hour === "range") {
|
|
1387
1435
|
const bounds = hour.split("-");
|
|
1388
|
-
return " " + rangeWindow(
|
|
1436
|
+
return " " + rangeWindow({
|
|
1437
|
+
continuous: ir.pattern.minute === "*",
|
|
1438
|
+
from: +bounds[0],
|
|
1439
|
+
throughMinute: 0,
|
|
1440
|
+
to: +bounds[1]
|
|
1441
|
+
}, opts);
|
|
1389
1442
|
}
|
|
1390
1443
|
return " during the " + hourSegmentTimes(ir, { minute: 0, second: null }, false, opts) + " hours";
|
|
1391
1444
|
}
|
|
@@ -1396,14 +1449,14 @@ function confinableHour(ir) {
|
|
|
1396
1449
|
if (ir.shapes.hour !== "step") {
|
|
1397
1450
|
return true;
|
|
1398
1451
|
}
|
|
1399
|
-
const segment = ir
|
|
1452
|
+
const segment = stepSegment(ir, "hour");
|
|
1400
1453
|
return ir.pattern.hour === "*/2" || segment.startToken.indexOf("-") !== -1;
|
|
1401
1454
|
}
|
|
1402
1455
|
function isMinuteStride(ir) {
|
|
1403
1456
|
if (ir.shapes.minute !== "list") {
|
|
1404
1457
|
return false;
|
|
1405
1458
|
}
|
|
1406
|
-
const values = singleValues(ir
|
|
1459
|
+
const values = singleValues(segmentsOf(ir, "minute"));
|
|
1407
1460
|
return values !== null && arithmeticStep(values) !== null;
|
|
1408
1461
|
}
|
|
1409
1462
|
function confinementEligible(ir, lead) {
|
|
@@ -1473,16 +1526,6 @@ function renderStride(stride, opts) {
|
|
|
1473
1526
|
const num = seriesNumber();
|
|
1474
1527
|
return cadence + " from " + num(start) + through(opts) + num(last) + " " + pluralize(last, unit) + " past the " + anchor;
|
|
1475
1528
|
}
|
|
1476
|
-
function singleValues(segments) {
|
|
1477
|
-
const values = [];
|
|
1478
|
-
for (const segment of segments) {
|
|
1479
|
-
if (segment.kind !== "single") {
|
|
1480
|
-
return null;
|
|
1481
|
-
}
|
|
1482
|
-
values.push(+segment.value);
|
|
1483
|
-
}
|
|
1484
|
-
return values;
|
|
1485
|
-
}
|
|
1486
1529
|
function strideFromSegments(segments, unit, anchor, opts) {
|
|
1487
1530
|
const values = singleValues(segments);
|
|
1488
1531
|
const step = values && arithmeticStep(values);
|
|
@@ -1531,9 +1574,6 @@ function hourStrideCadence(stride, opts) {
|
|
|
1531
1574
|
}
|
|
1532
1575
|
return cadence + " from " + getTime({ hour: start, minute: 0 }, opts) + through(opts) + getTime({ hour: last, minute: 0 }, opts);
|
|
1533
1576
|
}
|
|
1534
|
-
function offsetCleanStride(stride) {
|
|
1535
|
-
return stride.start < stride.interval && 24 % stride.interval === 0;
|
|
1536
|
-
}
|
|
1537
1577
|
function unevenHourCadence(ir, opts) {
|
|
1538
1578
|
const stride = hourStride(ir);
|
|
1539
1579
|
if (!stride || offsetCleanStride(stride)) {
|
|
@@ -1541,26 +1581,8 @@ function unevenHourCadence(ir, opts) {
|
|
|
1541
1581
|
}
|
|
1542
1582
|
return hourStrideCadence(stride, opts);
|
|
1543
1583
|
}
|
|
1544
|
-
function hourListStride(values) {
|
|
1545
|
-
if (values.length < 2) {
|
|
1546
|
-
return null;
|
|
1547
|
-
}
|
|
1548
|
-
const interval = values[1] - values[0];
|
|
1549
|
-
if (interval < 2) {
|
|
1550
|
-
return null;
|
|
1551
|
-
}
|
|
1552
|
-
for (let i = 2; i < values.length; i += 1) {
|
|
1553
|
-
if (values[i] - values[i - 1] !== interval) {
|
|
1554
|
-
return null;
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
if (values[0] !== 0 && values.length < 5) {
|
|
1558
|
-
return null;
|
|
1559
|
-
}
|
|
1560
|
-
return { interval, last: values[values.length - 1], start: values[0] };
|
|
1561
|
-
}
|
|
1562
1584
|
function hourStride(ir) {
|
|
1563
|
-
const segments = ir
|
|
1585
|
+
const segments = segmentsOf(ir, "hour");
|
|
1564
1586
|
if (segments.length === 1 && segments[0].kind === "step") {
|
|
1565
1587
|
const segment = segments[0];
|
|
1566
1588
|
if (segment.fires.length < 2) {
|
|
@@ -1607,7 +1629,7 @@ function hourCadence(ir, minute, opts) {
|
|
|
1607
1629
|
return hourCadenceLead(ir, minute, opts) + ", " + hourStrideCadence(stride, opts) + trailingQualifier(ir, opts);
|
|
1608
1630
|
}
|
|
1609
1631
|
function cleanStrideSegment(ir) {
|
|
1610
|
-
const segments = ir
|
|
1632
|
+
const segments = segmentsOf(ir, "hour");
|
|
1611
1633
|
const segment = segments.length === 1 && segments[0];
|
|
1612
1634
|
if (!segment || segment.kind !== "step" || segment.startToken.indexOf("-") !== -1 || !(segment.interval in stepOrdinals)) {
|
|
1613
1635
|
return null;
|
|
@@ -1615,28 +1637,28 @@ function cleanStrideSegment(ir) {
|
|
|
1615
1637
|
return segment;
|
|
1616
1638
|
}
|
|
1617
1639
|
function hasHourWindow(ir) {
|
|
1618
|
-
return ir
|
|
1640
|
+
return segmentsOf(ir, "hour").some(function range(segment) {
|
|
1619
1641
|
return segment.kind === "range";
|
|
1620
1642
|
});
|
|
1621
1643
|
}
|
|
1622
1644
|
function hourRangeWindowTail(ir, opts) {
|
|
1623
1645
|
const windows = [];
|
|
1624
|
-
const
|
|
1625
|
-
ir
|
|
1646
|
+
const outlierHours = collectHourOutliers(ir);
|
|
1647
|
+
segmentsOf(ir, "hour").forEach(function classify(segment) {
|
|
1626
1648
|
if (segment.kind === "range") {
|
|
1627
|
-
windows.push(rangeWindow(
|
|
1628
|
-
|
|
1629
|
-
+segment.bounds[
|
|
1630
|
-
0,
|
|
1631
|
-
|
|
1632
|
-
));
|
|
1649
|
+
windows.push(rangeWindow({
|
|
1650
|
+
continuous: false,
|
|
1651
|
+
from: +segment.bounds[0],
|
|
1652
|
+
throughMinute: 0,
|
|
1653
|
+
to: +segment.bounds[1]
|
|
1654
|
+
}, opts));
|
|
1633
1655
|
}
|
|
1634
1656
|
});
|
|
1635
1657
|
const phrase = "every hour " + joinList(windows, opts);
|
|
1636
|
-
const times =
|
|
1658
|
+
const times = outlierHours.map(function time(hour) {
|
|
1637
1659
|
return getTime({ hour, minute: 0 }, opts);
|
|
1638
1660
|
});
|
|
1639
|
-
return phrase + outlierTail(times,
|
|
1661
|
+
return phrase + outlierTail(times, opts);
|
|
1640
1662
|
}
|
|
1641
1663
|
function hourRangeCadence(ir, minute, opts) {
|
|
1642
1664
|
if (minute !== 0 || !hasHourWindow(ir)) {
|
|
@@ -1721,7 +1743,7 @@ function segmentHours(segment) {
|
|
|
1721
1743
|
}
|
|
1722
1744
|
function hourSegmentTimes(ir, fold, atContext, opts) {
|
|
1723
1745
|
const { minute, second } = fold;
|
|
1724
|
-
const segments = ir
|
|
1746
|
+
const segments = segmentsOf(ir, "hour");
|
|
1725
1747
|
const plain = mixedTwelve(segments.flatMap(function entries(segment) {
|
|
1726
1748
|
return segmentHours(segment).map(function entry(hour) {
|
|
1727
1749
|
return { hour: +hour, minute, second };
|
|
@@ -1841,7 +1863,7 @@ function datePhrase(ir, words, opts) {
|
|
|
1841
1863
|
}
|
|
1842
1864
|
function monthFoldsIntoDate(ir) {
|
|
1843
1865
|
return !oddEvenMonth(ir.pattern.month) && // Reached only with a restricted month, which has segments.
|
|
1844
|
-
ir
|
|
1866
|
+
segmentsOf(ir, "month").every(function flat(segment) {
|
|
1845
1867
|
return segment.kind !== "range";
|
|
1846
1868
|
});
|
|
1847
1869
|
}
|
|
@@ -1872,7 +1894,7 @@ function dayUnionDatePieces(ir, opts) {
|
|
|
1872
1894
|
return [oddEven];
|
|
1873
1895
|
}
|
|
1874
1896
|
const pieces = [];
|
|
1875
|
-
ir
|
|
1897
|
+
segmentsOf(ir, "date").forEach(function expand(segment) {
|
|
1876
1898
|
if (segment.kind === "range") {
|
|
1877
1899
|
pieces.push("from the " + getOrdinal(segment.bounds[0]) + through(opts) + "the " + getOrdinal(segment.bounds[1]));
|
|
1878
1900
|
} else if (segment.kind === "step") {
|
|
@@ -1892,7 +1914,7 @@ function dayUnionWeekdayPieces(ir, opts) {
|
|
|
1892
1914
|
return [quartz.replace(/^on /, "")];
|
|
1893
1915
|
}
|
|
1894
1916
|
const pieces = [];
|
|
1895
|
-
ir
|
|
1917
|
+
segmentsOf(ir, "weekday").forEach(function expand(segment) {
|
|
1896
1918
|
if (segment.kind === "range" && segment.bounds[0] === "1" && segment.bounds[1] === "5") {
|
|
1897
1919
|
pieces.push("a weekday");
|
|
1898
1920
|
} else if (segment.kind === "range") {
|
|
@@ -1973,7 +1995,7 @@ function quartzWeekdayPhrase(weekdayField, opts) {
|
|
|
1973
1995
|
function monthDatePhrase(ir, opts) {
|
|
1974
1996
|
const month = monthName(ir, opts);
|
|
1975
1997
|
const days = renderSegments(
|
|
1976
|
-
ir
|
|
1998
|
+
segmentsOf(ir, "date"),
|
|
1977
1999
|
opts.style.ordinals ? getOrdinal : cardinalDay,
|
|
1978
2000
|
opts
|
|
1979
2001
|
);
|
|
@@ -2016,14 +2038,14 @@ function stepDates(dateField) {
|
|
|
2016
2038
|
return phrase;
|
|
2017
2039
|
}
|
|
2018
2040
|
function dateOrdinals(ir, opts) {
|
|
2019
|
-
return renderSegments(ir
|
|
2041
|
+
return renderSegments(segmentsOf(ir, "date"), getOrdinal, opts);
|
|
2020
2042
|
}
|
|
2021
2043
|
function monthName(ir, opts) {
|
|
2022
2044
|
const oddEven = oddEvenMonth(ir.pattern.month);
|
|
2023
2045
|
if (oddEven) {
|
|
2024
2046
|
return oddEven;
|
|
2025
2047
|
}
|
|
2026
|
-
return renderSegments(ir
|
|
2048
|
+
return renderSegments(segmentsOf(ir, "month"), function name(value) {
|
|
2027
2049
|
return getMonth(value, opts);
|
|
2028
2050
|
}, opts);
|
|
2029
2051
|
}
|
|
@@ -2041,7 +2063,7 @@ function oddEvenMonth(monthField) {
|
|
|
2041
2063
|
return start === "2" ? "every even-numbered month" : null;
|
|
2042
2064
|
}
|
|
2043
2065
|
function weekdayPhrase(ir, recurring, opts) {
|
|
2044
|
-
const segments = orderWeekdaysForDisplay(ir
|
|
2066
|
+
const segments = orderWeekdaysForDisplay(segmentsOf(ir, "weekday"));
|
|
2045
2067
|
const hasRange = segments.some(function range(segment) {
|
|
2046
2068
|
return segment.kind === "range";
|
|
2047
2069
|
});
|
|
@@ -2069,9 +2091,6 @@ function renderSegments(segments, word, opts) {
|
|
|
2069
2091
|
});
|
|
2070
2092
|
return joinList(pieces, opts);
|
|
2071
2093
|
}
|
|
2072
|
-
function isOpenStep(field) {
|
|
2073
|
-
return field.indexOf("/") !== -1 && field.indexOf("-") === -1 && field.indexOf(",") === -1;
|
|
2074
|
-
}
|
|
2075
2094
|
function applyYear(description, ir, opts) {
|
|
2076
2095
|
const yearField = ir.pattern.year;
|
|
2077
2096
|
if (yearField === "*") {
|
|
@@ -2205,7 +2224,7 @@ function interpretCronPattern(cronPattern, lang, opts) {
|
|
|
2205
2224
|
return lang.reboot;
|
|
2206
2225
|
}
|
|
2207
2226
|
const ir = analyze(prepare(cronPattern, opts));
|
|
2208
|
-
const plan = lang.
|
|
2227
|
+
const plan = lang.plan ? lang.plan(ir, ir.plan) : ir.plan;
|
|
2209
2228
|
return lang.describe({ ...ir, plan }, opts);
|
|
2210
2229
|
}
|
|
2211
2230
|
var cronli5_default = cronli5;
|