cronli5 0.1.6 → 0.1.7
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 +43 -0
- package/README.md +2 -2
- package/cronli5.min.js +2 -2
- package/dist/cronli5.cjs +39 -7
- package/dist/cronli5.js +39 -7
- package/dist/lang/de.cjs +63 -17
- package/dist/lang/de.js +63 -17
- package/dist/lang/en.cjs +39 -7
- package/dist/lang/en.js +39 -7
- 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/util.ts +52 -1
- package/src/lang/de/index.ts +95 -25
- package/src/lang/en/index.ts +47 -16
- 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/util.d.ts +10 -1
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](
|
package/dist/lang/en.cjs
CHANGED
|
@@ -40,6 +40,26 @@ function arithmeticStep(values) {
|
|
|
40
40
|
}
|
|
41
41
|
return { start: values[0], interval, last: values[values.length - 1] };
|
|
42
42
|
}
|
|
43
|
+
function weekdayDisplayKey(value) {
|
|
44
|
+
return value === 0 ? 7 : value;
|
|
45
|
+
}
|
|
46
|
+
function orderWeekdaysForDisplay(segments) {
|
|
47
|
+
const flattened = segments.flatMap(function flat(segment) {
|
|
48
|
+
return segment.kind === "step" ? segment.fires.map(function single(value) {
|
|
49
|
+
return { kind: "single", value: "" + value };
|
|
50
|
+
}) : [segment];
|
|
51
|
+
});
|
|
52
|
+
function key(segment) {
|
|
53
|
+
return segment.kind === "range" ? weekdayDisplayKey(+segment.bounds[0]) : weekdayDisplayKey(+segment.value);
|
|
54
|
+
}
|
|
55
|
+
return flattened.map(function index(segment, position) {
|
|
56
|
+
return [segment, position];
|
|
57
|
+
}).sort(function byDisplayKey(a, b) {
|
|
58
|
+
return key(a[0]) - key(b[0]) || a[1] - b[1];
|
|
59
|
+
}).map(function unwrap(pair) {
|
|
60
|
+
return pair[0];
|
|
61
|
+
});
|
|
62
|
+
}
|
|
43
63
|
|
|
44
64
|
// src/core/specs.ts
|
|
45
65
|
var maxClockTimes = 6;
|
|
@@ -417,7 +437,8 @@ function renderHourStep(ir, plan, opts) {
|
|
|
417
437
|
return stepHours(ir.analyses.segments.hour[0], opts) + trailingQualifier(ir, opts);
|
|
418
438
|
}
|
|
419
439
|
function boundedWindow(plan) {
|
|
420
|
-
|
|
440
|
+
const last = plan.minuteForm === "wildcard" ? plan.boundMinute ?? 0 : 0;
|
|
441
|
+
return { from: plan.from, last, to: plan.to };
|
|
421
442
|
}
|
|
422
443
|
function hourWindow(window, opts) {
|
|
423
444
|
return "from " + getTime({ hour: window.from, minute: 0 }, opts) + through(opts) + getTime({ hour: window.to, minute: window.last }, opts);
|
|
@@ -872,17 +893,27 @@ function monthFoldsIntoDate(ir) {
|
|
|
872
893
|
function dateOrWeekday(ir, opts) {
|
|
873
894
|
const pattern = ir.pattern;
|
|
874
895
|
const weekdayPart = quartzWeekdayPhrase(pattern.weekday, opts) || "on " + weekdayPhrase(ir, opts);
|
|
896
|
+
if (pattern.month !== "*" && monthFoldsIntoDate(ir) && !quartzDatePhrase(pattern.date, opts) && !isOpenStep(pattern.date)) {
|
|
897
|
+
return "on " + monthDatePhrase(ir, opts) + " or " + weekdayPart + " in " + monthName(ir, opts);
|
|
898
|
+
}
|
|
899
|
+
return datePart(ir, opts) + " or " + weekdayPart + orMonthScope(ir, opts);
|
|
900
|
+
}
|
|
901
|
+
function datePart(ir, opts) {
|
|
902
|
+
const pattern = ir.pattern;
|
|
875
903
|
const quartzDate = quartzDatePhrase(pattern.date, opts);
|
|
876
904
|
if (quartzDate) {
|
|
877
|
-
return quartzDate
|
|
905
|
+
return quartzDate;
|
|
878
906
|
}
|
|
879
907
|
if (isOpenStep(pattern.date)) {
|
|
880
|
-
return stepDates(pattern.date)
|
|
908
|
+
return stepDates(pattern.date);
|
|
881
909
|
}
|
|
882
|
-
|
|
883
|
-
|
|
910
|
+
return "on the " + dateOrdinals(ir, opts);
|
|
911
|
+
}
|
|
912
|
+
function orMonthScope(ir, opts) {
|
|
913
|
+
if (ir.pattern.month === "*") {
|
|
914
|
+
return "";
|
|
884
915
|
}
|
|
885
|
-
return "
|
|
916
|
+
return ", in " + monthName(ir, opts);
|
|
886
917
|
}
|
|
887
918
|
function quartzDatePhrase(dateField, opts) {
|
|
888
919
|
if (dateField === "L") {
|
|
@@ -964,7 +995,8 @@ function oddEvenMonth(monthField) {
|
|
|
964
995
|
return start === "2" ? "every even-numbered month" : null;
|
|
965
996
|
}
|
|
966
997
|
function weekdayPhrase(ir, opts) {
|
|
967
|
-
|
|
998
|
+
const segments = orderWeekdaysForDisplay(ir.analyses.segments.weekday);
|
|
999
|
+
return renderSegments(segments, function name(value) {
|
|
968
1000
|
return getWeekday(value, opts);
|
|
969
1001
|
}, opts);
|
|
970
1002
|
}
|
package/dist/lang/en.js
CHANGED
|
@@ -14,6 +14,26 @@ function arithmeticStep(values) {
|
|
|
14
14
|
}
|
|
15
15
|
return { start: values[0], interval, last: values[values.length - 1] };
|
|
16
16
|
}
|
|
17
|
+
function weekdayDisplayKey(value) {
|
|
18
|
+
return value === 0 ? 7 : value;
|
|
19
|
+
}
|
|
20
|
+
function orderWeekdaysForDisplay(segments) {
|
|
21
|
+
const flattened = segments.flatMap(function flat(segment) {
|
|
22
|
+
return segment.kind === "step" ? segment.fires.map(function single(value) {
|
|
23
|
+
return { kind: "single", value: "" + value };
|
|
24
|
+
}) : [segment];
|
|
25
|
+
});
|
|
26
|
+
function key(segment) {
|
|
27
|
+
return segment.kind === "range" ? weekdayDisplayKey(+segment.bounds[0]) : weekdayDisplayKey(+segment.value);
|
|
28
|
+
}
|
|
29
|
+
return flattened.map(function index(segment, position) {
|
|
30
|
+
return [segment, position];
|
|
31
|
+
}).sort(function byDisplayKey(a, b) {
|
|
32
|
+
return key(a[0]) - key(b[0]) || a[1] - b[1];
|
|
33
|
+
}).map(function unwrap(pair) {
|
|
34
|
+
return pair[0];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
17
37
|
|
|
18
38
|
// src/core/specs.ts
|
|
19
39
|
var maxClockTimes = 6;
|
|
@@ -391,7 +411,8 @@ function renderHourStep(ir, plan, opts) {
|
|
|
391
411
|
return stepHours(ir.analyses.segments.hour[0], opts) + trailingQualifier(ir, opts);
|
|
392
412
|
}
|
|
393
413
|
function boundedWindow(plan) {
|
|
394
|
-
|
|
414
|
+
const last = plan.minuteForm === "wildcard" ? plan.boundMinute ?? 0 : 0;
|
|
415
|
+
return { from: plan.from, last, to: plan.to };
|
|
395
416
|
}
|
|
396
417
|
function hourWindow(window, opts) {
|
|
397
418
|
return "from " + getTime({ hour: window.from, minute: 0 }, opts) + through(opts) + getTime({ hour: window.to, minute: window.last }, opts);
|
|
@@ -846,17 +867,27 @@ function monthFoldsIntoDate(ir) {
|
|
|
846
867
|
function dateOrWeekday(ir, opts) {
|
|
847
868
|
const pattern = ir.pattern;
|
|
848
869
|
const weekdayPart = quartzWeekdayPhrase(pattern.weekday, opts) || "on " + weekdayPhrase(ir, opts);
|
|
870
|
+
if (pattern.month !== "*" && monthFoldsIntoDate(ir) && !quartzDatePhrase(pattern.date, opts) && !isOpenStep(pattern.date)) {
|
|
871
|
+
return "on " + monthDatePhrase(ir, opts) + " or " + weekdayPart + " in " + monthName(ir, opts);
|
|
872
|
+
}
|
|
873
|
+
return datePart(ir, opts) + " or " + weekdayPart + orMonthScope(ir, opts);
|
|
874
|
+
}
|
|
875
|
+
function datePart(ir, opts) {
|
|
876
|
+
const pattern = ir.pattern;
|
|
849
877
|
const quartzDate = quartzDatePhrase(pattern.date, opts);
|
|
850
878
|
if (quartzDate) {
|
|
851
|
-
return quartzDate
|
|
879
|
+
return quartzDate;
|
|
852
880
|
}
|
|
853
881
|
if (isOpenStep(pattern.date)) {
|
|
854
|
-
return stepDates(pattern.date)
|
|
882
|
+
return stepDates(pattern.date);
|
|
855
883
|
}
|
|
856
|
-
|
|
857
|
-
|
|
884
|
+
return "on the " + dateOrdinals(ir, opts);
|
|
885
|
+
}
|
|
886
|
+
function orMonthScope(ir, opts) {
|
|
887
|
+
if (ir.pattern.month === "*") {
|
|
888
|
+
return "";
|
|
858
889
|
}
|
|
859
|
-
return "
|
|
890
|
+
return ", in " + monthName(ir, opts);
|
|
860
891
|
}
|
|
861
892
|
function quartzDatePhrase(dateField, opts) {
|
|
862
893
|
if (dateField === "L") {
|
|
@@ -938,7 +969,8 @@ function oddEvenMonth(monthField) {
|
|
|
938
969
|
return start === "2" ? "every even-numbered month" : null;
|
|
939
970
|
}
|
|
940
971
|
function weekdayPhrase(ir, opts) {
|
|
941
|
-
|
|
972
|
+
const segments = orderWeekdaysForDisplay(ir.analyses.segments.weekday);
|
|
973
|
+
return renderSegments(segments, function name(value) {
|
|
942
974
|
return getWeekday(value, opts);
|
|
943
975
|
}, opts);
|
|
944
976
|
}
|
package/dist/lang/es.cjs
CHANGED
|
@@ -72,6 +72,26 @@ function arithmeticStep(values) {
|
|
|
72
72
|
}
|
|
73
73
|
return { start: values[0], interval, last: values[values.length - 1] };
|
|
74
74
|
}
|
|
75
|
+
function weekdayDisplayKey(value) {
|
|
76
|
+
return value === 0 ? 7 : value;
|
|
77
|
+
}
|
|
78
|
+
function orderWeekdaysForDisplay(segments) {
|
|
79
|
+
const flattened = segments.flatMap(function flat(segment) {
|
|
80
|
+
return segment.kind === "step" ? segment.fires.map(function single(value) {
|
|
81
|
+
return { kind: "single", value: "" + value };
|
|
82
|
+
}) : [segment];
|
|
83
|
+
});
|
|
84
|
+
function key(segment) {
|
|
85
|
+
return segment.kind === "range" ? weekdayDisplayKey(+segment.bounds[0]) : weekdayDisplayKey(+segment.value);
|
|
86
|
+
}
|
|
87
|
+
return flattened.map(function index(segment, position) {
|
|
88
|
+
return [segment, position];
|
|
89
|
+
}).sort(function byDisplayKey(a, b) {
|
|
90
|
+
return key(a[0]) - key(b[0]) || a[1] - b[1];
|
|
91
|
+
}).map(function unwrap(pair) {
|
|
92
|
+
return pair[0];
|
|
93
|
+
});
|
|
94
|
+
}
|
|
75
95
|
function toFieldNumber(token, numberMap) {
|
|
76
96
|
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
77
97
|
}
|
|
@@ -224,7 +244,7 @@ function renderComposeSeconds(ir, plan, opts) {
|
|
|
224
244
|
}
|
|
225
245
|
if (plan.rest.kind === "hourRange" && ir.shapes.second === "step" && ir.pattern.weekday !== "*") {
|
|
226
246
|
const restNode = plan.rest;
|
|
227
|
-
const window = hourWindow(restNode, opts);
|
|
247
|
+
const window = hourWindow(boundedWindow(restNode), opts);
|
|
228
248
|
const dayFrame = weekdayQualifier(ir) + monthScope(ir);
|
|
229
249
|
const cadence = "cada " + numero(stepSegment(ir.analyses.segments.second).interval, opts) + " segundos del minuto " + ir.pattern.minute;
|
|
230
250
|
return dayFrame + ", " + window + ", " + cadence;
|
|
@@ -437,7 +457,8 @@ function renderHourStep(ir, plan, opts) {
|
|
|
437
457
|
return stepHours(stepSegment(ir.analyses.segments.hour), opts) + trailingQualifier(ir, opts);
|
|
438
458
|
}
|
|
439
459
|
function boundedWindow(plan) {
|
|
440
|
-
|
|
460
|
+
const last = plan.minuteForm === "wildcard" ? plan.boundMinute ?? 0 : 0;
|
|
461
|
+
return { from: plan.from, last, to: plan.to };
|
|
441
462
|
}
|
|
442
463
|
function hourWindow(window, opts) {
|
|
443
464
|
return timeRange(
|
|
@@ -481,7 +502,7 @@ function dowArm(ir) {
|
|
|
481
502
|
if (quartz) {
|
|
482
503
|
return quartz;
|
|
483
504
|
}
|
|
484
|
-
const segments =
|
|
505
|
+
const segments = orderWeekdaysForDisplay(fieldSegments(ir, "weekday"));
|
|
485
506
|
const allSingles = segments.every(function single(segment) {
|
|
486
507
|
return segment.kind === "single";
|
|
487
508
|
});
|
|
@@ -705,7 +726,7 @@ function renderCompactClockTimes(ir, plan, opts) {
|
|
|
705
726
|
return leadingQualifier(ir, opts) + hourSegmentTimes(ir, plan.minute, ir.analyses.clockSecond, opts);
|
|
706
727
|
}
|
|
707
728
|
const cadence = unevenHourCadence(ir, opts);
|
|
708
|
-
const phrase = cadence ? minutesList(ir, opts) + ", " + cadence + trailingQualifier(ir, opts) : minutesList(ir, opts) + ", " +
|
|
729
|
+
const phrase = cadence ? minutesList(ir, opts) + ", " + cadence + trailingQualifier(ir, opts) : minutesList(ir, opts) + ", " + hourContextTimes(ir, opts) + trailingQualifier(ir, opts);
|
|
709
730
|
return ir.analyses.clockSecond ? secondsLeadClause(ir, opts) + ", " + phrase : phrase;
|
|
710
731
|
}
|
|
711
732
|
var renderers = {
|
|
@@ -896,6 +917,48 @@ function hourRangeCadence(ir, minute, opts) {
|
|
|
896
917
|
}
|
|
897
918
|
return hourCadenceLead(ir, minute, opts) + ", " + hourSegmentTimes(ir, 0, null, opts) + trailingQualifier(ir, opts);
|
|
898
919
|
}
|
|
920
|
+
function hourContextTimes(ir, opts) {
|
|
921
|
+
const segments = hourSegments(ir);
|
|
922
|
+
const points = [];
|
|
923
|
+
const hasRange = segments.some(function range(segment) {
|
|
924
|
+
return segment.kind === "range";
|
|
925
|
+
});
|
|
926
|
+
segments.forEach(function collect(segment) {
|
|
927
|
+
if (segment.kind === "step") {
|
|
928
|
+
points.push(...segment.fires);
|
|
929
|
+
} else if (segment.kind === "single") {
|
|
930
|
+
points.push(+segment.value);
|
|
931
|
+
}
|
|
932
|
+
});
|
|
933
|
+
function isWord(hour) {
|
|
934
|
+
return !opts.ampm && (hour === 0 || hour === 12);
|
|
935
|
+
}
|
|
936
|
+
if (!hasRange && points.every(isWord)) {
|
|
937
|
+
return joinList(points.map(function each(hour) {
|
|
938
|
+
return atTime(bareHourPhrase(hour, opts));
|
|
939
|
+
}));
|
|
940
|
+
}
|
|
941
|
+
function wholeHour(hour) {
|
|
942
|
+
return "de la hora " + fromTime(explicitTimePhrase(hour, 0, opts));
|
|
943
|
+
}
|
|
944
|
+
const pieces = [];
|
|
945
|
+
segments.forEach(function place(segment) {
|
|
946
|
+
if (segment.kind === "range") {
|
|
947
|
+
pieces.push(timeRange(
|
|
948
|
+
{ hour: +segment.bounds[0], minute: 0 },
|
|
949
|
+
{ hour: +segment.bounds[1], minute: 0 },
|
|
950
|
+
opts
|
|
951
|
+
));
|
|
952
|
+
} else if (segment.kind === "step") {
|
|
953
|
+
segment.fires.forEach(function each(hour) {
|
|
954
|
+
pieces.push(wholeHour(hour));
|
|
955
|
+
});
|
|
956
|
+
} else {
|
|
957
|
+
pieces.push(wholeHour(+segment.value));
|
|
958
|
+
}
|
|
959
|
+
});
|
|
960
|
+
return joinList(pieces);
|
|
961
|
+
}
|
|
899
962
|
function atTimes(hours, opts) {
|
|
900
963
|
return hours.map(function each(hour) {
|
|
901
964
|
return atTime(timePhrase(hour, 0, null, opts));
|
|
@@ -1158,7 +1221,7 @@ function weekdayQualifier(ir) {
|
|
|
1158
1221
|
if (quartz) {
|
|
1159
1222
|
return quartz;
|
|
1160
1223
|
}
|
|
1161
|
-
const segments =
|
|
1224
|
+
const segments = orderWeekdaysForDisplay(fieldSegments(ir, "weekday"));
|
|
1162
1225
|
const allSingles = segments.every(function single(segment) {
|
|
1163
1226
|
return segment.kind === "single";
|
|
1164
1227
|
});
|
package/dist/lang/es.js
CHANGED
|
@@ -46,6 +46,26 @@ function arithmeticStep(values) {
|
|
|
46
46
|
}
|
|
47
47
|
return { start: values[0], interval, last: values[values.length - 1] };
|
|
48
48
|
}
|
|
49
|
+
function weekdayDisplayKey(value) {
|
|
50
|
+
return value === 0 ? 7 : value;
|
|
51
|
+
}
|
|
52
|
+
function orderWeekdaysForDisplay(segments) {
|
|
53
|
+
const flattened = segments.flatMap(function flat(segment) {
|
|
54
|
+
return segment.kind === "step" ? segment.fires.map(function single(value) {
|
|
55
|
+
return { kind: "single", value: "" + value };
|
|
56
|
+
}) : [segment];
|
|
57
|
+
});
|
|
58
|
+
function key(segment) {
|
|
59
|
+
return segment.kind === "range" ? weekdayDisplayKey(+segment.bounds[0]) : weekdayDisplayKey(+segment.value);
|
|
60
|
+
}
|
|
61
|
+
return flattened.map(function index(segment, position) {
|
|
62
|
+
return [segment, position];
|
|
63
|
+
}).sort(function byDisplayKey(a, b) {
|
|
64
|
+
return key(a[0]) - key(b[0]) || a[1] - b[1];
|
|
65
|
+
}).map(function unwrap(pair) {
|
|
66
|
+
return pair[0];
|
|
67
|
+
});
|
|
68
|
+
}
|
|
49
69
|
function toFieldNumber(token, numberMap) {
|
|
50
70
|
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
51
71
|
}
|
|
@@ -198,7 +218,7 @@ function renderComposeSeconds(ir, plan, opts) {
|
|
|
198
218
|
}
|
|
199
219
|
if (plan.rest.kind === "hourRange" && ir.shapes.second === "step" && ir.pattern.weekday !== "*") {
|
|
200
220
|
const restNode = plan.rest;
|
|
201
|
-
const window = hourWindow(restNode, opts);
|
|
221
|
+
const window = hourWindow(boundedWindow(restNode), opts);
|
|
202
222
|
const dayFrame = weekdayQualifier(ir) + monthScope(ir);
|
|
203
223
|
const cadence = "cada " + numero(stepSegment(ir.analyses.segments.second).interval, opts) + " segundos del minuto " + ir.pattern.minute;
|
|
204
224
|
return dayFrame + ", " + window + ", " + cadence;
|
|
@@ -411,7 +431,8 @@ function renderHourStep(ir, plan, opts) {
|
|
|
411
431
|
return stepHours(stepSegment(ir.analyses.segments.hour), opts) + trailingQualifier(ir, opts);
|
|
412
432
|
}
|
|
413
433
|
function boundedWindow(plan) {
|
|
414
|
-
|
|
434
|
+
const last = plan.minuteForm === "wildcard" ? plan.boundMinute ?? 0 : 0;
|
|
435
|
+
return { from: plan.from, last, to: plan.to };
|
|
415
436
|
}
|
|
416
437
|
function hourWindow(window, opts) {
|
|
417
438
|
return timeRange(
|
|
@@ -455,7 +476,7 @@ function dowArm(ir) {
|
|
|
455
476
|
if (quartz) {
|
|
456
477
|
return quartz;
|
|
457
478
|
}
|
|
458
|
-
const segments =
|
|
479
|
+
const segments = orderWeekdaysForDisplay(fieldSegments(ir, "weekday"));
|
|
459
480
|
const allSingles = segments.every(function single(segment) {
|
|
460
481
|
return segment.kind === "single";
|
|
461
482
|
});
|
|
@@ -679,7 +700,7 @@ function renderCompactClockTimes(ir, plan, opts) {
|
|
|
679
700
|
return leadingQualifier(ir, opts) + hourSegmentTimes(ir, plan.minute, ir.analyses.clockSecond, opts);
|
|
680
701
|
}
|
|
681
702
|
const cadence = unevenHourCadence(ir, opts);
|
|
682
|
-
const phrase = cadence ? minutesList(ir, opts) + ", " + cadence + trailingQualifier(ir, opts) : minutesList(ir, opts) + ", " +
|
|
703
|
+
const phrase = cadence ? minutesList(ir, opts) + ", " + cadence + trailingQualifier(ir, opts) : minutesList(ir, opts) + ", " + hourContextTimes(ir, opts) + trailingQualifier(ir, opts);
|
|
683
704
|
return ir.analyses.clockSecond ? secondsLeadClause(ir, opts) + ", " + phrase : phrase;
|
|
684
705
|
}
|
|
685
706
|
var renderers = {
|
|
@@ -870,6 +891,48 @@ function hourRangeCadence(ir, minute, opts) {
|
|
|
870
891
|
}
|
|
871
892
|
return hourCadenceLead(ir, minute, opts) + ", " + hourSegmentTimes(ir, 0, null, opts) + trailingQualifier(ir, opts);
|
|
872
893
|
}
|
|
894
|
+
function hourContextTimes(ir, opts) {
|
|
895
|
+
const segments = hourSegments(ir);
|
|
896
|
+
const points = [];
|
|
897
|
+
const hasRange = segments.some(function range(segment) {
|
|
898
|
+
return segment.kind === "range";
|
|
899
|
+
});
|
|
900
|
+
segments.forEach(function collect(segment) {
|
|
901
|
+
if (segment.kind === "step") {
|
|
902
|
+
points.push(...segment.fires);
|
|
903
|
+
} else if (segment.kind === "single") {
|
|
904
|
+
points.push(+segment.value);
|
|
905
|
+
}
|
|
906
|
+
});
|
|
907
|
+
function isWord(hour) {
|
|
908
|
+
return !opts.ampm && (hour === 0 || hour === 12);
|
|
909
|
+
}
|
|
910
|
+
if (!hasRange && points.every(isWord)) {
|
|
911
|
+
return joinList(points.map(function each(hour) {
|
|
912
|
+
return atTime(bareHourPhrase(hour, opts));
|
|
913
|
+
}));
|
|
914
|
+
}
|
|
915
|
+
function wholeHour(hour) {
|
|
916
|
+
return "de la hora " + fromTime(explicitTimePhrase(hour, 0, opts));
|
|
917
|
+
}
|
|
918
|
+
const pieces = [];
|
|
919
|
+
segments.forEach(function place(segment) {
|
|
920
|
+
if (segment.kind === "range") {
|
|
921
|
+
pieces.push(timeRange(
|
|
922
|
+
{ hour: +segment.bounds[0], minute: 0 },
|
|
923
|
+
{ hour: +segment.bounds[1], minute: 0 },
|
|
924
|
+
opts
|
|
925
|
+
));
|
|
926
|
+
} else if (segment.kind === "step") {
|
|
927
|
+
segment.fires.forEach(function each(hour) {
|
|
928
|
+
pieces.push(wholeHour(hour));
|
|
929
|
+
});
|
|
930
|
+
} else {
|
|
931
|
+
pieces.push(wholeHour(+segment.value));
|
|
932
|
+
}
|
|
933
|
+
});
|
|
934
|
+
return joinList(pieces);
|
|
935
|
+
}
|
|
873
936
|
function atTimes(hours, opts) {
|
|
874
937
|
return hours.map(function each(hour) {
|
|
875
938
|
return atTime(timePhrase(hour, 0, null, opts));
|
|
@@ -1132,7 +1195,7 @@ function weekdayQualifier(ir) {
|
|
|
1132
1195
|
if (quartz) {
|
|
1133
1196
|
return quartz;
|
|
1134
1197
|
}
|
|
1135
|
-
const segments =
|
|
1198
|
+
const segments = orderWeekdaysForDisplay(fieldSegments(ir, "weekday"));
|
|
1136
1199
|
const allSingles = segments.every(function single(segment) {
|
|
1137
1200
|
return segment.kind === "single";
|
|
1138
1201
|
});
|
package/dist/lang/fi.cjs
CHANGED
|
@@ -72,6 +72,26 @@ function arithmeticStep(values) {
|
|
|
72
72
|
}
|
|
73
73
|
return { start: values[0], interval, last: values[values.length - 1] };
|
|
74
74
|
}
|
|
75
|
+
function weekdayDisplayKey(value) {
|
|
76
|
+
return value === 0 ? 7 : value;
|
|
77
|
+
}
|
|
78
|
+
function orderWeekdaysForDisplay(segments) {
|
|
79
|
+
const flattened = segments.flatMap(function flat(segment) {
|
|
80
|
+
return segment.kind === "step" ? segment.fires.map(function single(value) {
|
|
81
|
+
return { kind: "single", value: "" + value };
|
|
82
|
+
}) : [segment];
|
|
83
|
+
});
|
|
84
|
+
function key(segment) {
|
|
85
|
+
return segment.kind === "range" ? weekdayDisplayKey(+segment.bounds[0]) : weekdayDisplayKey(+segment.value);
|
|
86
|
+
}
|
|
87
|
+
return flattened.map(function index(segment, position) {
|
|
88
|
+
return [segment, position];
|
|
89
|
+
}).sort(function byDisplayKey(a, b) {
|
|
90
|
+
return key(a[0]) - key(b[0]) || a[1] - b[1];
|
|
91
|
+
}).map(function unwrap(pair) {
|
|
92
|
+
return pair[0];
|
|
93
|
+
});
|
|
94
|
+
}
|
|
75
95
|
function toFieldNumber(token, numberMap) {
|
|
76
96
|
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
77
97
|
}
|
|
@@ -965,7 +985,7 @@ function weekdayQualifier(ir) {
|
|
|
965
985
|
if (quartz) {
|
|
966
986
|
return quartz;
|
|
967
987
|
}
|
|
968
|
-
const segments =
|
|
988
|
+
const segments = orderWeekdaysForDisplay(ir.analyses.segments.weekday);
|
|
969
989
|
return joinList(segments.map(function piece(segment) {
|
|
970
990
|
if (segment.kind === "range") {
|
|
971
991
|
return weekdays[weekdayNumber(segment.bounds[0])].ela + " " + weekdays[weekdayNumber(segment.bounds[1])].ill;
|
package/dist/lang/fi.js
CHANGED
|
@@ -46,6 +46,26 @@ function arithmeticStep(values) {
|
|
|
46
46
|
}
|
|
47
47
|
return { start: values[0], interval, last: values[values.length - 1] };
|
|
48
48
|
}
|
|
49
|
+
function weekdayDisplayKey(value) {
|
|
50
|
+
return value === 0 ? 7 : value;
|
|
51
|
+
}
|
|
52
|
+
function orderWeekdaysForDisplay(segments) {
|
|
53
|
+
const flattened = segments.flatMap(function flat(segment) {
|
|
54
|
+
return segment.kind === "step" ? segment.fires.map(function single(value) {
|
|
55
|
+
return { kind: "single", value: "" + value };
|
|
56
|
+
}) : [segment];
|
|
57
|
+
});
|
|
58
|
+
function key(segment) {
|
|
59
|
+
return segment.kind === "range" ? weekdayDisplayKey(+segment.bounds[0]) : weekdayDisplayKey(+segment.value);
|
|
60
|
+
}
|
|
61
|
+
return flattened.map(function index(segment, position) {
|
|
62
|
+
return [segment, position];
|
|
63
|
+
}).sort(function byDisplayKey(a, b) {
|
|
64
|
+
return key(a[0]) - key(b[0]) || a[1] - b[1];
|
|
65
|
+
}).map(function unwrap(pair) {
|
|
66
|
+
return pair[0];
|
|
67
|
+
});
|
|
68
|
+
}
|
|
49
69
|
function toFieldNumber(token, numberMap) {
|
|
50
70
|
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
51
71
|
}
|
|
@@ -939,7 +959,7 @@ function weekdayQualifier(ir) {
|
|
|
939
959
|
if (quartz) {
|
|
940
960
|
return quartz;
|
|
941
961
|
}
|
|
942
|
-
const segments =
|
|
962
|
+
const segments = orderWeekdaysForDisplay(ir.analyses.segments.weekday);
|
|
943
963
|
return joinList(segments.map(function piece(segment) {
|
|
944
964
|
if (segment.kind === "range") {
|
|
945
965
|
return weekdays[weekdayNumber(segment.bounds[0])].ela + " " + weekdays[weekdayNumber(segment.bounds[1])].ill;
|