cronli5 0.1.2 → 0.1.4

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/dist/lang/es.cjs CHANGED
@@ -40,6 +40,26 @@ function clockDigits(time, { sep, pad: padHour, lean }) {
40
40
  return head + sep + pad(time.minute) + (time.second ? sep + pad(time.second) : "");
41
41
  }
42
42
 
43
+ // src/core/specs.ts
44
+ var weekdayNumbers = {
45
+ SUN: 0,
46
+ MON: 1,
47
+ TUE: 2,
48
+ WED: 3,
49
+ THU: 4,
50
+ FRI: 5,
51
+ SAT: 6
52
+ };
53
+
54
+ // src/core/util.ts
55
+ function isNonNegativeInteger(value) {
56
+ const digits = /^\d+$/;
57
+ return digits.test(value);
58
+ }
59
+ function toFieldNumber(token, numberMap) {
60
+ return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
61
+ }
62
+
43
63
  // src/lang/es/dialects.ts
44
64
  var es = {
45
65
  ampm: false,
@@ -111,29 +131,6 @@ var weekdayNames = [
111
131
  "viernes",
112
132
  "s\xE1bado"
113
133
  ];
114
- var monthTokens = {
115
- JAN: 1,
116
- FEB: 2,
117
- MAR: 3,
118
- APR: 4,
119
- MAY: 5,
120
- JUN: 6,
121
- JUL: 7,
122
- AUG: 8,
123
- SEP: 9,
124
- OCT: 10,
125
- NOV: 11,
126
- DEC: 12
127
- };
128
- var weekdayTokens = {
129
- SUN: 0,
130
- MON: 1,
131
- TUE: 2,
132
- WED: 3,
133
- THU: 4,
134
- FRI: 5,
135
- SAT: 6
136
- };
137
134
  var nthWeekdayNames = [null, "primer", "segundo", "tercer", "cuarto", "quinto"];
138
135
  function normalizeOptions(options) {
139
136
  options = options || {};
@@ -177,6 +174,9 @@ function renderSecondsWithinMinute(ir, plan, opts) {
177
174
  return secondsLeadClause(ir, opts) + ", en el minuto " + minuteField + " de cada hora" + trailingQualifier(ir, opts);
178
175
  }
179
176
  function renderComposeSeconds(ir, plan, opts) {
177
+ if (plan.rest.kind === "clockTimes" && (ir.shapes.second === "wildcard" || ir.shapes.second === "step")) {
178
+ return pinnedMinuteSeconds(ir, plan.rest, opts);
179
+ }
180
180
  if (plan.rest.kind === "clockTimes" && ir.shapes.second === "list") {
181
181
  const clockPhrases = plan.rest.times.map(function clock(time) {
182
182
  return atTime(timePhrase(time.hour, time.minute, null, opts));
@@ -196,6 +196,14 @@ function renderComposeSeconds(ir, plan, opts) {
196
196
  }
197
197
  return secondsLeadClause(ir, opts) + ", " + render(ir, plan.rest, opts);
198
198
  }
199
+ function pinnedMinuteSeconds(ir, rest, opts) {
200
+ const dayTrail = leadingQualifier(ir, opts).trimEnd();
201
+ const trail = dayTrail ? ", " + dayTrail : "";
202
+ if (+rest.times[0].minute === 0) {
203
+ return secondsLeadClause(ir, opts) + " durante un minuto " + durationHourList(rest.times, opts) + trail;
204
+ }
205
+ return secondsLeadClause(ir, opts) + " de " + explicitClockList(rest.times, opts) + trail;
206
+ }
199
207
  function secondsLeadClause(ir, opts) {
200
208
  const secondField = ir.pattern.second;
201
209
  const shape = ir.shapes.second;
@@ -304,6 +312,9 @@ function renderMinuteFrequency(ir, plan, opts) {
304
312
  return phrase + trailingQualifier(ir, opts);
305
313
  }
306
314
  function renderMinuteSpanInHour(ir, plan, opts) {
315
+ if (ir.pattern.minute === "*") {
316
+ return "cada minuto de la hora " + fromTime(timePhrase(plan.hour, 0, null, opts)) + trailingQualifier(ir, opts);
317
+ }
307
318
  return "cada minuto " + timeRange(
308
319
  { hour: plan.hour, minute: plan.span[0] },
309
320
  { hour: plan.hour, minute: plan.span[1] },
@@ -420,6 +431,45 @@ function renderClockTimes(ir, plan, opts) {
420
431
  });
421
432
  return leadingQualifier(ir, opts) + groupClockTimes(phrases);
422
433
  }
434
+ function explicitClockList(times, opts) {
435
+ const phrases = times.map(function clock(time) {
436
+ return atTime(explicitTimePhrase(time.hour, time.minute, opts));
437
+ });
438
+ const grouped = groupClockTimes(phrases);
439
+ return grouped.startsWith("a ") ? grouped.slice(2) : grouped;
440
+ }
441
+ function durationHourList(times, opts) {
442
+ const phrases = times.map(function clock(time) {
443
+ return atTime(bareHourPhrase(time.hour, opts));
444
+ });
445
+ return groupClockTimes(phrases);
446
+ }
447
+ function bareHourPhrase(hour, opts) {
448
+ if (opts.ampm) {
449
+ return timePhrase(hour, 0, null, opts);
450
+ }
451
+ if (+hour === 0) {
452
+ return "medianoche";
453
+ }
454
+ if (+hour === 12) {
455
+ return "mediod\xEDa";
456
+ }
457
+ return (+hour === 1 ? "la " : "las ") + hour;
458
+ }
459
+ function explicitTimePhrase(hour, minute, opts) {
460
+ if (!opts.ampm) {
461
+ const article = +hour === 1 ? "la " : "las ";
462
+ const suffix = opts.style.hSuffix ? " h" : "";
463
+ return article + clockDigits(
464
+ { hour, minute, second: 0 },
465
+ { pad: true, sep: opts.style.sep }
466
+ ) + suffix;
467
+ }
468
+ const display = hour % 12 || 12;
469
+ const time = (display === 1 ? "la " : "las ") + clockDigits({ hour: display, minute, second: 0 }, { sep: opts.style.sep });
470
+ const period = opts.style.meridiem === "english" ? meridiemMark(hour) : dayPeriod(hour, opts);
471
+ return time + " " + period;
472
+ }
423
473
  function groupClockTimes(phrases) {
424
474
  if (phrases.length < 2) {
425
475
  return joinList(phrases);
@@ -992,17 +1042,15 @@ function numero(n, opts) {
992
1042
  return numeral(n, numeros, opts);
993
1043
  }
994
1044
  function weekdayName(token) {
995
- if (token === "7" || token === 7) {
996
- return weekdayNames[0];
997
- }
998
- return weekdayNames[token] || weekdayNames[weekdayTokens[token]];
1045
+ const number = toFieldNumber("" + token, weekdayNumbers);
1046
+ return weekdayNames[number === 7 ? 0 : number];
999
1047
  }
1000
1048
  function pluralWeekday(token) {
1001
1049
  const name = weekdayName(token);
1002
1050
  return name.endsWith("s") ? name : name + "s";
1003
1051
  }
1004
1052
  function monthName(token) {
1005
- return monthNames[token] || monthNames[monthTokens[token]];
1053
+ return monthNames[+token];
1006
1054
  }
1007
1055
  function isOpenStep(field) {
1008
1056
  return field.indexOf("/") !== -1 && field.indexOf("-") === -1 && field.indexOf(",") === -1;
@@ -1012,7 +1060,9 @@ var es2 = {
1012
1060
  fallback: "un patr\xF3n cron irreconocible",
1013
1061
  options: normalizeOptions,
1014
1062
  reboot: "al arrancar el sistema",
1015
- sentence: (description) => "Se ejecuta " + description + "."
1063
+ // A description ending in a period already carries it, so closing the
1064
+ // sentence must not double it.
1065
+ sentence: (description) => "Se ejecuta " + description + (description.endsWith(".") ? "" : ".")
1016
1066
  };
1017
1067
  var index_default = es2;
1018
1068
  module.exports = module.exports.default;
package/dist/lang/es.js CHANGED
@@ -14,6 +14,26 @@ 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
+
28
+ // src/core/util.ts
29
+ function isNonNegativeInteger(value) {
30
+ const digits = /^\d+$/;
31
+ return digits.test(value);
32
+ }
33
+ function toFieldNumber(token, numberMap) {
34
+ return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
35
+ }
36
+
17
37
  // src/lang/es/dialects.ts
18
38
  var es = {
19
39
  ampm: false,
@@ -85,29 +105,6 @@ var weekdayNames = [
85
105
  "viernes",
86
106
  "s\xE1bado"
87
107
  ];
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
108
  var nthWeekdayNames = [null, "primer", "segundo", "tercer", "cuarto", "quinto"];
112
109
  function normalizeOptions(options) {
113
110
  options = options || {};
@@ -151,6 +148,9 @@ function renderSecondsWithinMinute(ir, plan, opts) {
151
148
  return secondsLeadClause(ir, opts) + ", en el minuto " + minuteField + " de cada hora" + trailingQualifier(ir, opts);
152
149
  }
153
150
  function renderComposeSeconds(ir, plan, opts) {
151
+ if (plan.rest.kind === "clockTimes" && (ir.shapes.second === "wildcard" || ir.shapes.second === "step")) {
152
+ return pinnedMinuteSeconds(ir, plan.rest, opts);
153
+ }
154
154
  if (plan.rest.kind === "clockTimes" && ir.shapes.second === "list") {
155
155
  const clockPhrases = plan.rest.times.map(function clock(time) {
156
156
  return atTime(timePhrase(time.hour, time.minute, null, opts));
@@ -170,6 +170,14 @@ function renderComposeSeconds(ir, plan, opts) {
170
170
  }
171
171
  return secondsLeadClause(ir, opts) + ", " + render(ir, plan.rest, opts);
172
172
  }
173
+ function pinnedMinuteSeconds(ir, rest, opts) {
174
+ const dayTrail = leadingQualifier(ir, opts).trimEnd();
175
+ const trail = dayTrail ? ", " + dayTrail : "";
176
+ if (+rest.times[0].minute === 0) {
177
+ return secondsLeadClause(ir, opts) + " durante un minuto " + durationHourList(rest.times, opts) + trail;
178
+ }
179
+ return secondsLeadClause(ir, opts) + " de " + explicitClockList(rest.times, opts) + trail;
180
+ }
173
181
  function secondsLeadClause(ir, opts) {
174
182
  const secondField = ir.pattern.second;
175
183
  const shape = ir.shapes.second;
@@ -278,6 +286,9 @@ function renderMinuteFrequency(ir, plan, opts) {
278
286
  return phrase + trailingQualifier(ir, opts);
279
287
  }
280
288
  function renderMinuteSpanInHour(ir, plan, opts) {
289
+ if (ir.pattern.minute === "*") {
290
+ return "cada minuto de la hora " + fromTime(timePhrase(plan.hour, 0, null, opts)) + trailingQualifier(ir, opts);
291
+ }
281
292
  return "cada minuto " + timeRange(
282
293
  { hour: plan.hour, minute: plan.span[0] },
283
294
  { hour: plan.hour, minute: plan.span[1] },
@@ -394,6 +405,45 @@ function renderClockTimes(ir, plan, opts) {
394
405
  });
395
406
  return leadingQualifier(ir, opts) + groupClockTimes(phrases);
396
407
  }
408
+ function explicitClockList(times, opts) {
409
+ const phrases = times.map(function clock(time) {
410
+ return atTime(explicitTimePhrase(time.hour, time.minute, opts));
411
+ });
412
+ const grouped = groupClockTimes(phrases);
413
+ return grouped.startsWith("a ") ? grouped.slice(2) : grouped;
414
+ }
415
+ function durationHourList(times, opts) {
416
+ const phrases = times.map(function clock(time) {
417
+ return atTime(bareHourPhrase(time.hour, opts));
418
+ });
419
+ return groupClockTimes(phrases);
420
+ }
421
+ function bareHourPhrase(hour, opts) {
422
+ if (opts.ampm) {
423
+ return timePhrase(hour, 0, null, opts);
424
+ }
425
+ if (+hour === 0) {
426
+ return "medianoche";
427
+ }
428
+ if (+hour === 12) {
429
+ return "mediod\xEDa";
430
+ }
431
+ return (+hour === 1 ? "la " : "las ") + hour;
432
+ }
433
+ function explicitTimePhrase(hour, minute, opts) {
434
+ if (!opts.ampm) {
435
+ const article = +hour === 1 ? "la " : "las ";
436
+ const suffix = opts.style.hSuffix ? " h" : "";
437
+ return article + clockDigits(
438
+ { hour, minute, second: 0 },
439
+ { pad: true, sep: opts.style.sep }
440
+ ) + suffix;
441
+ }
442
+ const display = hour % 12 || 12;
443
+ const time = (display === 1 ? "la " : "las ") + clockDigits({ hour: display, minute, second: 0 }, { sep: opts.style.sep });
444
+ const period = opts.style.meridiem === "english" ? meridiemMark(hour) : dayPeriod(hour, opts);
445
+ return time + " " + period;
446
+ }
397
447
  function groupClockTimes(phrases) {
398
448
  if (phrases.length < 2) {
399
449
  return joinList(phrases);
@@ -966,17 +1016,15 @@ function numero(n, opts) {
966
1016
  return numeral(n, numeros, opts);
967
1017
  }
968
1018
  function weekdayName(token) {
969
- if (token === "7" || token === 7) {
970
- return weekdayNames[0];
971
- }
972
- return weekdayNames[token] || weekdayNames[weekdayTokens[token]];
1019
+ const number = toFieldNumber("" + token, weekdayNumbers);
1020
+ return weekdayNames[number === 7 ? 0 : number];
973
1021
  }
974
1022
  function pluralWeekday(token) {
975
1023
  const name = weekdayName(token);
976
1024
  return name.endsWith("s") ? name : name + "s";
977
1025
  }
978
1026
  function monthName(token) {
979
- return monthNames[token] || monthNames[monthTokens[token]];
1027
+ return monthNames[+token];
980
1028
  }
981
1029
  function isOpenStep(field) {
982
1030
  return field.indexOf("/") !== -1 && field.indexOf("-") === -1 && field.indexOf(",") === -1;
@@ -986,7 +1034,9 @@ var es2 = {
986
1034
  fallback: "un patr\xF3n cron irreconocible",
987
1035
  options: normalizeOptions,
988
1036
  reboot: "al arrancar el sistema",
989
- sentence: (description) => "Se ejecuta " + description + "."
1037
+ // A description ending in a period already carries it, so closing the
1038
+ // sentence must not double it.
1039
+ sentence: (description) => "Se ejecuta " + description + (description.endsWith(".") ? "" : ".")
990
1040
  };
991
1041
  var index_default = es2;
992
1042
  export {
package/dist/lang/fi.cjs CHANGED
@@ -40,6 +40,26 @@ function clockDigits(time, { sep, pad: padHour, lean }) {
40
40
  return head + sep + pad(time.minute) + (time.second ? sep + pad(time.second) : "");
41
41
  }
42
42
 
43
+ // src/core/specs.ts
44
+ var weekdayNumbers = {
45
+ SUN: 0,
46
+ MON: 1,
47
+ TUE: 2,
48
+ WED: 3,
49
+ THU: 4,
50
+ FRI: 5,
51
+ SAT: 6
52
+ };
53
+
54
+ // src/core/util.ts
55
+ function isNonNegativeInteger(value) {
56
+ const digits = /^\d+$/;
57
+ return digits.test(value);
58
+ }
59
+ function toFieldNumber(token, numberMap) {
60
+ return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
61
+ }
62
+
43
63
  // src/lang/fi/dialects.ts
44
64
  var dialects = {
45
65
  fi: {
@@ -166,29 +186,6 @@ var monthStems = [
166
186
  "marras",
167
187
  "joulu"
168
188
  ];
169
- var monthTokens = {
170
- JAN: 1,
171
- FEB: 2,
172
- MAR: 3,
173
- APR: 4,
174
- MAY: 5,
175
- JUN: 6,
176
- JUL: 7,
177
- AUG: 8,
178
- SEP: 9,
179
- OCT: 10,
180
- NOV: 11,
181
- DEC: 12
182
- };
183
- var weekdayTokens = {
184
- SUN: 0,
185
- MON: 1,
186
- TUE: 2,
187
- WED: 3,
188
- THU: 4,
189
- FRI: 5,
190
- SAT: 6
191
- };
192
189
  var units = {
193
190
  minute: {
194
191
  mark: "joka tunti",
@@ -273,8 +270,22 @@ function renderComposeSeconds(ir, plan, opts) {
273
270
  }
274
271
  return stepPhrase + ", " + secondsLeadClause(ir, opts) + hourClause + trailingQualifier(ir, opts);
275
272
  }
273
+ if (plan.rest.kind === "clockTimes" && plan.rest.times.every((time) => +time.minute === 0)) {
274
+ return composeMinuteZero(ir, plan.rest, opts);
275
+ }
276
276
  return secondsLeadClause(ir, opts) + ", " + render(ir, plan.rest, opts);
277
277
  }
278
+ function composeMinuteZero(ir, rest, opts) {
279
+ const clocks = rest.times.map(function clock(time) {
280
+ return clockDigits(
281
+ { hour: time.hour, minute: time.minute },
282
+ { sep: opts.style.sep }
283
+ );
284
+ });
285
+ const frame = clocks.length === 1 ? "minuutin " + clocks[0] : "minuuttien " + joinList(clocks);
286
+ const dayTrail = leadingQualifier(ir, opts).trimEnd();
287
+ return secondsLeadClause(ir, opts) + " " + frame + " aikana" + (dayTrail ? ", " + dayTrail : "");
288
+ }
278
289
  function secondsLeadClause(ir, opts) {
279
290
  const secondField = ir.pattern.second;
280
291
  const shape = ir.shapes.second;
@@ -385,6 +396,9 @@ function renderMinuteFrequency(ir, plan, opts) {
385
396
  return phrase + trailingQualifier(ir, opts);
386
397
  }
387
398
  function renderMinuteSpanInHour(ir, plan, opts) {
399
+ if (ir.pattern.minute === "*") {
400
+ return "joka minuutti kello " + plan.hour + " aikana" + trailingQualifier(ir, opts);
401
+ }
388
402
  return "joka minuutti " + kloRange(
389
403
  { hour: plan.hour, minute: plan.span[0] },
390
404
  { hour: plan.hour, minute: plan.span[1] },
@@ -840,13 +854,10 @@ function quartzWeekdayPhrase(weekdayField) {
840
854
  }
841
855
  }
842
856
  function weekdayNumber(token) {
843
- if (token in weekdayTokens) {
844
- return weekdayTokens[token];
845
- }
846
- return +token % 7;
857
+ return toFieldNumber("" + token, weekdayNumbers) % 7;
847
858
  }
848
859
  function monthNumber(token) {
849
- return monthTokens[token] || +token;
860
+ return +token;
850
861
  }
851
862
  function applyYear(description, ir, opts) {
852
863
  const yearField = ir.pattern.year;
@@ -928,7 +939,9 @@ var fi = {
928
939
  fallback: "tunnistamaton cron-lauseke",
929
940
  options: normalizeOptions,
930
941
  reboot: "j\xE4rjestelm\xE4n k\xE4ynnistyess\xE4",
931
- sentence: (description) => "Suoritetaan " + description + "."
942
+ // A description ending in a period already carries it, so closing the
943
+ // sentence must not double it.
944
+ sentence: (description) => "Suoritetaan " + description + (description.endsWith(".") ? "" : ".")
932
945
  };
933
946
  var index_default = fi;
934
947
  module.exports = module.exports.default;
package/dist/lang/fi.js CHANGED
@@ -14,6 +14,26 @@ 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
+
28
+ // src/core/util.ts
29
+ function isNonNegativeInteger(value) {
30
+ const digits = /^\d+$/;
31
+ return digits.test(value);
32
+ }
33
+ function toFieldNumber(token, numberMap) {
34
+ return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
35
+ }
36
+
17
37
  // src/lang/fi/dialects.ts
18
38
  var dialects = {
19
39
  fi: {
@@ -140,29 +160,6 @@ var monthStems = [
140
160
  "marras",
141
161
  "joulu"
142
162
  ];
143
- var monthTokens = {
144
- JAN: 1,
145
- FEB: 2,
146
- MAR: 3,
147
- APR: 4,
148
- MAY: 5,
149
- JUN: 6,
150
- JUL: 7,
151
- AUG: 8,
152
- SEP: 9,
153
- OCT: 10,
154
- NOV: 11,
155
- DEC: 12
156
- };
157
- var weekdayTokens = {
158
- SUN: 0,
159
- MON: 1,
160
- TUE: 2,
161
- WED: 3,
162
- THU: 4,
163
- FRI: 5,
164
- SAT: 6
165
- };
166
163
  var units = {
167
164
  minute: {
168
165
  mark: "joka tunti",
@@ -247,8 +244,22 @@ function renderComposeSeconds(ir, plan, opts) {
247
244
  }
248
245
  return stepPhrase + ", " + secondsLeadClause(ir, opts) + hourClause + trailingQualifier(ir, opts);
249
246
  }
247
+ if (plan.rest.kind === "clockTimes" && plan.rest.times.every((time) => +time.minute === 0)) {
248
+ return composeMinuteZero(ir, plan.rest, opts);
249
+ }
250
250
  return secondsLeadClause(ir, opts) + ", " + render(ir, plan.rest, opts);
251
251
  }
252
+ function composeMinuteZero(ir, rest, opts) {
253
+ const clocks = rest.times.map(function clock(time) {
254
+ return clockDigits(
255
+ { hour: time.hour, minute: time.minute },
256
+ { sep: opts.style.sep }
257
+ );
258
+ });
259
+ const frame = clocks.length === 1 ? "minuutin " + clocks[0] : "minuuttien " + joinList(clocks);
260
+ const dayTrail = leadingQualifier(ir, opts).trimEnd();
261
+ return secondsLeadClause(ir, opts) + " " + frame + " aikana" + (dayTrail ? ", " + dayTrail : "");
262
+ }
252
263
  function secondsLeadClause(ir, opts) {
253
264
  const secondField = ir.pattern.second;
254
265
  const shape = ir.shapes.second;
@@ -359,6 +370,9 @@ function renderMinuteFrequency(ir, plan, opts) {
359
370
  return phrase + trailingQualifier(ir, opts);
360
371
  }
361
372
  function renderMinuteSpanInHour(ir, plan, opts) {
373
+ if (ir.pattern.minute === "*") {
374
+ return "joka minuutti kello " + plan.hour + " aikana" + trailingQualifier(ir, opts);
375
+ }
362
376
  return "joka minuutti " + kloRange(
363
377
  { hour: plan.hour, minute: plan.span[0] },
364
378
  { hour: plan.hour, minute: plan.span[1] },
@@ -814,13 +828,10 @@ function quartzWeekdayPhrase(weekdayField) {
814
828
  }
815
829
  }
816
830
  function weekdayNumber(token) {
817
- if (token in weekdayTokens) {
818
- return weekdayTokens[token];
819
- }
820
- return +token % 7;
831
+ return toFieldNumber("" + token, weekdayNumbers) % 7;
821
832
  }
822
833
  function monthNumber(token) {
823
- return monthTokens[token] || +token;
834
+ return +token;
824
835
  }
825
836
  function applyYear(description, ir, opts) {
826
837
  const yearField = ir.pattern.year;
@@ -902,7 +913,9 @@ var fi = {
902
913
  fallback: "tunnistamaton cron-lauseke",
903
914
  options: normalizeOptions,
904
915
  reboot: "j\xE4rjestelm\xE4n k\xE4ynnistyess\xE4",
905
- sentence: (description) => "Suoritetaan " + description + "."
916
+ // A description ending in a period already carries it, so closing the
917
+ // sentence must not double it.
918
+ sentence: (description) => "Suoritetaan " + description + (description.endsWith(".") ? "" : ".")
906
919
  };
907
920
  var index_default = fi;
908
921
  export {
package/dist/lang/zh.cjs CHANGED
@@ -201,7 +201,8 @@ function renderMinuteFrequency(ir, plan) {
201
201
  const base = minuteStep.startToken === "*" ? cadence(minuteStep.interval, UNITS.minute) : renderMinutePast(ir);
202
202
  const { hours } = plan;
203
203
  if (hours.kind === "step") {
204
- return cadence(stepSegment(ir, "hour").interval, UNITS.hour) + base;
204
+ const hourStep = stepSegment(ir, "hour");
205
+ return hourStep.startToken === "*" ? cadence(hourStep.interval, UNITS.hour) + base : "\u5728" + hourList(ir) + "\uFF0C" + base;
205
206
  }
206
207
  if (hours.kind === "single" || hours.kind === "window" && hours.from === hours.to) {
207
208
  return "\u5728" + hourWord(hours.from) + "\u81F3" + hours.from + "\u70B9" + hours.last + "\u5206\u4E4B\u95F4\uFF0C" + base;
@@ -216,6 +217,9 @@ function renderMinuteFrequency(ir, plan) {
216
217
  }
217
218
  function renderMinuteSpanInHour(ir, plan) {
218
219
  const span = plan;
220
+ if (ir.pattern.minute === "*") {
221
+ return hourWord(span.hour) + "\u7684\u6BCF\u4E00\u5206\u949F";
222
+ }
219
223
  return "\u5728" + hourWord(span.hour) + "\u81F3" + span.hour + "\u70B9" + span.span[1] + "\u5206\u4E4B\u95F4\uFF0C\u6BCF\u5206\u949F";
220
224
  }
221
225
  function renderMinutesAcrossHours(ir, plan) {
@@ -226,12 +230,17 @@ function renderMinutesAcrossHours(ir, plan) {
226
230
  return hourList(ir) + "\uFF0C\u6BCF\u5C0F\u65F6" + valueList(fieldSegments(ir, "minute"), "\u5206") + "\uFF0C\u6BCF\u5206\u949F";
227
231
  }
228
232
  function renderMinuteSpanAcrossHourStep(ir, plan) {
229
- const cad = cadence(stepSegment(ir, "hour").interval, UNITS.hour);
233
+ const hourStep = stepSegment(ir, "hour");
230
234
  const { form } = plan;
231
- if (form === "wildcard") {
232
- return cad + "\u5185\uFF0C\u6BCF\u5206\u949F";
235
+ const minuteTail = form === "wildcard" ? "\u6BCF\u5206\u949F" : "\u6BCF\u5C0F\u65F6" + valueList(fieldSegments(ir, "minute"), "\u5206") + "\uFF0C\u6BCF\u5206\u949F";
236
+ if (hourStep.startToken !== "*") {
237
+ return form === "wildcard" ? "\u5728" + hourList(ir) + "\uFF0C" + minuteTail : hourList(ir) + "\uFF0C" + minuteTail;
233
238
  }
234
- return cad + "\uFF0C\u6BCF\u5C0F\u65F6" + valueList(fieldSegments(ir, "minute"), "\u5206") + "\uFF0C\u6BCF\u5206\u949F";
239
+ if (hourStep.interval === 2 && form === "wildcard") {
240
+ return "\u5728\u5076\u6570\u5C0F\u65F6\uFF0C" + minuteTail;
241
+ }
242
+ const cad = cadence(hourStep.interval, UNITS.hour);
243
+ return form === "wildcard" ? cad + "\u5185\uFF0C" + minuteTail : cad + "\uFF0C" + minuteTail;
235
244
  }
236
245
  function renderClockTimes(ir, plan, opts) {
237
246
  const { times } = plan;
@@ -317,9 +326,19 @@ function isHourCadence(ir) {
317
326
  function composeSecondsOnHour(ir, plan, opts) {
318
327
  const sec = secondClause(ir);
319
328
  const { rest } = plan;
329
+ if ((rest.kind === "clockTimes" || rest.kind === "compactClockTimes") && ir.pattern.minute === "0") {
330
+ const clocks = hourFires(ir).map(function clock(hour) {
331
+ return hourWord(hour) + "0\u5206";
332
+ });
333
+ const tail = sec === "\u6BCF\u79D2" ? "\u7684\u6BCF\u4E00\u79D2" : "\u7684" + sec;
334
+ const core = joinAnd(clocks) + tail;
335
+ return isDaily(ir) ? "\u6BCF\u5929" + core : core;
336
+ }
320
337
  const restText = render(ir, rest, opts);
321
- if ((rest.kind === "clockTimes" || rest.kind === "compactClockTimes") && isDaily(ir)) {
322
- return "\u6BCF\u5929" + restText + sec;
338
+ if (rest.kind === "clockTimes" || rest.kind === "compactClockTimes") {
339
+ if (isDaily(ir)) {
340
+ return "\u6BCF\u5929" + restText + sec;
341
+ }
323
342
  }
324
343
  if (rest.kind === "singleMinute") {
325
344
  return restText + "\uFF0C" + sec;
@@ -343,6 +362,9 @@ function composeSecondsCadence(ir) {
343
362
  function composeSecondsListed(ir) {
344
363
  const sec = secondClause(ir);
345
364
  const minutes = "\u6BCF\u5C0F\u65F6" + valueList(fieldSegments(ir, "minute"), "\u5206");
365
+ if (ir.shapes.hour === "single" && sec === "\u6BCF\u79D2") {
366
+ return hourWord(hourFires(ir)[0]) + valueList(fieldSegments(ir, "minute"), "\u5206") + "\u7684\u6BCF\u4E00\u79D2";
367
+ }
346
368
  if (ir.shapes.hour === "wildcard") {
347
369
  return minutes + "\uFF0C" + sec;
348
370
  }
@@ -352,10 +374,13 @@ function composeSecondsListed(ir) {
352
374
  return hourFrame(ir) + minutes + "\uFF0C" + sec;
353
375
  }
354
376
  function renderComposeSeconds(ir, plan, opts) {
355
- if (ir.pattern.minute === "0") {
377
+ const { rest } = plan;
378
+ const composedClock = rest.kind === "clockTimes" || rest.kind === "compactClockTimes";
379
+ if (ir.pattern.minute === "0" || composedClock && ir.shapes.minute === "single") {
356
380
  return composeSecondsOnHour(ir, plan, opts);
357
381
  }
358
- if (ir.pattern.minute === "*" || ir.shapes.minute === "step") {
382
+ const minuteCadence = ir.pattern.minute === "*" || ir.shapes.minute === "step" && stepSegment(ir, "minute").startToken === "*";
383
+ if (minuteCadence) {
359
384
  return composeSecondsCadence(ir);
360
385
  }
361
386
  return composeSecondsListed(ir);