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/CHANGELOG.md +64 -0
- package/cli.js +9 -0
- package/cronli5.min.js +2 -2
- package/dist/cronli5.cjs +100 -28
- package/dist/cronli5.js +100 -28
- package/dist/lang/de.cjs +55 -34
- package/dist/lang/de.js +55 -34
- package/dist/lang/en.cjs +41 -21
- package/dist/lang/en.js +41 -21
- package/dist/lang/es.cjs +79 -29
- package/dist/lang/es.js +79 -29
- package/dist/lang/fi.cjs +42 -29
- package/dist/lang/fi.js +42 -29
- package/dist/lang/zh.cjs +34 -9
- package/dist/lang/zh.js +34 -9
- package/package.json +2 -1
- package/src/core/normalize.ts +94 -4
- package/src/lang/de/index.ts +92 -33
- package/src/lang/en/index.ts +100 -30
- package/src/lang/es/index.ts +134 -25
- package/src/lang/fi/index.ts +54 -20
- package/src/lang/zh/index.ts +83 -12
package/dist/lang/de.cjs
CHANGED
|
@@ -30,6 +30,26 @@ function pad(n) {
|
|
|
30
30
|
return n.length < 2 ? "0" + n : n;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// src/core/specs.ts
|
|
34
|
+
var weekdayNumbers = {
|
|
35
|
+
SUN: 0,
|
|
36
|
+
MON: 1,
|
|
37
|
+
TUE: 2,
|
|
38
|
+
WED: 3,
|
|
39
|
+
THU: 4,
|
|
40
|
+
FRI: 5,
|
|
41
|
+
SAT: 6
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// src/core/util.ts
|
|
45
|
+
function isNonNegativeInteger(value) {
|
|
46
|
+
const digits = /^\d+$/;
|
|
47
|
+
return digits.test(value);
|
|
48
|
+
}
|
|
49
|
+
function toFieldNumber(token, numberMap) {
|
|
50
|
+
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
51
|
+
}
|
|
52
|
+
|
|
33
53
|
// src/lang/de/dialects.ts
|
|
34
54
|
var months = [
|
|
35
55
|
null,
|
|
@@ -101,15 +121,6 @@ var weekdayNames = [
|
|
|
101
121
|
"freitags",
|
|
102
122
|
"samstags"
|
|
103
123
|
];
|
|
104
|
-
var weekdayTokens = {
|
|
105
|
-
SUN: 0,
|
|
106
|
-
MON: 1,
|
|
107
|
-
TUE: 2,
|
|
108
|
-
WED: 3,
|
|
109
|
-
THU: 4,
|
|
110
|
-
FRI: 5,
|
|
111
|
-
SAT: 6
|
|
112
|
-
};
|
|
113
124
|
function fieldSegments(ir, field) {
|
|
114
125
|
return ir.analyses.segments[field];
|
|
115
126
|
}
|
|
@@ -130,10 +141,7 @@ function joinList(items) {
|
|
|
130
141
|
return items.slice(0, -1).join(", ") + " und " + items[items.length - 1];
|
|
131
142
|
}
|
|
132
143
|
function weekdayName(token) {
|
|
133
|
-
|
|
134
|
-
return weekdayNames[0];
|
|
135
|
-
}
|
|
136
|
-
return weekdayNames[token] || weekdayNames[weekdayTokens[token]];
|
|
144
|
+
return weekdayNames[+token];
|
|
137
145
|
}
|
|
138
146
|
function weekdayRange(bounds) {
|
|
139
147
|
return weekdayName(bounds[0]) + " bis " + weekdayName(bounds[1]);
|
|
@@ -171,10 +179,7 @@ function everyNthHour(segment) {
|
|
|
171
179
|
return start === 0 ? base : base + " ab " + start + " Uhr";
|
|
172
180
|
}
|
|
173
181
|
function weekdayNoun(token) {
|
|
174
|
-
|
|
175
|
-
return weekdayNouns[0];
|
|
176
|
-
}
|
|
177
|
-
return weekdayNouns[token in weekdayTokens ? weekdayTokens[token] : +token];
|
|
182
|
+
return weekdayNouns[toFieldNumber(token, weekdayNumbers)];
|
|
178
183
|
}
|
|
179
184
|
function quartzWeekday(field) {
|
|
180
185
|
if (field.indexOf("#") !== -1) {
|
|
@@ -198,22 +203,8 @@ function quartzDate(field) {
|
|
|
198
203
|
}
|
|
199
204
|
return null;
|
|
200
205
|
}
|
|
201
|
-
var monthTokens = {
|
|
202
|
-
JAN: 1,
|
|
203
|
-
FEB: 2,
|
|
204
|
-
MAR: 3,
|
|
205
|
-
APR: 4,
|
|
206
|
-
MAY: 5,
|
|
207
|
-
JUN: 6,
|
|
208
|
-
JUL: 7,
|
|
209
|
-
AUG: 8,
|
|
210
|
-
SEP: 9,
|
|
211
|
-
OCT: 10,
|
|
212
|
-
NOV: 11,
|
|
213
|
-
DEC: 12
|
|
214
|
-
};
|
|
215
206
|
function monthName(token, months2) {
|
|
216
|
-
return months2[token]
|
|
207
|
+
return months2[+token];
|
|
217
208
|
}
|
|
218
209
|
function monthRange(bounds, months2) {
|
|
219
210
|
return "von " + monthName(bounds[0], months2) + " bis " + monthName(bounds[1], months2);
|
|
@@ -375,13 +366,37 @@ function renderSecondsWithinMinute(ir, plan) {
|
|
|
375
366
|
}
|
|
376
367
|
return secondsLead(ir) + ", in Minute " + ir.pattern.minute + " jeder Stunde";
|
|
377
368
|
}
|
|
369
|
+
function wholeHour(hour) {
|
|
370
|
+
if (hour === 0) {
|
|
371
|
+
return "der Mitternachtsstunde";
|
|
372
|
+
}
|
|
373
|
+
if (hour === 12) {
|
|
374
|
+
return "der Mittagsstunde";
|
|
375
|
+
}
|
|
376
|
+
return "der " + hour + "-Uhr-Stunde";
|
|
377
|
+
}
|
|
378
378
|
function renderMinuteSpanInHour(ir, plan, opts) {
|
|
379
|
+
if (ir.pattern.minute === "*") {
|
|
380
|
+
return "jede Minute " + wholeHour(plan.hour);
|
|
381
|
+
}
|
|
379
382
|
const sep = opts.style.sep;
|
|
380
383
|
return "jede Minute von " + spanTime(plan.hour, plan.span[0], sep) + " bis " + spanTime(plan.hour, plan.span[1], sep) + " Uhr";
|
|
381
384
|
}
|
|
382
385
|
function renderComposeSeconds(ir, plan, opts) {
|
|
386
|
+
if (composeMinuteZero(ir, plan)) {
|
|
387
|
+
return secondsLead(ir) + " " + clockMinuteGenitive(plan.rest.times, opts.style.sep);
|
|
388
|
+
}
|
|
383
389
|
return secondsLead(ir) + ", " + render(ir, plan.rest, opts);
|
|
384
390
|
}
|
|
391
|
+
function composeMinuteZero(ir, plan) {
|
|
392
|
+
return plan.rest.kind === "clockTimes" && plan.rest.times.every((time) => +time.minute === 0);
|
|
393
|
+
}
|
|
394
|
+
function clockMinuteGenitive(times, sep) {
|
|
395
|
+
const clocks = times.map(function clock(time) {
|
|
396
|
+
return time.hour + sep + pad(time.minute);
|
|
397
|
+
});
|
|
398
|
+
return clocks.length === 1 ? "der Minute " + clocks[0] : "der Minuten " + joinList(clocks);
|
|
399
|
+
}
|
|
385
400
|
function renderMinutesAcrossHours(ir, plan, opts) {
|
|
386
401
|
const sep = opts.style.sep;
|
|
387
402
|
if (plan.form === "wildcard") {
|
|
@@ -490,8 +505,14 @@ function qualifier(ir, months2) {
|
|
|
490
505
|
return "";
|
|
491
506
|
}
|
|
492
507
|
var LEADING_PLANS = /* @__PURE__ */ new Set(["clockTimes"]);
|
|
508
|
+
function leadsQualifier(ir) {
|
|
509
|
+
return LEADING_PLANS.has(ir.plan.kind) || isComposeMinuteZero(ir);
|
|
510
|
+
}
|
|
511
|
+
function isComposeMinuteZero(ir) {
|
|
512
|
+
return ir.plan.kind === "composeSeconds" && composeMinuteZero(ir, ir.plan);
|
|
513
|
+
}
|
|
493
514
|
function needsDailyFrame(ir) {
|
|
494
|
-
if (ir.plan.kind === "clockTimes") {
|
|
515
|
+
if (ir.plan.kind === "clockTimes" || isComposeMinuteZero(ir)) {
|
|
495
516
|
return true;
|
|
496
517
|
}
|
|
497
518
|
return ir.plan.kind === "hourStep" && !cleanStep(stepSegment(ir.analyses.segments.hour), 24);
|
|
@@ -534,7 +555,7 @@ function describe(ir, opts) {
|
|
|
534
555
|
const qual = qualifier(ir, opts.style.months);
|
|
535
556
|
let base = core;
|
|
536
557
|
if (qual) {
|
|
537
|
-
base =
|
|
558
|
+
base = leadsQualifier(ir) ? qual + " " + core : core + " " + qual;
|
|
538
559
|
} else if (needsDailyFrame(ir)) {
|
|
539
560
|
base = "t\xE4glich " + core;
|
|
540
561
|
}
|
package/dist/lang/de.js
CHANGED
|
@@ -4,6 +4,26 @@ function pad(n) {
|
|
|
4
4
|
return n.length < 2 ? "0" + n : n;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
// src/core/specs.ts
|
|
8
|
+
var weekdayNumbers = {
|
|
9
|
+
SUN: 0,
|
|
10
|
+
MON: 1,
|
|
11
|
+
TUE: 2,
|
|
12
|
+
WED: 3,
|
|
13
|
+
THU: 4,
|
|
14
|
+
FRI: 5,
|
|
15
|
+
SAT: 6
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// src/core/util.ts
|
|
19
|
+
function isNonNegativeInteger(value) {
|
|
20
|
+
const digits = /^\d+$/;
|
|
21
|
+
return digits.test(value);
|
|
22
|
+
}
|
|
23
|
+
function toFieldNumber(token, numberMap) {
|
|
24
|
+
return isNonNegativeInteger(token) ? +token : numberMap[token.toUpperCase()];
|
|
25
|
+
}
|
|
26
|
+
|
|
7
27
|
// src/lang/de/dialects.ts
|
|
8
28
|
var months = [
|
|
9
29
|
null,
|
|
@@ -75,15 +95,6 @@ var weekdayNames = [
|
|
|
75
95
|
"freitags",
|
|
76
96
|
"samstags"
|
|
77
97
|
];
|
|
78
|
-
var weekdayTokens = {
|
|
79
|
-
SUN: 0,
|
|
80
|
-
MON: 1,
|
|
81
|
-
TUE: 2,
|
|
82
|
-
WED: 3,
|
|
83
|
-
THU: 4,
|
|
84
|
-
FRI: 5,
|
|
85
|
-
SAT: 6
|
|
86
|
-
};
|
|
87
98
|
function fieldSegments(ir, field) {
|
|
88
99
|
return ir.analyses.segments[field];
|
|
89
100
|
}
|
|
@@ -104,10 +115,7 @@ function joinList(items) {
|
|
|
104
115
|
return items.slice(0, -1).join(", ") + " und " + items[items.length - 1];
|
|
105
116
|
}
|
|
106
117
|
function weekdayName(token) {
|
|
107
|
-
|
|
108
|
-
return weekdayNames[0];
|
|
109
|
-
}
|
|
110
|
-
return weekdayNames[token] || weekdayNames[weekdayTokens[token]];
|
|
118
|
+
return weekdayNames[+token];
|
|
111
119
|
}
|
|
112
120
|
function weekdayRange(bounds) {
|
|
113
121
|
return weekdayName(bounds[0]) + " bis " + weekdayName(bounds[1]);
|
|
@@ -145,10 +153,7 @@ function everyNthHour(segment) {
|
|
|
145
153
|
return start === 0 ? base : base + " ab " + start + " Uhr";
|
|
146
154
|
}
|
|
147
155
|
function weekdayNoun(token) {
|
|
148
|
-
|
|
149
|
-
return weekdayNouns[0];
|
|
150
|
-
}
|
|
151
|
-
return weekdayNouns[token in weekdayTokens ? weekdayTokens[token] : +token];
|
|
156
|
+
return weekdayNouns[toFieldNumber(token, weekdayNumbers)];
|
|
152
157
|
}
|
|
153
158
|
function quartzWeekday(field) {
|
|
154
159
|
if (field.indexOf("#") !== -1) {
|
|
@@ -172,22 +177,8 @@ function quartzDate(field) {
|
|
|
172
177
|
}
|
|
173
178
|
return null;
|
|
174
179
|
}
|
|
175
|
-
var monthTokens = {
|
|
176
|
-
JAN: 1,
|
|
177
|
-
FEB: 2,
|
|
178
|
-
MAR: 3,
|
|
179
|
-
APR: 4,
|
|
180
|
-
MAY: 5,
|
|
181
|
-
JUN: 6,
|
|
182
|
-
JUL: 7,
|
|
183
|
-
AUG: 8,
|
|
184
|
-
SEP: 9,
|
|
185
|
-
OCT: 10,
|
|
186
|
-
NOV: 11,
|
|
187
|
-
DEC: 12
|
|
188
|
-
};
|
|
189
180
|
function monthName(token, months2) {
|
|
190
|
-
return months2[token]
|
|
181
|
+
return months2[+token];
|
|
191
182
|
}
|
|
192
183
|
function monthRange(bounds, months2) {
|
|
193
184
|
return "von " + monthName(bounds[0], months2) + " bis " + monthName(bounds[1], months2);
|
|
@@ -349,13 +340,37 @@ function renderSecondsWithinMinute(ir, plan) {
|
|
|
349
340
|
}
|
|
350
341
|
return secondsLead(ir) + ", in Minute " + ir.pattern.minute + " jeder Stunde";
|
|
351
342
|
}
|
|
343
|
+
function wholeHour(hour) {
|
|
344
|
+
if (hour === 0) {
|
|
345
|
+
return "der Mitternachtsstunde";
|
|
346
|
+
}
|
|
347
|
+
if (hour === 12) {
|
|
348
|
+
return "der Mittagsstunde";
|
|
349
|
+
}
|
|
350
|
+
return "der " + hour + "-Uhr-Stunde";
|
|
351
|
+
}
|
|
352
352
|
function renderMinuteSpanInHour(ir, plan, opts) {
|
|
353
|
+
if (ir.pattern.minute === "*") {
|
|
354
|
+
return "jede Minute " + wholeHour(plan.hour);
|
|
355
|
+
}
|
|
353
356
|
const sep = opts.style.sep;
|
|
354
357
|
return "jede Minute von " + spanTime(plan.hour, plan.span[0], sep) + " bis " + spanTime(plan.hour, plan.span[1], sep) + " Uhr";
|
|
355
358
|
}
|
|
356
359
|
function renderComposeSeconds(ir, plan, opts) {
|
|
360
|
+
if (composeMinuteZero(ir, plan)) {
|
|
361
|
+
return secondsLead(ir) + " " + clockMinuteGenitive(plan.rest.times, opts.style.sep);
|
|
362
|
+
}
|
|
357
363
|
return secondsLead(ir) + ", " + render(ir, plan.rest, opts);
|
|
358
364
|
}
|
|
365
|
+
function composeMinuteZero(ir, plan) {
|
|
366
|
+
return plan.rest.kind === "clockTimes" && plan.rest.times.every((time) => +time.minute === 0);
|
|
367
|
+
}
|
|
368
|
+
function clockMinuteGenitive(times, sep) {
|
|
369
|
+
const clocks = times.map(function clock(time) {
|
|
370
|
+
return time.hour + sep + pad(time.minute);
|
|
371
|
+
});
|
|
372
|
+
return clocks.length === 1 ? "der Minute " + clocks[0] : "der Minuten " + joinList(clocks);
|
|
373
|
+
}
|
|
359
374
|
function renderMinutesAcrossHours(ir, plan, opts) {
|
|
360
375
|
const sep = opts.style.sep;
|
|
361
376
|
if (plan.form === "wildcard") {
|
|
@@ -464,8 +479,14 @@ function qualifier(ir, months2) {
|
|
|
464
479
|
return "";
|
|
465
480
|
}
|
|
466
481
|
var LEADING_PLANS = /* @__PURE__ */ new Set(["clockTimes"]);
|
|
482
|
+
function leadsQualifier(ir) {
|
|
483
|
+
return LEADING_PLANS.has(ir.plan.kind) || isComposeMinuteZero(ir);
|
|
484
|
+
}
|
|
485
|
+
function isComposeMinuteZero(ir) {
|
|
486
|
+
return ir.plan.kind === "composeSeconds" && composeMinuteZero(ir, ir.plan);
|
|
487
|
+
}
|
|
467
488
|
function needsDailyFrame(ir) {
|
|
468
|
-
if (ir.plan.kind === "clockTimes") {
|
|
489
|
+
if (ir.plan.kind === "clockTimes" || isComposeMinuteZero(ir)) {
|
|
469
490
|
return true;
|
|
470
491
|
}
|
|
471
492
|
return ir.plan.kind === "hourStep" && !cleanStep(stepSegment(ir.analyses.segments.hour), 24);
|
|
@@ -508,7 +529,7 @@ function describe(ir, opts) {
|
|
|
508
529
|
const qual = qualifier(ir, opts.style.months);
|
|
509
530
|
let base = core;
|
|
510
531
|
if (qual) {
|
|
511
|
-
base =
|
|
532
|
+
base = leadsQualifier(ir) ? qual + " " + core : core + " " + qual;
|
|
512
533
|
} else if (needsDailyFrame(ir)) {
|
|
513
534
|
base = "t\xE4glich " + core;
|
|
514
535
|
}
|
package/dist/lang/en.cjs
CHANGED
|
@@ -131,20 +131,6 @@ var weekdayNames = [
|
|
|
131
131
|
["Friday", "Fri"],
|
|
132
132
|
["Saturday", "Sat"]
|
|
133
133
|
];
|
|
134
|
-
var monthAbbreviations = {
|
|
135
|
-
JAN: monthNames[1],
|
|
136
|
-
FEB: monthNames[2],
|
|
137
|
-
MAR: monthNames[3],
|
|
138
|
-
APR: monthNames[4],
|
|
139
|
-
MAY: monthNames[5],
|
|
140
|
-
JUN: monthNames[6],
|
|
141
|
-
JUL: monthNames[7],
|
|
142
|
-
AUG: monthNames[8],
|
|
143
|
-
SEP: monthNames[9],
|
|
144
|
-
OCT: monthNames[10],
|
|
145
|
-
NOV: monthNames[11],
|
|
146
|
-
DEC: monthNames[12]
|
|
147
|
-
};
|
|
148
134
|
var weekdayAbbreviations = {
|
|
149
135
|
SUN: weekdayNames[0],
|
|
150
136
|
MON: weekdayNames[1],
|
|
@@ -194,8 +180,37 @@ function renderSecondsWithinMinute(ir, plan, opts) {
|
|
|
194
180
|
return secondsLeadClause(ir, opts) + ", " + minuteWord + " " + minuteUnit + " past the hour, every hour" + trailingQualifier(ir, opts);
|
|
195
181
|
}
|
|
196
182
|
function renderComposeSeconds(ir, plan, opts) {
|
|
183
|
+
if (plan.rest.kind === "clockTimes" && (ir.shapes.second === "wildcard" || ir.shapes.second === "step")) {
|
|
184
|
+
const minute = plan.rest.times[0].minute;
|
|
185
|
+
if (+minute === 0) {
|
|
186
|
+
return secondsLeadClause(ir, opts) + " for one minute at " + durationHours(ir, plan.rest, opts);
|
|
187
|
+
}
|
|
188
|
+
return secondsLeadClause(ir, opts) + " of " + clockTimesOf(ir, plan.rest, opts);
|
|
189
|
+
}
|
|
190
|
+
if (ir.shapes.second === "wildcard" && plan.rest.kind === "minuteFrequency" && plan.rest.hours.kind === "none" && ir.pattern.minute === "*/2") {
|
|
191
|
+
return "every second of every other minute" + trailingQualifier(ir, opts);
|
|
192
|
+
}
|
|
197
193
|
return secondsLeadClause(ir, opts) + ", " + render(ir, plan.rest, opts);
|
|
198
194
|
}
|
|
195
|
+
function durationHours(ir, plan, opts) {
|
|
196
|
+
const hours = plan.times.map(function clock(time) {
|
|
197
|
+
return getTime({ hour: time.hour, minute: 0 }, opts);
|
|
198
|
+
});
|
|
199
|
+
const trail = dayQualifier(ir, leadingWords, opts);
|
|
200
|
+
return joinList(hours, opts) + (trail && ", " + trail);
|
|
201
|
+
}
|
|
202
|
+
function clockTimesOf(ir, plan, opts) {
|
|
203
|
+
const times = plan.times.map(function clock(time) {
|
|
204
|
+
return getTime({
|
|
205
|
+
hour: time.hour,
|
|
206
|
+
minute: time.minute,
|
|
207
|
+
second: time.second,
|
|
208
|
+
explicit: true
|
|
209
|
+
}, opts);
|
|
210
|
+
});
|
|
211
|
+
const trail = dayQualifier(ir, leadingWords, opts);
|
|
212
|
+
return joinList(times, opts) + (trail && ", " + trail);
|
|
213
|
+
}
|
|
199
214
|
function secondsLeadClause(ir, opts) {
|
|
200
215
|
const secondField = ir.pattern.second;
|
|
201
216
|
const shape = ir.shapes.second;
|
|
@@ -260,6 +275,9 @@ function renderMinuteFrequency(ir, plan, opts) {
|
|
|
260
275
|
return phrase + trailingQualifier(ir, opts);
|
|
261
276
|
}
|
|
262
277
|
function renderMinuteSpanInHour(ir, plan, opts) {
|
|
278
|
+
if (ir.pattern.minute === "*") {
|
|
279
|
+
return "every minute of the " + getTime({ hour: plan.hour, minute: 0 }, opts) + " hour" + trailingQualifier(ir, opts);
|
|
280
|
+
}
|
|
263
281
|
return "every minute from " + getTime({ hour: plan.hour, minute: plan.span[0] }, opts) + through(opts) + getTime({ hour: plan.hour, minute: plan.span[1] }, opts) + trailingQualifier(ir, opts);
|
|
264
282
|
}
|
|
265
283
|
function renderMinutesAcrossHours(ir, plan, opts) {
|
|
@@ -758,7 +776,7 @@ function stepYears(yearField, opts) {
|
|
|
758
776
|
return phrase;
|
|
759
777
|
}
|
|
760
778
|
function getTime(time, opts) {
|
|
761
|
-
const { hour, minute, plain } = time;
|
|
779
|
+
const { hour, minute, plain, explicit } = time;
|
|
762
780
|
const second = typeof time.second === "number" && time.second > 0 ? time.second : 0;
|
|
763
781
|
if (!opts.ampm) {
|
|
764
782
|
return clockDigits({
|
|
@@ -767,12 +785,12 @@ function getTime(time, opts) {
|
|
|
767
785
|
second
|
|
768
786
|
}, { pad: true, sep: opts.style.sep });
|
|
769
787
|
}
|
|
770
|
-
return twelveHourTime({ hour, minute, second, plain }, opts);
|
|
788
|
+
return twelveHourTime({ hour, minute, second, plain, explicit }, opts);
|
|
771
789
|
}
|
|
772
790
|
function twelveHourTime(time, opts) {
|
|
773
|
-
const { hour, minute, second, plain } = time;
|
|
791
|
+
const { hour, minute, second, plain, explicit } = time;
|
|
774
792
|
const style = opts.style;
|
|
775
|
-
if (!plain && +minute === 0 && !second) {
|
|
793
|
+
if (!plain && !explicit && +minute === 0 && !second) {
|
|
776
794
|
if (+hour === 0) {
|
|
777
795
|
return style.midnight;
|
|
778
796
|
}
|
|
@@ -782,7 +800,7 @@ function twelveHourTime(time, opts) {
|
|
|
782
800
|
}
|
|
783
801
|
const digits = clockDigits(
|
|
784
802
|
{ hour: hour % 12 || 12, minute, second },
|
|
785
|
-
{ lean:
|
|
803
|
+
{ lean: !explicit, sep: style.sep }
|
|
786
804
|
);
|
|
787
805
|
return digits + (style.closeUp ? "" : " ") + (hour < 12 ? style.am : style.pm);
|
|
788
806
|
}
|
|
@@ -805,7 +823,7 @@ function getOrdinal(n) {
|
|
|
805
823
|
return n + suffix;
|
|
806
824
|
}
|
|
807
825
|
function getMonth(m, opts) {
|
|
808
|
-
const month = monthNames[m]
|
|
826
|
+
const month = monthNames[+m];
|
|
809
827
|
return month && month[opts.short ? 1 : 0];
|
|
810
828
|
}
|
|
811
829
|
function getWeekday(d, opts) {
|
|
@@ -818,7 +836,9 @@ var en = {
|
|
|
818
836
|
fallback: "an unrecognizable cron pattern",
|
|
819
837
|
options: normalizeOptions,
|
|
820
838
|
reboot: "at system startup",
|
|
821
|
-
|
|
839
|
+
// A description ending in an abbreviation already carries its period
|
|
840
|
+
// ("…9 a.m."), so closing the sentence must not double it.
|
|
841
|
+
sentence: (description) => "Runs " + description + (description.endsWith(".") ? "" : ".")
|
|
822
842
|
};
|
|
823
843
|
var index_default = en;
|
|
824
844
|
module.exports = module.exports.default;
|
package/dist/lang/en.js
CHANGED
|
@@ -105,20 +105,6 @@ var weekdayNames = [
|
|
|
105
105
|
["Friday", "Fri"],
|
|
106
106
|
["Saturday", "Sat"]
|
|
107
107
|
];
|
|
108
|
-
var monthAbbreviations = {
|
|
109
|
-
JAN: monthNames[1],
|
|
110
|
-
FEB: monthNames[2],
|
|
111
|
-
MAR: monthNames[3],
|
|
112
|
-
APR: monthNames[4],
|
|
113
|
-
MAY: monthNames[5],
|
|
114
|
-
JUN: monthNames[6],
|
|
115
|
-
JUL: monthNames[7],
|
|
116
|
-
AUG: monthNames[8],
|
|
117
|
-
SEP: monthNames[9],
|
|
118
|
-
OCT: monthNames[10],
|
|
119
|
-
NOV: monthNames[11],
|
|
120
|
-
DEC: monthNames[12]
|
|
121
|
-
};
|
|
122
108
|
var weekdayAbbreviations = {
|
|
123
109
|
SUN: weekdayNames[0],
|
|
124
110
|
MON: weekdayNames[1],
|
|
@@ -168,8 +154,37 @@ function renderSecondsWithinMinute(ir, plan, opts) {
|
|
|
168
154
|
return secondsLeadClause(ir, opts) + ", " + minuteWord + " " + minuteUnit + " past the hour, every hour" + trailingQualifier(ir, opts);
|
|
169
155
|
}
|
|
170
156
|
function renderComposeSeconds(ir, plan, opts) {
|
|
157
|
+
if (plan.rest.kind === "clockTimes" && (ir.shapes.second === "wildcard" || ir.shapes.second === "step")) {
|
|
158
|
+
const minute = plan.rest.times[0].minute;
|
|
159
|
+
if (+minute === 0) {
|
|
160
|
+
return secondsLeadClause(ir, opts) + " for one minute at " + durationHours(ir, plan.rest, opts);
|
|
161
|
+
}
|
|
162
|
+
return secondsLeadClause(ir, opts) + " of " + clockTimesOf(ir, plan.rest, opts);
|
|
163
|
+
}
|
|
164
|
+
if (ir.shapes.second === "wildcard" && plan.rest.kind === "minuteFrequency" && plan.rest.hours.kind === "none" && ir.pattern.minute === "*/2") {
|
|
165
|
+
return "every second of every other minute" + trailingQualifier(ir, opts);
|
|
166
|
+
}
|
|
171
167
|
return secondsLeadClause(ir, opts) + ", " + render(ir, plan.rest, opts);
|
|
172
168
|
}
|
|
169
|
+
function durationHours(ir, plan, opts) {
|
|
170
|
+
const hours = plan.times.map(function clock(time) {
|
|
171
|
+
return getTime({ hour: time.hour, minute: 0 }, opts);
|
|
172
|
+
});
|
|
173
|
+
const trail = dayQualifier(ir, leadingWords, opts);
|
|
174
|
+
return joinList(hours, opts) + (trail && ", " + trail);
|
|
175
|
+
}
|
|
176
|
+
function clockTimesOf(ir, plan, opts) {
|
|
177
|
+
const times = plan.times.map(function clock(time) {
|
|
178
|
+
return getTime({
|
|
179
|
+
hour: time.hour,
|
|
180
|
+
minute: time.minute,
|
|
181
|
+
second: time.second,
|
|
182
|
+
explicit: true
|
|
183
|
+
}, opts);
|
|
184
|
+
});
|
|
185
|
+
const trail = dayQualifier(ir, leadingWords, opts);
|
|
186
|
+
return joinList(times, opts) + (trail && ", " + trail);
|
|
187
|
+
}
|
|
173
188
|
function secondsLeadClause(ir, opts) {
|
|
174
189
|
const secondField = ir.pattern.second;
|
|
175
190
|
const shape = ir.shapes.second;
|
|
@@ -234,6 +249,9 @@ function renderMinuteFrequency(ir, plan, opts) {
|
|
|
234
249
|
return phrase + trailingQualifier(ir, opts);
|
|
235
250
|
}
|
|
236
251
|
function renderMinuteSpanInHour(ir, plan, opts) {
|
|
252
|
+
if (ir.pattern.minute === "*") {
|
|
253
|
+
return "every minute of the " + getTime({ hour: plan.hour, minute: 0 }, opts) + " hour" + trailingQualifier(ir, opts);
|
|
254
|
+
}
|
|
237
255
|
return "every minute from " + getTime({ hour: plan.hour, minute: plan.span[0] }, opts) + through(opts) + getTime({ hour: plan.hour, minute: plan.span[1] }, opts) + trailingQualifier(ir, opts);
|
|
238
256
|
}
|
|
239
257
|
function renderMinutesAcrossHours(ir, plan, opts) {
|
|
@@ -732,7 +750,7 @@ function stepYears(yearField, opts) {
|
|
|
732
750
|
return phrase;
|
|
733
751
|
}
|
|
734
752
|
function getTime(time, opts) {
|
|
735
|
-
const { hour, minute, plain } = time;
|
|
753
|
+
const { hour, minute, plain, explicit } = time;
|
|
736
754
|
const second = typeof time.second === "number" && time.second > 0 ? time.second : 0;
|
|
737
755
|
if (!opts.ampm) {
|
|
738
756
|
return clockDigits({
|
|
@@ -741,12 +759,12 @@ function getTime(time, opts) {
|
|
|
741
759
|
second
|
|
742
760
|
}, { pad: true, sep: opts.style.sep });
|
|
743
761
|
}
|
|
744
|
-
return twelveHourTime({ hour, minute, second, plain }, opts);
|
|
762
|
+
return twelveHourTime({ hour, minute, second, plain, explicit }, opts);
|
|
745
763
|
}
|
|
746
764
|
function twelveHourTime(time, opts) {
|
|
747
|
-
const { hour, minute, second, plain } = time;
|
|
765
|
+
const { hour, minute, second, plain, explicit } = time;
|
|
748
766
|
const style = opts.style;
|
|
749
|
-
if (!plain && +minute === 0 && !second) {
|
|
767
|
+
if (!plain && !explicit && +minute === 0 && !second) {
|
|
750
768
|
if (+hour === 0) {
|
|
751
769
|
return style.midnight;
|
|
752
770
|
}
|
|
@@ -756,7 +774,7 @@ function twelveHourTime(time, opts) {
|
|
|
756
774
|
}
|
|
757
775
|
const digits = clockDigits(
|
|
758
776
|
{ hour: hour % 12 || 12, minute, second },
|
|
759
|
-
{ lean:
|
|
777
|
+
{ lean: !explicit, sep: style.sep }
|
|
760
778
|
);
|
|
761
779
|
return digits + (style.closeUp ? "" : " ") + (hour < 12 ? style.am : style.pm);
|
|
762
780
|
}
|
|
@@ -779,7 +797,7 @@ function getOrdinal(n) {
|
|
|
779
797
|
return n + suffix;
|
|
780
798
|
}
|
|
781
799
|
function getMonth(m, opts) {
|
|
782
|
-
const month = monthNames[m]
|
|
800
|
+
const month = monthNames[+m];
|
|
783
801
|
return month && month[opts.short ? 1 : 0];
|
|
784
802
|
}
|
|
785
803
|
function getWeekday(d, opts) {
|
|
@@ -792,7 +810,9 @@ var en = {
|
|
|
792
810
|
fallback: "an unrecognizable cron pattern",
|
|
793
811
|
options: normalizeOptions,
|
|
794
812
|
reboot: "at system startup",
|
|
795
|
-
|
|
813
|
+
// A description ending in an abbreviation already carries its period
|
|
814
|
+
// ("…9 a.m."), so closing the sentence must not double it.
|
|
815
|
+
sentence: (description) => "Runs " + description + (description.endsWith(".") ? "" : ".")
|
|
796
816
|
};
|
|
797
817
|
var index_default = en;
|
|
798
818
|
export {
|