cronli5 0.1.2 → 0.1.5
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 +89 -0
- package/cli.js +9 -0
- package/cronli5.min.js +2 -2
- package/dist/cronli5.cjs +280 -64
- package/dist/cronli5.js +280 -64
- package/dist/lang/de.cjs +227 -42
- package/dist/lang/de.js +227 -42
- package/dist/lang/en.cjs +216 -50
- package/dist/lang/en.js +216 -50
- package/dist/lang/es.cjs +259 -54
- package/dist/lang/es.js +259 -54
- package/dist/lang/fi.cjs +230 -69
- package/dist/lang/fi.js +230 -69
- package/dist/lang/zh.cjs +190 -19
- package/dist/lang/zh.js +190 -19
- package/package.json +3 -1
- package/src/core/analyze.ts +7 -0
- package/src/core/ir.ts +1 -1
- package/src/core/normalize.ts +94 -4
- package/src/core/util.ts +31 -1
- package/src/lang/de/index.ts +449 -46
- package/src/lang/en/index.ts +433 -63
- package/src/lang/es/index.ts +505 -63
- package/src/lang/fi/index.ts +455 -89
- package/src/lang/zh/index.ts +393 -30
- package/types/core/ir.d.ts +1 -1
- package/types/core/util.d.ts +6 -1
package/dist/lang/es.js
CHANGED
|
@@ -14,6 +14,42 @@ function clockDigits(time, { sep, pad: padHour, lean }) {
|
|
|
14
14
|
return head + sep + pad(time.minute) + (time.second ? sep + pad(time.second) : "");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
// src/core/specs.ts
|
|
18
|
+
var weekdayNumbers = {
|
|
19
|
+
SUN: 0,
|
|
20
|
+
MON: 1,
|
|
21
|
+
TUE: 2,
|
|
22
|
+
WED: 3,
|
|
23
|
+
THU: 4,
|
|
24
|
+
FRI: 5,
|
|
25
|
+
SAT: 6
|
|
26
|
+
};
|
|
27
|
+
var maxClockTimes = 6;
|
|
28
|
+
|
|
29
|
+
// src/core/util.ts
|
|
30
|
+
function isNonNegativeInteger(value) {
|
|
31
|
+
const digits = /^\d+$/;
|
|
32
|
+
return digits.test(value);
|
|
33
|
+
}
|
|
34
|
+
function arithmeticStep(values) {
|
|
35
|
+
if (values.length < 5) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
const interval = values[1] - values[0];
|
|
39
|
+
if (interval < 2) {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
for (let i = 2; i < values.length; i += 1) {
|
|
43
|
+
if (values[i] - values[i - 1] !== interval) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return { start: values[0], interval, last: values[values.length - 1] };
|
|
48
|
+
}
|
|
49
|
+
function toFieldNumber(token, numberMap) {
|
|
50
|
+
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
51
|
+
}
|
|
52
|
+
|
|
17
53
|
// src/lang/es/dialects.ts
|
|
18
54
|
var es = {
|
|
19
55
|
ampm: false,
|
|
@@ -85,29 +121,6 @@ var weekdayNames = [
|
|
|
85
121
|
"viernes",
|
|
86
122
|
"s\xE1bado"
|
|
87
123
|
];
|
|
88
|
-
var monthTokens = {
|
|
89
|
-
JAN: 1,
|
|
90
|
-
FEB: 2,
|
|
91
|
-
MAR: 3,
|
|
92
|
-
APR: 4,
|
|
93
|
-
MAY: 5,
|
|
94
|
-
JUN: 6,
|
|
95
|
-
JUL: 7,
|
|
96
|
-
AUG: 8,
|
|
97
|
-
SEP: 9,
|
|
98
|
-
OCT: 10,
|
|
99
|
-
NOV: 11,
|
|
100
|
-
DEC: 12
|
|
101
|
-
};
|
|
102
|
-
var weekdayTokens = {
|
|
103
|
-
SUN: 0,
|
|
104
|
-
MON: 1,
|
|
105
|
-
TUE: 2,
|
|
106
|
-
WED: 3,
|
|
107
|
-
THU: 4,
|
|
108
|
-
FRI: 5,
|
|
109
|
-
SAT: 6
|
|
110
|
-
};
|
|
111
124
|
var nthWeekdayNames = [null, "primer", "segundo", "tercer", "cuarto", "quinto"];
|
|
112
125
|
function normalizeOptions(options) {
|
|
113
126
|
options = options || {};
|
|
@@ -150,16 +163,31 @@ function renderSecondsWithinMinute(ir, plan, opts) {
|
|
|
150
163
|
}
|
|
151
164
|
return secondsLeadClause(ir, opts) + ", en el minuto " + minuteField + " de cada hora" + trailingQualifier(ir, opts);
|
|
152
165
|
}
|
|
166
|
+
function secondsListAtClock(ir, rest, opts) {
|
|
167
|
+
const clockPhrases = rest.times.map(function clock(time) {
|
|
168
|
+
return atTime(timePhrase(time.hour, time.minute, null, opts));
|
|
169
|
+
});
|
|
170
|
+
const grouped = groupClockTimesByArticle(clockPhrases);
|
|
171
|
+
const clockList = grouped.startsWith("a ") ? grouped.slice(2) : grouped;
|
|
172
|
+
const stride = strideFromSegments(fieldSegments(ir, "second"), "segundo", "", opts);
|
|
173
|
+
const secondsPhrase = stride ?? "en los segundos " + joinList(segmentWords(fieldSegments(ir, "second")));
|
|
174
|
+
const dayFrame = trailingQualifier(ir, opts);
|
|
175
|
+
return (dayFrame ? dayFrame.trimStart() + ", " : "") + secondsPhrase + " de " + clockList;
|
|
176
|
+
}
|
|
177
|
+
function composeHourCadence(ir, plan, opts) {
|
|
178
|
+
const clockRest = plan.rest.kind === "clockTimes" || plan.rest.kind === "compactClockTimes";
|
|
179
|
+
return clockRest && ir.shapes.minute === "single" ? hourCadence(ir, +ir.pattern.minute, opts) : null;
|
|
180
|
+
}
|
|
153
181
|
function renderComposeSeconds(ir, plan, opts) {
|
|
182
|
+
const hourCad = composeHourCadence(ir, plan, opts);
|
|
183
|
+
if (hourCad !== null) {
|
|
184
|
+
return hourCad;
|
|
185
|
+
}
|
|
186
|
+
if (plan.rest.kind === "clockTimes" && (ir.shapes.second === "wildcard" || ir.shapes.second === "step")) {
|
|
187
|
+
return pinnedMinuteSeconds(ir, plan.rest, opts);
|
|
188
|
+
}
|
|
154
189
|
if (plan.rest.kind === "clockTimes" && ir.shapes.second === "list") {
|
|
155
|
-
|
|
156
|
-
return atTime(timePhrase(time.hour, time.minute, null, opts));
|
|
157
|
-
});
|
|
158
|
-
const grouped = groupClockTimesByArticle(clockPhrases);
|
|
159
|
-
const clockList = grouped.startsWith("a ") ? grouped.slice(2) : grouped;
|
|
160
|
-
const secondsPhrase = "en los segundos " + joinList(segmentWords(fieldSegments(ir, "second")));
|
|
161
|
-
const dayFrame = trailingQualifier(ir, opts);
|
|
162
|
-
return (dayFrame ? dayFrame.trimStart() + ", " : "") + secondsPhrase + " de " + clockList;
|
|
190
|
+
return secondsListAtClock(ir, plan.rest, opts);
|
|
163
191
|
}
|
|
164
192
|
if (plan.rest.kind === "hourRange" && ir.shapes.second === "step" && ir.pattern.weekday !== "*") {
|
|
165
193
|
const restNode = plan.rest;
|
|
@@ -168,9 +196,30 @@ function renderComposeSeconds(ir, plan, opts) {
|
|
|
168
196
|
const cadence = "cada " + numero(stepSegment(ir.analyses.segments.second).interval, opts) + " segundos del minuto " + ir.pattern.minute;
|
|
169
197
|
return dayFrame + ", " + window + ", " + cadence;
|
|
170
198
|
}
|
|
199
|
+
if (isEveryOtherMinuteSeconds(ir, plan)) {
|
|
200
|
+
return secondsLeadClause(ir, opts) + " de " + render(ir, plan.rest, opts);
|
|
201
|
+
}
|
|
171
202
|
return secondsLeadClause(ir, opts) + ", " + render(ir, plan.rest, opts);
|
|
172
203
|
}
|
|
204
|
+
function isEveryOtherMinuteSeconds(ir, plan) {
|
|
205
|
+
if (plan.rest.kind !== "minuteFrequency" || ir.shapes.second !== "wildcard" || ir.shapes.hour !== "wildcard") {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
const minuteStep = stepSegment(ir.analyses.segments.minute);
|
|
209
|
+
return minuteStep.startToken === "*" && minuteStep.interval === 2;
|
|
210
|
+
}
|
|
211
|
+
function pinnedMinuteSeconds(ir, rest, opts) {
|
|
212
|
+
const dayTrail = leadingQualifier(ir, opts).trimEnd();
|
|
213
|
+
const trail = dayTrail ? ", " + dayTrail : "";
|
|
214
|
+
if (+rest.times[0].minute === 0) {
|
|
215
|
+
return secondsLeadClause(ir, opts) + " durante un minuto " + durationHourList(rest.times, opts) + trail;
|
|
216
|
+
}
|
|
217
|
+
return secondsLeadClause(ir, opts) + " de " + explicitClockList(rest.times, opts) + trail;
|
|
218
|
+
}
|
|
173
219
|
function secondsLeadClause(ir, opts) {
|
|
220
|
+
return secondsClause(ir, "minuto", opts);
|
|
221
|
+
}
|
|
222
|
+
function secondsClause(ir, anchor, opts) {
|
|
174
223
|
const secondField = ir.pattern.second;
|
|
175
224
|
const shape = ir.shapes.second;
|
|
176
225
|
if (secondField === "*") {
|
|
@@ -180,18 +229,23 @@ function secondsLeadClause(ir, opts) {
|
|
|
180
229
|
return stepCycle60(
|
|
181
230
|
stepSegment(ir.analyses.segments.second),
|
|
182
231
|
"segundo",
|
|
183
|
-
|
|
232
|
+
anchor,
|
|
184
233
|
opts
|
|
185
234
|
);
|
|
186
235
|
}
|
|
187
236
|
if (shape === "range") {
|
|
188
237
|
const bounds = secondField.split("-");
|
|
189
|
-
return "cada segundo del " + bounds[0] + " al " + bounds[1] + " de cada
|
|
238
|
+
return "cada segundo del " + bounds[0] + " al " + bounds[1] + " de cada " + anchor;
|
|
190
239
|
}
|
|
191
240
|
if (shape === "single") {
|
|
192
|
-
return "en el segundo " + secondField + " de cada
|
|
241
|
+
return "en el segundo " + secondField + " de cada " + anchor;
|
|
193
242
|
}
|
|
194
|
-
return
|
|
243
|
+
return strideFromSegments(
|
|
244
|
+
fieldSegments(ir, "second"),
|
|
245
|
+
"segundo",
|
|
246
|
+
anchor,
|
|
247
|
+
opts
|
|
248
|
+
) ?? "en los segundos " + joinList(segmentWords(fieldSegments(ir, "second"))) + " de cada " + anchor;
|
|
195
249
|
}
|
|
196
250
|
function renderEveryMinute(ir, plan, opts) {
|
|
197
251
|
return "cada minuto" + trailingQualifier(ir, opts);
|
|
@@ -203,10 +257,15 @@ function renderRangeOfMinutes(ir, plan, opts) {
|
|
|
203
257
|
return minuteRangeLead(ir.pattern.minute) + " de cada hora" + trailingQualifier(ir, opts);
|
|
204
258
|
}
|
|
205
259
|
function renderMultipleMinutes(ir, plan, opts) {
|
|
206
|
-
return minutesList(ir) + trailingQualifier(ir, opts);
|
|
260
|
+
return minutesList(ir, opts) + trailingQualifier(ir, opts);
|
|
207
261
|
}
|
|
208
|
-
function minutesList(ir) {
|
|
209
|
-
return
|
|
262
|
+
function minutesList(ir, opts) {
|
|
263
|
+
return strideFromSegments(
|
|
264
|
+
fieldSegments(ir, "minute"),
|
|
265
|
+
"minuto",
|
|
266
|
+
"hora",
|
|
267
|
+
opts
|
|
268
|
+
) ?? "en los minutos " + joinList(segmentWords(fieldSegments(ir, "minute"))) + " de cada hora";
|
|
210
269
|
}
|
|
211
270
|
function minuteRangeLead(minuteField) {
|
|
212
271
|
const bounds = minuteField.split("-");
|
|
@@ -278,6 +337,9 @@ function renderMinuteFrequency(ir, plan, opts) {
|
|
|
278
337
|
return phrase + trailingQualifier(ir, opts);
|
|
279
338
|
}
|
|
280
339
|
function renderMinuteSpanInHour(ir, plan, opts) {
|
|
340
|
+
if (ir.pattern.minute === "*") {
|
|
341
|
+
return "cada minuto de la hora " + fromTime(timePhrase(plan.hour, 0, null, opts)) + trailingQualifier(ir, opts);
|
|
342
|
+
}
|
|
281
343
|
return "cada minuto " + timeRange(
|
|
282
344
|
{ hour: plan.hour, minute: plan.span[0] },
|
|
283
345
|
{ hour: plan.hour, minute: plan.span[1] },
|
|
@@ -291,7 +353,7 @@ function renderMinutesAcrossHours(ir, plan, opts) {
|
|
|
291
353
|
}
|
|
292
354
|
return "cada minuto " + hourSpanFromTimes(ir, plan.times, opts) + trailingQualifier(ir, opts);
|
|
293
355
|
}
|
|
294
|
-
const lead = plan.form === "range" ? minuteRangeLead(ir.pattern.minute) : minutesList(ir);
|
|
356
|
+
const lead = plan.form === "range" ? minuteRangeLead(ir.pattern.minute) : minutesList(ir, opts);
|
|
295
357
|
return lead + ", " + atHourTimes(ir, plan.times, opts) + trailingQualifier(ir, opts);
|
|
296
358
|
}
|
|
297
359
|
function renderMinuteSpanAcrossHourStep(ir, plan, opts) {
|
|
@@ -299,7 +361,8 @@ function renderMinuteSpanAcrossHourStep(ir, plan, opts) {
|
|
|
299
361
|
if (plan.form === "wildcard") {
|
|
300
362
|
return "cada minuto, " + stepHourSpan(segment, opts) + trailingQualifier(ir, opts);
|
|
301
363
|
}
|
|
302
|
-
|
|
364
|
+
const lead = plan.form === "list" ? minutesList(ir, opts) : minuteRangeLead(ir.pattern.minute);
|
|
365
|
+
return lead + ", " + stepHours(segment, opts) + trailingQualifier(ir, opts);
|
|
303
366
|
}
|
|
304
367
|
function renderEveryHour(ir, plan, opts) {
|
|
305
368
|
return "cada hora" + trailingQualifier(ir, opts);
|
|
@@ -315,7 +378,7 @@ function renderHourRange(ir, plan, opts) {
|
|
|
315
378
|
if (ir.pattern.minute === "0") {
|
|
316
379
|
return "cada hora " + window + trailingQualifier(ir, opts);
|
|
317
380
|
}
|
|
318
|
-
const lead = ir.shapes.minute === "single" ? "en el minuto " + ir.pattern.minute + " de cada hora" : minutesList(ir);
|
|
381
|
+
const lead = ir.shapes.minute === "single" ? "en el minuto " + ir.pattern.minute + " de cada hora" : minutesList(ir, opts);
|
|
319
382
|
return lead + ", " + window + trailingQualifier(ir, opts);
|
|
320
383
|
}
|
|
321
384
|
function renderHourStep(ir, plan, opts) {
|
|
@@ -389,11 +452,56 @@ function unionYaseaSuffix(ir, opts) {
|
|
|
389
452
|
return ", ya sea " + domArm(ir, opts) + " o " + dowArm(ir);
|
|
390
453
|
}
|
|
391
454
|
function renderClockTimes(ir, plan, opts) {
|
|
455
|
+
if (ir.shapes.minute === "single") {
|
|
456
|
+
const cadence = hourCadence(ir, +ir.pattern.minute, opts);
|
|
457
|
+
if (cadence !== null) {
|
|
458
|
+
return cadence;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
392
461
|
const phrases = plan.times.map(function clock(time) {
|
|
393
462
|
return atTime(timePhrase(time.hour, time.minute, time.second, opts));
|
|
394
463
|
});
|
|
395
464
|
return leadingQualifier(ir, opts) + groupClockTimes(phrases);
|
|
396
465
|
}
|
|
466
|
+
function explicitClockList(times, opts) {
|
|
467
|
+
const phrases = times.map(function clock(time) {
|
|
468
|
+
return atTime(explicitTimePhrase(time.hour, time.minute, opts));
|
|
469
|
+
});
|
|
470
|
+
const grouped = groupClockTimes(phrases);
|
|
471
|
+
return grouped.startsWith("a ") ? grouped.slice(2) : grouped;
|
|
472
|
+
}
|
|
473
|
+
function durationHourList(times, opts) {
|
|
474
|
+
const phrases = times.map(function clock(time) {
|
|
475
|
+
return atTime(bareHourPhrase(time.hour, opts));
|
|
476
|
+
});
|
|
477
|
+
return groupClockTimes(phrases);
|
|
478
|
+
}
|
|
479
|
+
function bareHourPhrase(hour, opts) {
|
|
480
|
+
if (opts.ampm) {
|
|
481
|
+
return timePhrase(hour, 0, null, opts);
|
|
482
|
+
}
|
|
483
|
+
if (+hour === 0) {
|
|
484
|
+
return "medianoche";
|
|
485
|
+
}
|
|
486
|
+
if (+hour === 12) {
|
|
487
|
+
return "mediod\xEDa";
|
|
488
|
+
}
|
|
489
|
+
return (+hour === 1 ? "la " : "las ") + hour;
|
|
490
|
+
}
|
|
491
|
+
function explicitTimePhrase(hour, minute, opts) {
|
|
492
|
+
if (!opts.ampm) {
|
|
493
|
+
const article = +hour === 1 ? "la " : "las ";
|
|
494
|
+
const suffix = opts.style.hSuffix ? " h" : "";
|
|
495
|
+
return article + clockDigits(
|
|
496
|
+
{ hour, minute, second: 0 },
|
|
497
|
+
{ pad: true, sep: opts.style.sep }
|
|
498
|
+
) + suffix;
|
|
499
|
+
}
|
|
500
|
+
const display = hour % 12 || 12;
|
|
501
|
+
const time = (display === 1 ? "la " : "las ") + clockDigits({ hour: display, minute, second: 0 }, { sep: opts.style.sep });
|
|
502
|
+
const period = opts.style.meridiem === "english" ? meridiemMark(hour) : dayPeriod(hour, opts);
|
|
503
|
+
return time + " " + period;
|
|
504
|
+
}
|
|
397
505
|
function groupClockTimes(phrases) {
|
|
398
506
|
if (phrases.length < 2) {
|
|
399
507
|
return joinList(phrases);
|
|
@@ -531,6 +639,10 @@ function groupClockTimesByArticle(phrases) {
|
|
|
531
639
|
}
|
|
532
640
|
function renderCompactClockTimes(ir, plan, opts) {
|
|
533
641
|
if (plan.fold) {
|
|
642
|
+
const cadence = hourCadence(ir, plan.minute, opts);
|
|
643
|
+
if (cadence !== null) {
|
|
644
|
+
return cadence;
|
|
645
|
+
}
|
|
534
646
|
const ranged = hourSegments(ir).some(function range(segment) {
|
|
535
647
|
return segment.kind === "range";
|
|
536
648
|
});
|
|
@@ -539,7 +651,7 @@ function renderCompactClockTimes(ir, plan, opts) {
|
|
|
539
651
|
}
|
|
540
652
|
return leadingQualifier(ir, opts) + hourSegmentTimes(ir, plan.minute, ir.analyses.clockSecond, opts);
|
|
541
653
|
}
|
|
542
|
-
const phrase = minutesList(ir) + ", " + hourSegmentTimes(ir, 0, null, opts) + trailingQualifier(ir, opts);
|
|
654
|
+
const phrase = minutesList(ir, opts) + ", " + hourSegmentTimes(ir, 0, null, opts) + trailingQualifier(ir, opts);
|
|
543
655
|
return ir.analyses.clockSecond ? secondsLeadClause(ir, opts) + ", " + phrase : phrase;
|
|
544
656
|
}
|
|
545
657
|
var renderers = {
|
|
@@ -562,19 +674,50 @@ var renderers = {
|
|
|
562
674
|
singleMinute: renderSingleMinute,
|
|
563
675
|
standaloneSeconds: renderStandaloneSeconds
|
|
564
676
|
};
|
|
677
|
+
function renderStride(stride, opts) {
|
|
678
|
+
const { interval, start, last, cycle, unit, anchor } = stride;
|
|
679
|
+
const cadence = "cada " + numero(interval, opts) + " " + unit + "s";
|
|
680
|
+
const tiles = cycle % interval === 0;
|
|
681
|
+
if (start === 0 && tiles) {
|
|
682
|
+
return cadence;
|
|
683
|
+
}
|
|
684
|
+
const tail = anchor ? " de cada " + anchor : "";
|
|
685
|
+
if (start < interval && tiles) {
|
|
686
|
+
return cadence + " a partir del " + unit + " " + start + tail;
|
|
687
|
+
}
|
|
688
|
+
return cadence + " del " + unit + " " + start + " al " + last + tail;
|
|
689
|
+
}
|
|
565
690
|
function stepCycle60(segment, unit, anchor, opts) {
|
|
566
691
|
if (segment.startToken.indexOf("-") !== -1) {
|
|
567
692
|
return "en los " + unit + "s " + joinList(wordList(segment.fires)) + " de cada " + anchor;
|
|
568
693
|
}
|
|
569
694
|
const start = segment.startToken === "*" ? 0 : +segment.startToken;
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
695
|
+
if (start !== 0 && segment.fires.length <= 3) {
|
|
696
|
+
return "en los " + unit + "s " + joinList(wordList(segment.fires)) + " de cada " + anchor;
|
|
697
|
+
}
|
|
698
|
+
return renderStride({
|
|
699
|
+
interval: segment.interval,
|
|
700
|
+
start,
|
|
701
|
+
last: segment.fires[segment.fires.length - 1],
|
|
702
|
+
cycle: 60,
|
|
703
|
+
unit,
|
|
704
|
+
anchor
|
|
705
|
+
}, opts);
|
|
706
|
+
}
|
|
707
|
+
function strideFromSegments(segments, unit, anchor, opts) {
|
|
708
|
+
const values = singleValues(segments);
|
|
709
|
+
const step = values && arithmeticStep(values);
|
|
710
|
+
return step ? renderStride({ ...step, cycle: 60, unit, anchor }, opts) : null;
|
|
711
|
+
}
|
|
712
|
+
function singleValues(segments) {
|
|
713
|
+
const values = [];
|
|
714
|
+
for (const segment of segments) {
|
|
715
|
+
if (segment.kind !== "single") {
|
|
716
|
+
return null;
|
|
574
717
|
}
|
|
575
|
-
|
|
718
|
+
values.push(+segment.value);
|
|
576
719
|
}
|
|
577
|
-
return
|
|
720
|
+
return values;
|
|
578
721
|
}
|
|
579
722
|
function stepHours(segment, opts) {
|
|
580
723
|
if (segment.startToken.indexOf("-") !== -1) {
|
|
@@ -590,6 +733,68 @@ function stepHours(segment, opts) {
|
|
|
590
733
|
}
|
|
591
734
|
return "cada " + numero(interval, opts) + " horas a partir de " + timePhrase(start, 0, null, opts);
|
|
592
735
|
}
|
|
736
|
+
function hourStrideCadence(stride, opts) {
|
|
737
|
+
const { start, interval, last } = stride;
|
|
738
|
+
const cadence = "cada " + numero(interval, opts) + " horas";
|
|
739
|
+
const tiles = 24 % interval === 0;
|
|
740
|
+
if (start === 0 && tiles) {
|
|
741
|
+
return cadence;
|
|
742
|
+
}
|
|
743
|
+
if (start < interval && tiles) {
|
|
744
|
+
return cadence + " a partir de " + timePhrase(start, 0, null, opts);
|
|
745
|
+
}
|
|
746
|
+
return cadence + " de " + timePhrase(start, 0, null, opts) + " a " + timePhrase(last, 0, null, opts);
|
|
747
|
+
}
|
|
748
|
+
function hourStride(ir) {
|
|
749
|
+
const segments = fieldSegments(ir, "hour");
|
|
750
|
+
if (segments.length === 1 && segments[0].kind === "step") {
|
|
751
|
+
const segment = segments[0];
|
|
752
|
+
const start = segment.startToken === "*" ? 0 : +segment.startToken.split("-")[0];
|
|
753
|
+
return { interval: segment.interval, last: segment.fires[segment.fires.length - 1], start };
|
|
754
|
+
}
|
|
755
|
+
const values = singleValues(segments);
|
|
756
|
+
const step = values && arithmeticStep(values);
|
|
757
|
+
return step || null;
|
|
758
|
+
}
|
|
759
|
+
function subMinuteSecond(ir) {
|
|
760
|
+
return ir.pattern.second === "*" || ir.shapes.second === "step";
|
|
761
|
+
}
|
|
762
|
+
function hourCadenceLead(ir, minute, opts) {
|
|
763
|
+
if (minute === 0) {
|
|
764
|
+
if (subMinuteSecond(ir)) {
|
|
765
|
+
return secondsClause(ir, "minuto", opts) + " durante un minuto";
|
|
766
|
+
}
|
|
767
|
+
return secondsClause(ir, "hora", opts);
|
|
768
|
+
}
|
|
769
|
+
const minutePhrase = "en el minuto " + minute;
|
|
770
|
+
if (ir.pattern.second === "0") {
|
|
771
|
+
return minutePhrase;
|
|
772
|
+
}
|
|
773
|
+
return secondsClause(ir, "minuto", opts) + ", " + minutePhrase;
|
|
774
|
+
}
|
|
775
|
+
function hourCadence(ir, minute, opts) {
|
|
776
|
+
const stride = hourStride(ir);
|
|
777
|
+
if (!stride) {
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
const fires = (stride.last - stride.start) / stride.interval + 1;
|
|
781
|
+
if (ir.pattern.second === "0" && fires <= maxClockTimes) {
|
|
782
|
+
return null;
|
|
783
|
+
}
|
|
784
|
+
const confinement = minute === 0 && subMinuteSecond(ir) && cleanStrideSegment(ir);
|
|
785
|
+
if (confinement) {
|
|
786
|
+
return secondsClause(ir, "minuto", opts) + " durante un minuto, " + stepHourSpan(confinement, opts) + trailingQualifier(ir, opts);
|
|
787
|
+
}
|
|
788
|
+
return hourCadenceLead(ir, minute, opts) + ", " + hourStrideCadence(stride, opts) + trailingQualifier(ir, opts);
|
|
789
|
+
}
|
|
790
|
+
function cleanStrideSegment(ir) {
|
|
791
|
+
const segments = fieldSegments(ir, "hour");
|
|
792
|
+
const segment = segments.length === 1 && segments[0];
|
|
793
|
+
if (!segment || segment.kind !== "step" || segment.startToken.indexOf("-") !== -1) {
|
|
794
|
+
return null;
|
|
795
|
+
}
|
|
796
|
+
return segment;
|
|
797
|
+
}
|
|
593
798
|
function atTimes(hours, opts) {
|
|
594
799
|
return hours.map(function each(hour) {
|
|
595
800
|
return atTime(timePhrase(hour, 0, null, opts));
|
|
@@ -966,17 +1171,15 @@ function numero(n, opts) {
|
|
|
966
1171
|
return numeral(n, numeros, opts);
|
|
967
1172
|
}
|
|
968
1173
|
function weekdayName(token) {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
}
|
|
972
|
-
return weekdayNames[token] || weekdayNames[weekdayTokens[token]];
|
|
1174
|
+
const number = toFieldNumber("" + token, weekdayNumbers);
|
|
1175
|
+
return weekdayNames[number === 7 ? 0 : number];
|
|
973
1176
|
}
|
|
974
1177
|
function pluralWeekday(token) {
|
|
975
1178
|
const name = weekdayName(token);
|
|
976
1179
|
return name.endsWith("s") ? name : name + "s";
|
|
977
1180
|
}
|
|
978
1181
|
function monthName(token) {
|
|
979
|
-
return monthNames[token]
|
|
1182
|
+
return monthNames[+token];
|
|
980
1183
|
}
|
|
981
1184
|
function isOpenStep(field) {
|
|
982
1185
|
return field.indexOf("/") !== -1 && field.indexOf("-") === -1 && field.indexOf(",") === -1;
|
|
@@ -986,7 +1189,9 @@ var es2 = {
|
|
|
986
1189
|
fallback: "un patr\xF3n cron irreconocible",
|
|
987
1190
|
options: normalizeOptions,
|
|
988
1191
|
reboot: "al arrancar el sistema",
|
|
989
|
-
|
|
1192
|
+
// A description ending in a period already carries it, so closing the
|
|
1193
|
+
// sentence must not double it.
|
|
1194
|
+
sentence: (description) => "Se ejecuta " + description + (description.endsWith(".") ? "" : ".")
|
|
990
1195
|
};
|
|
991
1196
|
var index_default = es2;
|
|
992
1197
|
export {
|