cronli5 0.1.6 → 0.2.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/CHANGELOG.md +86 -0
- package/README.md +6 -6
- package/cronli5.min.js +2 -2
- package/dist/cronli5.cjs +401 -81
- package/dist/cronli5.js +401 -81
- package/dist/lang/de.cjs +63 -17
- package/dist/lang/de.js +63 -17
- package/dist/lang/en.cjs +401 -81
- package/dist/lang/en.js +401 -81
- package/dist/lang/es.cjs +68 -5
- package/dist/lang/es.js +68 -5
- package/dist/lang/fi.cjs +21 -1
- package/dist/lang/fi.js +21 -1
- package/dist/lang/zh.cjs +38 -7
- package/dist/lang/zh.js +38 -7
- package/package.json +1 -1
- package/src/core/ir.ts +5 -0
- package/src/core/util.ts +52 -1
- package/src/lang/de/index.ts +95 -25
- package/src/lang/en/dialects.ts +6 -2
- package/src/lang/en/index.ts +781 -117
- package/src/lang/es/index.ts +85 -9
- package/src/lang/fi/index.ts +6 -2
- package/src/lang/zh/index.ts +44 -18
- package/types/core/ir.d.ts +1 -0
- package/types/core/util.d.ts +10 -1
package/dist/lang/de.cjs
CHANGED
|
@@ -62,6 +62,26 @@ function arithmeticStep(values) {
|
|
|
62
62
|
}
|
|
63
63
|
return { start: values[0], interval, last: values[values.length - 1] };
|
|
64
64
|
}
|
|
65
|
+
function weekdayDisplayKey(value) {
|
|
66
|
+
return value === 0 ? 7 : value;
|
|
67
|
+
}
|
|
68
|
+
function orderWeekdaysForDisplay(segments) {
|
|
69
|
+
const flattened = segments.flatMap(function flat(segment) {
|
|
70
|
+
return segment.kind === "step" ? segment.fires.map(function single(value) {
|
|
71
|
+
return { kind: "single", value: "" + value };
|
|
72
|
+
}) : [segment];
|
|
73
|
+
});
|
|
74
|
+
function key(segment) {
|
|
75
|
+
return segment.kind === "range" ? weekdayDisplayKey(+segment.bounds[0]) : weekdayDisplayKey(+segment.value);
|
|
76
|
+
}
|
|
77
|
+
return flattened.map(function index(segment, position) {
|
|
78
|
+
return [segment, position];
|
|
79
|
+
}).sort(function byDisplayKey(a, b) {
|
|
80
|
+
return key(a[0]) - key(b[0]) || a[1] - b[1];
|
|
81
|
+
}).map(function unwrap(pair) {
|
|
82
|
+
return pair[0];
|
|
83
|
+
});
|
|
84
|
+
}
|
|
65
85
|
function toFieldNumber(token, numberMap) {
|
|
66
86
|
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
67
87
|
}
|
|
@@ -122,6 +142,9 @@ function everyUnit(unit) {
|
|
|
122
142
|
function everyN(interval, unit) {
|
|
123
143
|
return "alle " + interval + " " + unit.plural;
|
|
124
144
|
}
|
|
145
|
+
function withAnchor(clause, anchor) {
|
|
146
|
+
return anchor ? clause + " " + anchor : clause;
|
|
147
|
+
}
|
|
125
148
|
function stepSegment(segments) {
|
|
126
149
|
return segments[0];
|
|
127
150
|
}
|
|
@@ -145,7 +168,10 @@ function stepClause(segment, unit, anchor) {
|
|
|
145
168
|
const start = segment.startToken === "*" ? 0 : +segment.startToken;
|
|
146
169
|
const short = start !== 0 && segment.fires.length <= 3;
|
|
147
170
|
if (segment.startToken.indexOf("-") !== -1 || short) {
|
|
148
|
-
return
|
|
171
|
+
return withAnchor(
|
|
172
|
+
"in den " + unit.plural + " " + joinList(segment.fires.map(String)),
|
|
173
|
+
anchor
|
|
174
|
+
);
|
|
149
175
|
}
|
|
150
176
|
return renderStride({
|
|
151
177
|
interval: segment.interval,
|
|
@@ -206,7 +232,7 @@ function weekdayRange(bounds) {
|
|
|
206
232
|
return weekdayName(bounds[0]) + " bis " + weekdayName(bounds[1]);
|
|
207
233
|
}
|
|
208
234
|
function weekdayQualifier(ir) {
|
|
209
|
-
const segments =
|
|
235
|
+
const segments = orderWeekdaysForDisplay(fieldSegments(ir, "weekday"));
|
|
210
236
|
if (segments.length === 1 && segments[0].kind === "range") {
|
|
211
237
|
return weekdayRange(segments[0].bounds);
|
|
212
238
|
}
|
|
@@ -346,8 +372,11 @@ function countedPhrase(ir, field, singular, plural) {
|
|
|
346
372
|
}
|
|
347
373
|
return "in den " + plural + " " + joinList(fieldValues(ir, field));
|
|
348
374
|
}
|
|
375
|
+
function minuteAnchor(ir) {
|
|
376
|
+
return ir.pattern.minute === "*" ? "jeder Minute" : "";
|
|
377
|
+
}
|
|
349
378
|
function secondsLead(ir) {
|
|
350
|
-
return secondsClause(ir,
|
|
379
|
+
return secondsClause(ir, minuteAnchor(ir));
|
|
351
380
|
}
|
|
352
381
|
function secondsClause(ir, anchor) {
|
|
353
382
|
if (ir.pattern.second === "*") {
|
|
@@ -357,7 +386,7 @@ function secondsClause(ir, anchor) {
|
|
|
357
386
|
if (ir.shapes.second === "step") {
|
|
358
387
|
return stepClause(stepSegment(segments), UNITS.second, anchor);
|
|
359
388
|
}
|
|
360
|
-
return strideFromSegments(segments, UNITS.second, anchor) ?? countedPhrase(ir, "second", "Sekunde", "Sekunden")
|
|
389
|
+
return strideFromSegments(segments, UNITS.second, anchor) ?? withAnchor(countedPhrase(ir, "second", "Sekunde", "Sekunden"), anchor);
|
|
361
390
|
}
|
|
362
391
|
function spanTime(hour, minute, sep) {
|
|
363
392
|
return hour + sep + pad(minute);
|
|
@@ -532,16 +561,22 @@ function renderMinuteFrequency(ir, plan, opts) {
|
|
|
532
561
|
const segment = stepSegment(ir.analyses.segments.minute);
|
|
533
562
|
const sep = opts.style.sep;
|
|
534
563
|
const clean = cleanStep(segment, 60);
|
|
535
|
-
const base = stepClause(segment, UNITS.minute, "jeder Stunde");
|
|
536
564
|
if (plan.hours.kind === "window") {
|
|
565
|
+
const singleHour = plan.hours.from === plan.hours.to;
|
|
566
|
+
const base2 = stepClause(
|
|
567
|
+
segment,
|
|
568
|
+
UNITS.minute,
|
|
569
|
+
singleHour ? "" : "jeder Stunde"
|
|
570
|
+
);
|
|
537
571
|
const window = hourWindow(
|
|
538
572
|
plan.hours.from,
|
|
539
573
|
plan.hours.to,
|
|
540
574
|
plan.hours.last,
|
|
541
575
|
sep
|
|
542
576
|
);
|
|
543
|
-
return clean ?
|
|
577
|
+
return clean ? base2 + " " + window : base2 + ", " + window;
|
|
544
578
|
}
|
|
579
|
+
const base = stepClause(segment, UNITS.minute, "jeder Stunde");
|
|
545
580
|
if (plan.hours.kind === "during") {
|
|
546
581
|
const cadence = unevenHourCadence(ir);
|
|
547
582
|
return cadence ? base + ", " + cadence : base + " " + duringHours(ir, plan.hours.times, sep);
|
|
@@ -557,7 +592,18 @@ function hourStepPhrase(ir) {
|
|
|
557
592
|
return cadence;
|
|
558
593
|
}
|
|
559
594
|
const segment = stepSegment(ir.analyses.segments.hour);
|
|
560
|
-
|
|
595
|
+
if (cleanStep(segment, 24)) {
|
|
596
|
+
return everyN(segment.interval, UNITS.hour);
|
|
597
|
+
}
|
|
598
|
+
const stride = openOffsetCleanStride(ir, segment);
|
|
599
|
+
return stride ? hourStrideCadence(stride) : atHours(segment.fires);
|
|
600
|
+
}
|
|
601
|
+
function openOffsetCleanStride(ir, segment) {
|
|
602
|
+
if (segment.startToken.indexOf("-") !== -1) {
|
|
603
|
+
return null;
|
|
604
|
+
}
|
|
605
|
+
const stride = hourStride(ir);
|
|
606
|
+
return stride && offsetCleanStride(stride) ? stride : null;
|
|
561
607
|
}
|
|
562
608
|
function hourStrideCadence(stride) {
|
|
563
609
|
const { start, interval, last } = stride;
|
|
@@ -621,7 +667,7 @@ function subMinuteSecond(ir) {
|
|
|
621
667
|
function hourCadenceLead(ir, minute) {
|
|
622
668
|
if (minute === 0) {
|
|
623
669
|
if (subMinuteSecond(ir)) {
|
|
624
|
-
return secondsClause(ir,
|
|
670
|
+
return withAnchor(secondsClause(ir, minuteAnchor(ir)), "f\xFCr eine Minute");
|
|
625
671
|
}
|
|
626
672
|
return secondsClause(ir, "jeder Stunde");
|
|
627
673
|
}
|
|
@@ -629,7 +675,7 @@ function hourCadenceLead(ir, minute) {
|
|
|
629
675
|
if (ir.pattern.second === "0") {
|
|
630
676
|
return minutePhrase;
|
|
631
677
|
}
|
|
632
|
-
return secondsClause(ir,
|
|
678
|
+
return secondsClause(ir, minuteAnchor(ir)) + ", " + minutePhrase;
|
|
633
679
|
}
|
|
634
680
|
function hourCadence(ir, minute) {
|
|
635
681
|
const stride = hourStride(ir);
|
|
@@ -643,7 +689,7 @@ function hourCadence(ir, minute) {
|
|
|
643
689
|
const segment = fieldSegments(ir, "hour")[0];
|
|
644
690
|
const confined = minute === 0 && subMinuteSecond(ir) && fieldSegments(ir, "hour").length === 1 && segment.kind === "step" && confinedHourStride(segment);
|
|
645
691
|
if (confined) {
|
|
646
|
-
return secondsClause(ir,
|
|
692
|
+
return withAnchor(secondsClause(ir, minuteAnchor(ir)), "f\xFCr eine Minute") + " " + everyNthHour(segment);
|
|
647
693
|
}
|
|
648
694
|
if (minute === 0 && ir.pattern.second === "0") {
|
|
649
695
|
return hourStrideCadence(stride);
|
|
@@ -673,12 +719,8 @@ function hourRangeWindowTail(ir) {
|
|
|
673
719
|
return joinList(hourSegmentParts(ir, 0, 0, ":"));
|
|
674
720
|
}
|
|
675
721
|
function renderHourRange(ir, plan, opts) {
|
|
676
|
-
const
|
|
677
|
-
|
|
678
|
-
plan.to,
|
|
679
|
-
plan.boundMinute ?? 0,
|
|
680
|
-
opts.style.sep
|
|
681
|
-
);
|
|
722
|
+
const last = plan.minuteForm === "wildcard" ? plan.boundMinute ?? 0 : 0;
|
|
723
|
+
const window = hourWindow(plan.from, plan.to, last, opts.style.sep);
|
|
682
724
|
if (plan.minuteForm === "wildcard") {
|
|
683
725
|
return "jede Minute " + window;
|
|
684
726
|
}
|
|
@@ -754,7 +796,11 @@ function needsDailyFrame(ir) {
|
|
|
754
796
|
if (ir.plan.kind === "clockTimes" || isComposeMinuteZero(ir)) {
|
|
755
797
|
return true;
|
|
756
798
|
}
|
|
757
|
-
|
|
799
|
+
if (ir.plan.kind !== "hourStep") {
|
|
800
|
+
return false;
|
|
801
|
+
}
|
|
802
|
+
const segment = stepSegment(ir.analyses.segments.hour);
|
|
803
|
+
return !cleanStep(segment, 24) && !openOffsetCleanStride(ir, segment);
|
|
758
804
|
}
|
|
759
805
|
function render(ir, plan, opts) {
|
|
760
806
|
return renderers[plan.kind](
|
package/dist/lang/de.js
CHANGED
|
@@ -36,6 +36,26 @@ function arithmeticStep(values) {
|
|
|
36
36
|
}
|
|
37
37
|
return { start: values[0], interval, last: values[values.length - 1] };
|
|
38
38
|
}
|
|
39
|
+
function weekdayDisplayKey(value) {
|
|
40
|
+
return value === 0 ? 7 : value;
|
|
41
|
+
}
|
|
42
|
+
function orderWeekdaysForDisplay(segments) {
|
|
43
|
+
const flattened = segments.flatMap(function flat(segment) {
|
|
44
|
+
return segment.kind === "step" ? segment.fires.map(function single(value) {
|
|
45
|
+
return { kind: "single", value: "" + value };
|
|
46
|
+
}) : [segment];
|
|
47
|
+
});
|
|
48
|
+
function key(segment) {
|
|
49
|
+
return segment.kind === "range" ? weekdayDisplayKey(+segment.bounds[0]) : weekdayDisplayKey(+segment.value);
|
|
50
|
+
}
|
|
51
|
+
return flattened.map(function index(segment, position) {
|
|
52
|
+
return [segment, position];
|
|
53
|
+
}).sort(function byDisplayKey(a, b) {
|
|
54
|
+
return key(a[0]) - key(b[0]) || a[1] - b[1];
|
|
55
|
+
}).map(function unwrap(pair) {
|
|
56
|
+
return pair[0];
|
|
57
|
+
});
|
|
58
|
+
}
|
|
39
59
|
function toFieldNumber(token, numberMap) {
|
|
40
60
|
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
41
61
|
}
|
|
@@ -96,6 +116,9 @@ function everyUnit(unit) {
|
|
|
96
116
|
function everyN(interval, unit) {
|
|
97
117
|
return "alle " + interval + " " + unit.plural;
|
|
98
118
|
}
|
|
119
|
+
function withAnchor(clause, anchor) {
|
|
120
|
+
return anchor ? clause + " " + anchor : clause;
|
|
121
|
+
}
|
|
99
122
|
function stepSegment(segments) {
|
|
100
123
|
return segments[0];
|
|
101
124
|
}
|
|
@@ -119,7 +142,10 @@ function stepClause(segment, unit, anchor) {
|
|
|
119
142
|
const start = segment.startToken === "*" ? 0 : +segment.startToken;
|
|
120
143
|
const short = start !== 0 && segment.fires.length <= 3;
|
|
121
144
|
if (segment.startToken.indexOf("-") !== -1 || short) {
|
|
122
|
-
return
|
|
145
|
+
return withAnchor(
|
|
146
|
+
"in den " + unit.plural + " " + joinList(segment.fires.map(String)),
|
|
147
|
+
anchor
|
|
148
|
+
);
|
|
123
149
|
}
|
|
124
150
|
return renderStride({
|
|
125
151
|
interval: segment.interval,
|
|
@@ -180,7 +206,7 @@ function weekdayRange(bounds) {
|
|
|
180
206
|
return weekdayName(bounds[0]) + " bis " + weekdayName(bounds[1]);
|
|
181
207
|
}
|
|
182
208
|
function weekdayQualifier(ir) {
|
|
183
|
-
const segments =
|
|
209
|
+
const segments = orderWeekdaysForDisplay(fieldSegments(ir, "weekday"));
|
|
184
210
|
if (segments.length === 1 && segments[0].kind === "range") {
|
|
185
211
|
return weekdayRange(segments[0].bounds);
|
|
186
212
|
}
|
|
@@ -320,8 +346,11 @@ function countedPhrase(ir, field, singular, plural) {
|
|
|
320
346
|
}
|
|
321
347
|
return "in den " + plural + " " + joinList(fieldValues(ir, field));
|
|
322
348
|
}
|
|
349
|
+
function minuteAnchor(ir) {
|
|
350
|
+
return ir.pattern.minute === "*" ? "jeder Minute" : "";
|
|
351
|
+
}
|
|
323
352
|
function secondsLead(ir) {
|
|
324
|
-
return secondsClause(ir,
|
|
353
|
+
return secondsClause(ir, minuteAnchor(ir));
|
|
325
354
|
}
|
|
326
355
|
function secondsClause(ir, anchor) {
|
|
327
356
|
if (ir.pattern.second === "*") {
|
|
@@ -331,7 +360,7 @@ function secondsClause(ir, anchor) {
|
|
|
331
360
|
if (ir.shapes.second === "step") {
|
|
332
361
|
return stepClause(stepSegment(segments), UNITS.second, anchor);
|
|
333
362
|
}
|
|
334
|
-
return strideFromSegments(segments, UNITS.second, anchor) ?? countedPhrase(ir, "second", "Sekunde", "Sekunden")
|
|
363
|
+
return strideFromSegments(segments, UNITS.second, anchor) ?? withAnchor(countedPhrase(ir, "second", "Sekunde", "Sekunden"), anchor);
|
|
335
364
|
}
|
|
336
365
|
function spanTime(hour, minute, sep) {
|
|
337
366
|
return hour + sep + pad(minute);
|
|
@@ -506,16 +535,22 @@ function renderMinuteFrequency(ir, plan, opts) {
|
|
|
506
535
|
const segment = stepSegment(ir.analyses.segments.minute);
|
|
507
536
|
const sep = opts.style.sep;
|
|
508
537
|
const clean = cleanStep(segment, 60);
|
|
509
|
-
const base = stepClause(segment, UNITS.minute, "jeder Stunde");
|
|
510
538
|
if (plan.hours.kind === "window") {
|
|
539
|
+
const singleHour = plan.hours.from === plan.hours.to;
|
|
540
|
+
const base2 = stepClause(
|
|
541
|
+
segment,
|
|
542
|
+
UNITS.minute,
|
|
543
|
+
singleHour ? "" : "jeder Stunde"
|
|
544
|
+
);
|
|
511
545
|
const window = hourWindow(
|
|
512
546
|
plan.hours.from,
|
|
513
547
|
plan.hours.to,
|
|
514
548
|
plan.hours.last,
|
|
515
549
|
sep
|
|
516
550
|
);
|
|
517
|
-
return clean ?
|
|
551
|
+
return clean ? base2 + " " + window : base2 + ", " + window;
|
|
518
552
|
}
|
|
553
|
+
const base = stepClause(segment, UNITS.minute, "jeder Stunde");
|
|
519
554
|
if (plan.hours.kind === "during") {
|
|
520
555
|
const cadence = unevenHourCadence(ir);
|
|
521
556
|
return cadence ? base + ", " + cadence : base + " " + duringHours(ir, plan.hours.times, sep);
|
|
@@ -531,7 +566,18 @@ function hourStepPhrase(ir) {
|
|
|
531
566
|
return cadence;
|
|
532
567
|
}
|
|
533
568
|
const segment = stepSegment(ir.analyses.segments.hour);
|
|
534
|
-
|
|
569
|
+
if (cleanStep(segment, 24)) {
|
|
570
|
+
return everyN(segment.interval, UNITS.hour);
|
|
571
|
+
}
|
|
572
|
+
const stride = openOffsetCleanStride(ir, segment);
|
|
573
|
+
return stride ? hourStrideCadence(stride) : atHours(segment.fires);
|
|
574
|
+
}
|
|
575
|
+
function openOffsetCleanStride(ir, segment) {
|
|
576
|
+
if (segment.startToken.indexOf("-") !== -1) {
|
|
577
|
+
return null;
|
|
578
|
+
}
|
|
579
|
+
const stride = hourStride(ir);
|
|
580
|
+
return stride && offsetCleanStride(stride) ? stride : null;
|
|
535
581
|
}
|
|
536
582
|
function hourStrideCadence(stride) {
|
|
537
583
|
const { start, interval, last } = stride;
|
|
@@ -595,7 +641,7 @@ function subMinuteSecond(ir) {
|
|
|
595
641
|
function hourCadenceLead(ir, minute) {
|
|
596
642
|
if (minute === 0) {
|
|
597
643
|
if (subMinuteSecond(ir)) {
|
|
598
|
-
return secondsClause(ir,
|
|
644
|
+
return withAnchor(secondsClause(ir, minuteAnchor(ir)), "f\xFCr eine Minute");
|
|
599
645
|
}
|
|
600
646
|
return secondsClause(ir, "jeder Stunde");
|
|
601
647
|
}
|
|
@@ -603,7 +649,7 @@ function hourCadenceLead(ir, minute) {
|
|
|
603
649
|
if (ir.pattern.second === "0") {
|
|
604
650
|
return minutePhrase;
|
|
605
651
|
}
|
|
606
|
-
return secondsClause(ir,
|
|
652
|
+
return secondsClause(ir, minuteAnchor(ir)) + ", " + minutePhrase;
|
|
607
653
|
}
|
|
608
654
|
function hourCadence(ir, minute) {
|
|
609
655
|
const stride = hourStride(ir);
|
|
@@ -617,7 +663,7 @@ function hourCadence(ir, minute) {
|
|
|
617
663
|
const segment = fieldSegments(ir, "hour")[0];
|
|
618
664
|
const confined = minute === 0 && subMinuteSecond(ir) && fieldSegments(ir, "hour").length === 1 && segment.kind === "step" && confinedHourStride(segment);
|
|
619
665
|
if (confined) {
|
|
620
|
-
return secondsClause(ir,
|
|
666
|
+
return withAnchor(secondsClause(ir, minuteAnchor(ir)), "f\xFCr eine Minute") + " " + everyNthHour(segment);
|
|
621
667
|
}
|
|
622
668
|
if (minute === 0 && ir.pattern.second === "0") {
|
|
623
669
|
return hourStrideCadence(stride);
|
|
@@ -647,12 +693,8 @@ function hourRangeWindowTail(ir) {
|
|
|
647
693
|
return joinList(hourSegmentParts(ir, 0, 0, ":"));
|
|
648
694
|
}
|
|
649
695
|
function renderHourRange(ir, plan, opts) {
|
|
650
|
-
const
|
|
651
|
-
|
|
652
|
-
plan.to,
|
|
653
|
-
plan.boundMinute ?? 0,
|
|
654
|
-
opts.style.sep
|
|
655
|
-
);
|
|
696
|
+
const last = plan.minuteForm === "wildcard" ? plan.boundMinute ?? 0 : 0;
|
|
697
|
+
const window = hourWindow(plan.from, plan.to, last, opts.style.sep);
|
|
656
698
|
if (plan.minuteForm === "wildcard") {
|
|
657
699
|
return "jede Minute " + window;
|
|
658
700
|
}
|
|
@@ -728,7 +770,11 @@ function needsDailyFrame(ir) {
|
|
|
728
770
|
if (ir.plan.kind === "clockTimes" || isComposeMinuteZero(ir)) {
|
|
729
771
|
return true;
|
|
730
772
|
}
|
|
731
|
-
|
|
773
|
+
if (ir.plan.kind !== "hourStep") {
|
|
774
|
+
return false;
|
|
775
|
+
}
|
|
776
|
+
const segment = stepSegment(ir.analyses.segments.hour);
|
|
777
|
+
return !cleanStep(segment, 24) && !openOffsetCleanStride(ir, segment);
|
|
732
778
|
}
|
|
733
779
|
function render(ir, plan, opts) {
|
|
734
780
|
return renderers[plan.kind](
|