cronli5 0.0.0-beta.6 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +276 -0
- package/LICENSE.md +2 -2
- package/README.md +328 -91
- package/cli.js +73 -10
- package/cronli5.min.js +3 -0
- package/dist/cronli5.cjs +1556 -0
- package/dist/cronli5.js +1532 -0
- package/dist/lang/de.cjs +546 -0
- package/dist/lang/de.js +522 -0
- package/dist/lang/en.cjs +830 -0
- package/dist/lang/en.js +806 -0
- package/dist/lang/es.cjs +1024 -0
- package/dist/lang/es.js +1000 -0
- package/dist/lang/fi.cjs +942 -0
- package/dist/lang/fi.js +918 -0
- package/dist/lang/zh.cjs +612 -0
- package/dist/lang/zh.js +588 -0
- package/package.json +92 -13
- package/src/browser.ts +9 -0
- package/src/core/analyze.ts +549 -0
- package/src/core/format.ts +51 -0
- package/src/core/index.ts +28 -0
- package/src/core/ir.ts +167 -0
- package/src/core/normalize.ts +143 -0
- package/src/core/parse.ts +132 -0
- package/src/core/shapes.ts +41 -0
- package/src/core/specs.ts +93 -0
- package/src/core/util.ts +28 -0
- package/src/core/validate.ts +170 -0
- package/src/cronli5.ts +95 -0
- package/src/lang/de/dialects.ts +52 -0
- package/src/lang/de/index.ts +820 -0
- package/src/lang/de/notes.md +79 -0
- package/src/lang/de/status.json +18 -0
- package/src/lang/en/dialects.ts +70 -0
- package/src/lang/en/index.ts +1290 -0
- package/src/lang/en/notes.md +44 -0
- package/src/lang/en/status.json +20 -0
- package/src/lang/es/dialects.ts +55 -0
- package/src/lang/es/index.ts +1737 -0
- package/src/lang/es/notes.md +63 -0
- package/src/lang/es/status.json +19 -0
- package/src/lang/fi/dialects.ts +31 -0
- package/src/lang/fi/index.ts +1499 -0
- package/src/lang/fi/notes.md +163 -0
- package/src/lang/fi/status.json +7 -0
- package/src/lang/zh/dialects.ts +27 -0
- package/src/lang/zh/index.ts +863 -0
- package/src/lang/zh/notes.md +118 -0
- package/src/lang/zh/status.json +7 -0
- package/src/types.ts +143 -0
- package/types/browser.d.ts +2 -0
- package/types/core/analyze.d.ts +13 -0
- package/types/core/format.d.ts +16 -0
- package/types/core/index.d.ts +8 -0
- package/types/core/ir.d.ts +185 -0
- package/types/core/normalize.d.ts +5 -0
- package/types/core/parse.d.ts +5 -0
- package/types/core/shapes.d.ts +6 -0
- package/types/core/specs.d.ts +27 -0
- package/types/core/util.d.ts +7 -0
- package/types/core/validate.d.ts +5 -0
- package/types/cronli5.d.ts +7 -0
- package/types/lang/de/dialects.d.ts +7 -0
- package/types/lang/de/index.d.ts +4 -0
- package/types/lang/en/dialects.d.ts +4 -0
- package/types/lang/en/index.d.ts +3 -0
- package/types/lang/es/dialects.d.ts +13 -0
- package/types/lang/es/index.d.ts +4 -0
- package/types/lang/fi/dialects.d.ts +4 -0
- package/types/lang/fi/index.d.ts +3 -0
- package/types/lang/zh/dialects.d.ts +6 -0
- package/types/lang/zh/index.d.ts +4 -0
- package/types/types.d.ts +113 -0
- package/.eslintrc.json +0 -217
- package/.npmignore +0 -2
- package/conli5.min.js +0 -4
- package/cronli5.js +0 -559
- package/test/.eslintrc.json +0 -10
- package/test/bad_input/arrays.js +0 -34
- package/test/bad_input/bad-types.js +0 -33
- package/test/bad_input/error-types.js +0 -7
- package/test/bad_input/objects.js +0 -47
- package/test/bad_input/strings.js +0 -10
- package/test/baseline/baseline.js +0 -14
- package/test/basic/arrays.js +0 -76
- package/test/basic/objects.js +0 -70
- package/test/basic/strings.js +0 -76
- package/test/complex/steps/strings.js +0 -42
- package/test/mocha.opts +0 -5
- package/test/options/ampm.js +0 -17
- package/test/options/seconds.js +0 -0
- package/test/options/short.js +0 -27
- package/test/options/years.js +0 -0
- package/test/runner.js +0 -52
- package/test/simple/arrays.js +0 -33
- package/test/simple/objects.js +0 -23
- package/test/simple/strings.js +0 -33
package/dist/lang/en.cjs
ADDED
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/lang/en/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
default: () => index_default
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/core/format.ts
|
|
28
|
+
function pad(n) {
|
|
29
|
+
n = "" + n;
|
|
30
|
+
return n.length < 2 ? "0" + n : n;
|
|
31
|
+
}
|
|
32
|
+
function numeral(n, words, opts) {
|
|
33
|
+
return opts.short ? n : words[n] || n;
|
|
34
|
+
}
|
|
35
|
+
function clockDigits(time, { sep, pad: padHour, lean }) {
|
|
36
|
+
const head = padHour ? pad(time.hour) : "" + time.hour;
|
|
37
|
+
if (lean && !time.minute && !time.second) {
|
|
38
|
+
return head;
|
|
39
|
+
}
|
|
40
|
+
return head + sep + pad(time.minute) + (time.second ? sep + pad(time.second) : "");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// src/lang/en/dialects.ts
|
|
44
|
+
var dialects = {
|
|
45
|
+
gb: {
|
|
46
|
+
am: "am",
|
|
47
|
+
closeUp: true,
|
|
48
|
+
dayFirst: true,
|
|
49
|
+
midday: "midday",
|
|
50
|
+
midnight: "midnight",
|
|
51
|
+
ordinals: false,
|
|
52
|
+
pm: "pm",
|
|
53
|
+
sep: ".",
|
|
54
|
+
serialComma: false,
|
|
55
|
+
through: " to "
|
|
56
|
+
},
|
|
57
|
+
us: {
|
|
58
|
+
am: "a.m.",
|
|
59
|
+
closeUp: false,
|
|
60
|
+
dayFirst: false,
|
|
61
|
+
midday: "noon",
|
|
62
|
+
midnight: "midnight",
|
|
63
|
+
ordinals: false,
|
|
64
|
+
pm: "p.m.",
|
|
65
|
+
sep: ":",
|
|
66
|
+
serialComma: true,
|
|
67
|
+
through: " through "
|
|
68
|
+
},
|
|
69
|
+
house: {
|
|
70
|
+
am: "AM",
|
|
71
|
+
closeUp: false,
|
|
72
|
+
dayFirst: false,
|
|
73
|
+
midday: "noon",
|
|
74
|
+
midnight: "midnight",
|
|
75
|
+
ordinals: true,
|
|
76
|
+
pm: "PM",
|
|
77
|
+
sep: ":",
|
|
78
|
+
serialComma: true,
|
|
79
|
+
through: " - "
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
function resolveDialect(dialect) {
|
|
83
|
+
if (typeof dialect === "object" && dialect !== null) {
|
|
84
|
+
return { ...dialects.us, ...dialect };
|
|
85
|
+
}
|
|
86
|
+
const name = dialect === "uk" ? "gb" : dialect;
|
|
87
|
+
return dialects[name] || dialects.us;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// src/lang/en/index.ts
|
|
91
|
+
var numbers = [
|
|
92
|
+
"zero",
|
|
93
|
+
"one",
|
|
94
|
+
"two",
|
|
95
|
+
"three",
|
|
96
|
+
"four",
|
|
97
|
+
"five",
|
|
98
|
+
"six",
|
|
99
|
+
"seven",
|
|
100
|
+
"eight",
|
|
101
|
+
"nine",
|
|
102
|
+
"ten"
|
|
103
|
+
];
|
|
104
|
+
var suffixes = [
|
|
105
|
+
"th",
|
|
106
|
+
"st",
|
|
107
|
+
"nd",
|
|
108
|
+
"rd"
|
|
109
|
+
];
|
|
110
|
+
var monthNames = [
|
|
111
|
+
null,
|
|
112
|
+
["January", "Jan"],
|
|
113
|
+
["February", "Feb"],
|
|
114
|
+
["March", "Mar"],
|
|
115
|
+
["April", "Apr"],
|
|
116
|
+
["May", "May"],
|
|
117
|
+
["June", "Jun"],
|
|
118
|
+
["July", "Jul"],
|
|
119
|
+
["August", "Aug"],
|
|
120
|
+
["September", "Sep"],
|
|
121
|
+
["October", "Oct"],
|
|
122
|
+
["November", "Nov"],
|
|
123
|
+
["December", "Dec"]
|
|
124
|
+
];
|
|
125
|
+
var weekdayNames = [
|
|
126
|
+
["Sunday", "Sun"],
|
|
127
|
+
["Monday", "Mon"],
|
|
128
|
+
["Tuesday", "Tue"],
|
|
129
|
+
["Wednesday", "Wed"],
|
|
130
|
+
["Thursday", "Thu"],
|
|
131
|
+
["Friday", "Fri"],
|
|
132
|
+
["Saturday", "Sat"]
|
|
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
|
+
var weekdayAbbreviations = {
|
|
149
|
+
SUN: weekdayNames[0],
|
|
150
|
+
MON: weekdayNames[1],
|
|
151
|
+
TUE: weekdayNames[2],
|
|
152
|
+
WED: weekdayNames[3],
|
|
153
|
+
THU: weekdayNames[4],
|
|
154
|
+
FRI: weekdayNames[5],
|
|
155
|
+
SAT: weekdayNames[6]
|
|
156
|
+
};
|
|
157
|
+
var nthWeekdayNames = [null, "first", "second", "third", "fourth", "fifth"];
|
|
158
|
+
function normalizeOptions(options) {
|
|
159
|
+
options = options || {};
|
|
160
|
+
return {
|
|
161
|
+
ampm: typeof options.ampm === "boolean" ? options.ampm : true,
|
|
162
|
+
lenient: !!options.lenient,
|
|
163
|
+
seconds: !!options.seconds,
|
|
164
|
+
short: !!options.short,
|
|
165
|
+
style: resolveDialect(options.dialect),
|
|
166
|
+
years: !!options.years
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
function describe(ir, opts) {
|
|
170
|
+
return applyYear(render(ir, ir.plan, opts), ir, opts);
|
|
171
|
+
}
|
|
172
|
+
function render(ir, plan, opts) {
|
|
173
|
+
const renderer = renderers[plan.kind];
|
|
174
|
+
return renderer(ir, plan, opts);
|
|
175
|
+
}
|
|
176
|
+
function renderEverySecond(ir, plan, opts) {
|
|
177
|
+
return "every second" + trailingQualifier(ir, opts);
|
|
178
|
+
}
|
|
179
|
+
function renderStandaloneSeconds(ir, plan, opts) {
|
|
180
|
+
return secondsLeadClause(ir, opts) + trailingQualifier(ir, opts);
|
|
181
|
+
}
|
|
182
|
+
function renderSecondPastMinute(ir, plan, opts) {
|
|
183
|
+
const secondField = ir.pattern.second;
|
|
184
|
+
return getNumber(secondField, opts) + " " + pluralize(secondField, "second") + " past the minute, every minute" + trailingQualifier(ir, opts);
|
|
185
|
+
}
|
|
186
|
+
function renderSecondsWithinMinute(ir, plan, opts) {
|
|
187
|
+
const minuteField = ir.pattern.minute;
|
|
188
|
+
const minuteWord = getNumber(minuteField, opts);
|
|
189
|
+
const minuteUnit = pluralize(minuteField, "minute");
|
|
190
|
+
if (plan.singleSecond) {
|
|
191
|
+
const secondField = ir.pattern.second;
|
|
192
|
+
return minuteWord + " " + minuteUnit + " and " + getNumber(secondField, opts) + " " + pluralize(secondField, "second") + " past the hour, every hour" + trailingQualifier(ir, opts);
|
|
193
|
+
}
|
|
194
|
+
return secondsLeadClause(ir, opts) + ", " + minuteWord + " " + minuteUnit + " past the hour, every hour" + trailingQualifier(ir, opts);
|
|
195
|
+
}
|
|
196
|
+
function renderComposeSeconds(ir, plan, opts) {
|
|
197
|
+
return secondsLeadClause(ir, opts) + ", " + render(ir, plan.rest, opts);
|
|
198
|
+
}
|
|
199
|
+
function secondsLeadClause(ir, opts) {
|
|
200
|
+
const secondField = ir.pattern.second;
|
|
201
|
+
const shape = ir.shapes.second;
|
|
202
|
+
if (secondField === "*") {
|
|
203
|
+
return "every second";
|
|
204
|
+
}
|
|
205
|
+
if (shape === "step") {
|
|
206
|
+
return stepCycle60(
|
|
207
|
+
ir.analyses.segments.second[0],
|
|
208
|
+
"second",
|
|
209
|
+
"minute",
|
|
210
|
+
opts
|
|
211
|
+
);
|
|
212
|
+
}
|
|
213
|
+
if (shape === "range") {
|
|
214
|
+
const bounds = secondField.split("-");
|
|
215
|
+
const num = seriesNumber(bounds, opts);
|
|
216
|
+
return "every second from " + num(bounds[0]) + through(opts) + num(bounds[1]) + " past the minute";
|
|
217
|
+
}
|
|
218
|
+
if (shape === "single") {
|
|
219
|
+
return "at " + getNumber(secondField, opts) + " " + pluralize(secondField, "second") + " past the minute";
|
|
220
|
+
}
|
|
221
|
+
return listPastThe(
|
|
222
|
+
segmentWords(ir.analyses.segments.second, opts),
|
|
223
|
+
"second",
|
|
224
|
+
"minute",
|
|
225
|
+
opts
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
function renderEveryMinute(ir, plan, opts) {
|
|
229
|
+
return "every minute" + trailingQualifier(ir, opts);
|
|
230
|
+
}
|
|
231
|
+
function renderSingleMinute(ir, plan, opts) {
|
|
232
|
+
const minuteField = ir.pattern.minute;
|
|
233
|
+
return getNumber(minuteField, opts) + " " + pluralize(minuteField, "minute") + " past the hour, every hour" + trailingQualifier(ir, opts);
|
|
234
|
+
}
|
|
235
|
+
function renderRangeOfMinutes(ir, plan, opts) {
|
|
236
|
+
return minuteRangeLead(ir.pattern.minute, opts) + trailingQualifier(ir, opts);
|
|
237
|
+
}
|
|
238
|
+
function renderMultipleMinutes(ir, plan, opts) {
|
|
239
|
+
return listPastThe(
|
|
240
|
+
segmentWords(ir.analyses.segments.minute, opts),
|
|
241
|
+
"minute",
|
|
242
|
+
"hour",
|
|
243
|
+
opts
|
|
244
|
+
) + trailingQualifier(ir, opts);
|
|
245
|
+
}
|
|
246
|
+
function renderMinuteFrequency(ir, plan, opts) {
|
|
247
|
+
let phrase = stepCycle60(
|
|
248
|
+
ir.analyses.segments.minute[0],
|
|
249
|
+
"minute",
|
|
250
|
+
"hour",
|
|
251
|
+
opts
|
|
252
|
+
);
|
|
253
|
+
if (plan.hours.kind === "during") {
|
|
254
|
+
phrase += " during the " + hourTimesFromPlan(ir, plan.hours.times, false, opts) + " hours";
|
|
255
|
+
} else if (plan.hours.kind === "window") {
|
|
256
|
+
phrase += " " + hourWindow(plan.hours, opts);
|
|
257
|
+
} else if (plan.hours.kind === "step") {
|
|
258
|
+
phrase += " " + everyNthHour(ir.analyses.segments.hour[0], opts);
|
|
259
|
+
}
|
|
260
|
+
return phrase + trailingQualifier(ir, opts);
|
|
261
|
+
}
|
|
262
|
+
function renderMinuteSpanInHour(ir, plan, opts) {
|
|
263
|
+
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
|
+
}
|
|
265
|
+
function renderMinutesAcrossHours(ir, plan, opts) {
|
|
266
|
+
if (plan.form === "wildcard") {
|
|
267
|
+
return "every minute during the " + hourTimesFromPlan(ir, plan.times, false, opts) + " hours" + trailingQualifier(ir, opts);
|
|
268
|
+
}
|
|
269
|
+
const times = hourTimesFromPlan(ir, plan.times, true, opts);
|
|
270
|
+
const lead = plan.form === "range" ? minuteRangeLead(ir.pattern.minute, opts) : (
|
|
271
|
+
// The 'list' form is a minute list, which has segments.
|
|
272
|
+
listPastThe(
|
|
273
|
+
segmentWords(ir.analyses.segments.minute, opts),
|
|
274
|
+
"minute",
|
|
275
|
+
"hour",
|
|
276
|
+
opts
|
|
277
|
+
)
|
|
278
|
+
);
|
|
279
|
+
return lead + ", at " + times + trailingQualifier(ir, opts);
|
|
280
|
+
}
|
|
281
|
+
var stepOrdinals = {
|
|
282
|
+
2: "other",
|
|
283
|
+
3: "third",
|
|
284
|
+
4: "fourth",
|
|
285
|
+
6: "sixth",
|
|
286
|
+
8: "eighth",
|
|
287
|
+
12: "twelfth"
|
|
288
|
+
};
|
|
289
|
+
function everyNthHour(segment, opts) {
|
|
290
|
+
const base = "during every " + stepOrdinals[segment.interval] + " hour";
|
|
291
|
+
const start = segment.startToken === "*" ? 0 : +segment.startToken;
|
|
292
|
+
return start === 0 ? base : base + " starting at " + getTime({ hour: start, minute: 0 }, opts);
|
|
293
|
+
}
|
|
294
|
+
function renderMinuteSpanAcrossHourStep(ir, plan, opts) {
|
|
295
|
+
const segment = ir.analyses.segments.hour[0];
|
|
296
|
+
if (plan.form === "wildcard") {
|
|
297
|
+
return "every minute " + everyNthHour(segment, opts) + trailingQualifier(ir, opts);
|
|
298
|
+
}
|
|
299
|
+
return minuteRangeLead(ir.pattern.minute, opts) + ", " + stepHours(segment, opts) + trailingQualifier(ir, opts);
|
|
300
|
+
}
|
|
301
|
+
function minuteRangeLead(minuteField, opts) {
|
|
302
|
+
const bounds = minuteField.split("-");
|
|
303
|
+
const num = seriesNumber(bounds, opts);
|
|
304
|
+
return "every minute from " + num(bounds[0]) + through(opts) + num(bounds[1]) + " past the hour";
|
|
305
|
+
}
|
|
306
|
+
function renderEveryHour(ir, plan, opts) {
|
|
307
|
+
return "every hour" + trailingQualifier(ir, opts);
|
|
308
|
+
}
|
|
309
|
+
function renderHourRange(ir, plan, opts) {
|
|
310
|
+
const window = hourWindow(plan, opts);
|
|
311
|
+
if (plan.minuteForm === "wildcard") {
|
|
312
|
+
return "every minute " + window + trailingQualifier(ir, opts);
|
|
313
|
+
}
|
|
314
|
+
if (plan.minuteForm === "range") {
|
|
315
|
+
return minuteRangeLead(ir.pattern.minute, opts) + ", " + window + trailingQualifier(ir, opts);
|
|
316
|
+
}
|
|
317
|
+
return rangeMinuteLead(ir, opts) + " " + window + trailingQualifier(ir, opts);
|
|
318
|
+
}
|
|
319
|
+
function rangeMinuteLead(ir, opts) {
|
|
320
|
+
if (ir.pattern.minute === "0") {
|
|
321
|
+
return "every hour";
|
|
322
|
+
}
|
|
323
|
+
return listPastThe(
|
|
324
|
+
segmentWords(ir.analyses.segments.minute, opts),
|
|
325
|
+
"minute",
|
|
326
|
+
"hour",
|
|
327
|
+
opts
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
function renderHourStep(ir, plan, opts) {
|
|
331
|
+
return stepHours(ir.analyses.segments.hour[0], opts) + trailingQualifier(ir, opts);
|
|
332
|
+
}
|
|
333
|
+
function hourWindow(window, opts) {
|
|
334
|
+
return "from " + getTime({ hour: window.from, minute: 0 }, opts) + through(opts) + getTime({ hour: window.to, minute: window.last }, opts);
|
|
335
|
+
}
|
|
336
|
+
function renderClockTimes(ir, plan, opts) {
|
|
337
|
+
const plain = mixedTwelve(plan.times);
|
|
338
|
+
const times = plan.times.map(function clock(time) {
|
|
339
|
+
return getTime({
|
|
340
|
+
hour: time.hour,
|
|
341
|
+
minute: time.minute,
|
|
342
|
+
second: time.second,
|
|
343
|
+
plain
|
|
344
|
+
}, opts);
|
|
345
|
+
});
|
|
346
|
+
return interpretDayQualifier(ir, opts) + "at " + joinList(times, opts);
|
|
347
|
+
}
|
|
348
|
+
function renderCompactClockTimes(ir, plan, opts) {
|
|
349
|
+
if (plan.fold) {
|
|
350
|
+
const hasRange = ir.analyses.segments.hour.some(function range(segment) {
|
|
351
|
+
return segment.kind === "range";
|
|
352
|
+
});
|
|
353
|
+
if (hasRange && !ir.analyses.clockSecond) {
|
|
354
|
+
return foldedHourWindows(ir, plan, opts) + trailingQualifier(ir, opts);
|
|
355
|
+
}
|
|
356
|
+
const fold = { minute: plan.minute, second: ir.analyses.clockSecond };
|
|
357
|
+
return interpretDayQualifier(ir, opts) + "at " + hourSegmentTimes(ir, fold, true, opts);
|
|
358
|
+
}
|
|
359
|
+
const phrase = (
|
|
360
|
+
// The non-fold branch is a minute list, which has segments.
|
|
361
|
+
listPastThe(
|
|
362
|
+
segmentWords(ir.analyses.segments.minute, opts),
|
|
363
|
+
"minute",
|
|
364
|
+
"hour",
|
|
365
|
+
opts
|
|
366
|
+
) + ", at " + hourSegmentTimes(ir, { minute: 0, second: null }, true, opts) + trailingQualifier(ir, opts)
|
|
367
|
+
);
|
|
368
|
+
return ir.analyses.clockSecond ? secondsLeadClause(ir, opts) + ", " + phrase : phrase;
|
|
369
|
+
}
|
|
370
|
+
function foldedHourWindows(ir, plan, opts) {
|
|
371
|
+
const minute = plan.minute;
|
|
372
|
+
const windows = [];
|
|
373
|
+
const singles = [];
|
|
374
|
+
ir.analyses.segments.hour.forEach(function classify(segment) {
|
|
375
|
+
if (segment.kind === "range") {
|
|
376
|
+
windows.push("from " + getTime(
|
|
377
|
+
{ hour: segment.bounds[0], minute: 0 },
|
|
378
|
+
opts
|
|
379
|
+
) + through(opts) + getTime({ hour: segment.bounds[1], minute }, opts));
|
|
380
|
+
} else if (segment.kind === "step") {
|
|
381
|
+
singles.push(...segment.fires);
|
|
382
|
+
} else {
|
|
383
|
+
singles.push(+segment.value);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
let phrase = rangeMinuteLead(ir, opts) + " " + joinList(windows, opts);
|
|
387
|
+
if (singles.length) {
|
|
388
|
+
phrase += " and at " + joinList(singles.map(function time(hour) {
|
|
389
|
+
return getTime({ hour, minute }, opts);
|
|
390
|
+
}), opts);
|
|
391
|
+
}
|
|
392
|
+
return phrase;
|
|
393
|
+
}
|
|
394
|
+
var renderers = {
|
|
395
|
+
clockTimes: renderClockTimes,
|
|
396
|
+
compactClockTimes: renderCompactClockTimes,
|
|
397
|
+
composeSeconds: renderComposeSeconds,
|
|
398
|
+
everyHour: renderEveryHour,
|
|
399
|
+
everyMinute: renderEveryMinute,
|
|
400
|
+
everySecond: renderEverySecond,
|
|
401
|
+
hourRange: renderHourRange,
|
|
402
|
+
hourStep: renderHourStep,
|
|
403
|
+
minuteFrequency: renderMinuteFrequency,
|
|
404
|
+
minuteSpanAcrossHourStep: renderMinuteSpanAcrossHourStep,
|
|
405
|
+
minuteSpanInHour: renderMinuteSpanInHour,
|
|
406
|
+
minutesAcrossHours: renderMinutesAcrossHours,
|
|
407
|
+
multipleMinutes: renderMultipleMinutes,
|
|
408
|
+
rangeOfMinutes: renderRangeOfMinutes,
|
|
409
|
+
secondPastMinute: renderSecondPastMinute,
|
|
410
|
+
secondsWithinMinute: renderSecondsWithinMinute,
|
|
411
|
+
singleMinute: renderSingleMinute,
|
|
412
|
+
standaloneSeconds: renderStandaloneSeconds
|
|
413
|
+
};
|
|
414
|
+
function stepCycle60(segment, unit, anchor, opts) {
|
|
415
|
+
if (segment.startToken.indexOf("-") !== -1) {
|
|
416
|
+
return listPastThe(numberWords(segment.fires, opts), unit, anchor, opts);
|
|
417
|
+
}
|
|
418
|
+
const start = segment.startToken === "*" ? 0 : +segment.startToken;
|
|
419
|
+
const interval = segment.interval;
|
|
420
|
+
if (start !== 0) {
|
|
421
|
+
if (segment.fires.length <= 3) {
|
|
422
|
+
return listPastThe(
|
|
423
|
+
numberWords(segment.fires, opts),
|
|
424
|
+
unit,
|
|
425
|
+
anchor,
|
|
426
|
+
opts
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
return "every " + getNumber(interval, opts) + " " + unit + "s from " + getNumber(start, opts) + " " + pluralize(start, unit) + " past the " + anchor;
|
|
430
|
+
}
|
|
431
|
+
if (60 % interval === 0) {
|
|
432
|
+
return "every " + getNumber(interval, opts) + " " + unit + "s";
|
|
433
|
+
}
|
|
434
|
+
if (segment.fires.length <= 2) {
|
|
435
|
+
return listPastThe(numberWords(segment.fires, opts), unit, anchor, opts);
|
|
436
|
+
}
|
|
437
|
+
return "every " + getNumber(interval, opts) + " " + unit + "s past the " + anchor;
|
|
438
|
+
}
|
|
439
|
+
function stepHours(segment, opts) {
|
|
440
|
+
if (segment.startToken.indexOf("-") !== -1) {
|
|
441
|
+
return "at " + hourTimes(segment.fires, opts);
|
|
442
|
+
}
|
|
443
|
+
const start = segment.startToken === "*" ? 0 : +segment.startToken;
|
|
444
|
+
const interval = segment.interval;
|
|
445
|
+
if (start === 0 && 24 % interval === 0) {
|
|
446
|
+
return "every " + getNumber(interval, opts) + " hours";
|
|
447
|
+
}
|
|
448
|
+
if (segment.fires.length <= 3) {
|
|
449
|
+
return "at " + hourTimes(segment.fires, opts);
|
|
450
|
+
}
|
|
451
|
+
if (start === 0) {
|
|
452
|
+
return "every " + getNumber(interval, opts) + " hours from midnight";
|
|
453
|
+
}
|
|
454
|
+
return "every " + getNumber(interval, opts) + " hours from " + getTime({ hour: start, minute: 0 }, opts);
|
|
455
|
+
}
|
|
456
|
+
function seriesNumber(values, opts) {
|
|
457
|
+
const anyBig = values.some(function big(v) {
|
|
458
|
+
return +v > 10;
|
|
459
|
+
});
|
|
460
|
+
return function format(n) {
|
|
461
|
+
return anyBig ? "" + n : getNumber(n, opts);
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
function numberWords(fires, opts) {
|
|
465
|
+
return fires.map(seriesNumber(fires, opts));
|
|
466
|
+
}
|
|
467
|
+
function segmentWords(segments, opts) {
|
|
468
|
+
const values = segments.flatMap(function collect(segment) {
|
|
469
|
+
if (segment.kind === "range") {
|
|
470
|
+
return segment.bounds;
|
|
471
|
+
}
|
|
472
|
+
return segment.kind === "step" ? segment.fires : [segment.value];
|
|
473
|
+
});
|
|
474
|
+
const num = seriesNumber(values, opts);
|
|
475
|
+
return segments.flatMap(function word(segment) {
|
|
476
|
+
if (segment.kind === "range") {
|
|
477
|
+
return [num(segment.bounds[0]) + through(opts) + num(segment.bounds[1])];
|
|
478
|
+
}
|
|
479
|
+
if (segment.kind === "step") {
|
|
480
|
+
return segment.fires.map(num);
|
|
481
|
+
}
|
|
482
|
+
return [num(segment.value)];
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
function listPastThe(words, unit, anchor, opts) {
|
|
486
|
+
return "at " + joinList(words, opts) + " " + unit + "s past the " + anchor;
|
|
487
|
+
}
|
|
488
|
+
function wordTime(hour, minute, second) {
|
|
489
|
+
return (+hour === 0 || +hour === 12) && +minute === 0 && !(typeof second === "number" && second > 0);
|
|
490
|
+
}
|
|
491
|
+
function mixedTwelve(entries) {
|
|
492
|
+
const words = entries.filter(function word(e) {
|
|
493
|
+
return wordTime(e.hour, e.minute, e.second);
|
|
494
|
+
});
|
|
495
|
+
return words.length > 0 && words.length < entries.length;
|
|
496
|
+
}
|
|
497
|
+
function hourTimes(hours, opts) {
|
|
498
|
+
const plain = mixedTwelve(hours.map(function entry(hour) {
|
|
499
|
+
return { hour, minute: 0 };
|
|
500
|
+
}));
|
|
501
|
+
const times = hours.map(function clock(hour) {
|
|
502
|
+
return getTime({ hour, minute: 0, plain }, opts);
|
|
503
|
+
});
|
|
504
|
+
return joinList(times, opts);
|
|
505
|
+
}
|
|
506
|
+
function hourTimesFromPlan(ir, times, atContext, opts) {
|
|
507
|
+
if (times.kind === "fires") {
|
|
508
|
+
return hourTimes(times.fires, opts);
|
|
509
|
+
}
|
|
510
|
+
return hourSegmentTimes(ir, { minute: 0, second: null }, atContext, opts);
|
|
511
|
+
}
|
|
512
|
+
function segmentHours(segment) {
|
|
513
|
+
if (segment.kind === "range") {
|
|
514
|
+
return segment.bounds;
|
|
515
|
+
}
|
|
516
|
+
return segment.kind === "step" ? segment.fires : [segment.value];
|
|
517
|
+
}
|
|
518
|
+
function hourSegmentTimes(ir, fold, atContext, opts) {
|
|
519
|
+
const { minute, second } = fold;
|
|
520
|
+
const segments = ir.analyses.segments.hour;
|
|
521
|
+
const plain = mixedTwelve(segments.flatMap(function entries(segment) {
|
|
522
|
+
return segmentHours(segment).map(function entry(hour) {
|
|
523
|
+
return { hour: +hour, minute, second };
|
|
524
|
+
});
|
|
525
|
+
}));
|
|
526
|
+
const pieces = [];
|
|
527
|
+
segments.forEach(function clock(segment) {
|
|
528
|
+
if (segment.kind === "step") {
|
|
529
|
+
pieces.push(...segment.fires.map(function time(hour) {
|
|
530
|
+
return getTime({ hour, minute, second, plain }, opts);
|
|
531
|
+
}));
|
|
532
|
+
} else if (segment.kind === "range") {
|
|
533
|
+
pieces.push(
|
|
534
|
+
getTime({ hour: segment.bounds[0], minute, second, plain }, opts) + through(opts) + getTime({ hour: segment.bounds[1], minute, second, plain }, opts)
|
|
535
|
+
);
|
|
536
|
+
} else {
|
|
537
|
+
pieces.push(getTime({ hour: segment.value, minute, second, plain }, opts));
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
return joinList(disambiguateTimes(pieces, segments, atContext), opts);
|
|
541
|
+
}
|
|
542
|
+
function disambiguateTimes(pieces, segments, atContext) {
|
|
543
|
+
const hasRange = segments.some(function range(segment) {
|
|
544
|
+
return segment.kind === "range";
|
|
545
|
+
});
|
|
546
|
+
if (!atContext || !hasRange) {
|
|
547
|
+
return pieces;
|
|
548
|
+
}
|
|
549
|
+
return pieces.map(function at(piece, index) {
|
|
550
|
+
return index === 0 ? piece : "at " + piece;
|
|
551
|
+
});
|
|
552
|
+
}
|
|
553
|
+
function joinList(items, opts) {
|
|
554
|
+
if (items.length <= 1) {
|
|
555
|
+
return items.join("");
|
|
556
|
+
}
|
|
557
|
+
if (items.length === 2) {
|
|
558
|
+
return items[0] + " and " + items[1];
|
|
559
|
+
}
|
|
560
|
+
const and = opts.style.serialComma ? ", and " : " and ";
|
|
561
|
+
return items.slice(0, -1).join(", ") + and + items[items.length - 1];
|
|
562
|
+
}
|
|
563
|
+
var trailingWords = { all: "", month: "in ", stepDate: "on ", weekday: "on " };
|
|
564
|
+
var leadingWords = {
|
|
565
|
+
all: "every day",
|
|
566
|
+
month: "every day in ",
|
|
567
|
+
stepDate: "",
|
|
568
|
+
weekday: "every "
|
|
569
|
+
};
|
|
570
|
+
function trailingQualifier(ir, opts) {
|
|
571
|
+
const phrase = dayQualifier(ir, trailingWords, opts);
|
|
572
|
+
return phrase && " " + phrase;
|
|
573
|
+
}
|
|
574
|
+
function interpretDayQualifier(ir, opts) {
|
|
575
|
+
return dayQualifier(ir, leadingWords, opts) + " ";
|
|
576
|
+
}
|
|
577
|
+
function dayQualifier(ir, words, opts) {
|
|
578
|
+
const pattern = ir.pattern;
|
|
579
|
+
if (pattern.date !== "*" && pattern.weekday !== "*") {
|
|
580
|
+
return dateOrWeekday(ir, opts);
|
|
581
|
+
}
|
|
582
|
+
if (pattern.date !== "*") {
|
|
583
|
+
return datePhrase(ir, words, opts);
|
|
584
|
+
}
|
|
585
|
+
if (pattern.weekday !== "*") {
|
|
586
|
+
const weekdays = quartzWeekdayPhrase(pattern.weekday, opts) || words.weekday + weekdayPhrase(ir, opts);
|
|
587
|
+
return weekdays + monthScope(ir, opts);
|
|
588
|
+
}
|
|
589
|
+
if (pattern.month !== "*") {
|
|
590
|
+
return words.month + monthName(ir, opts);
|
|
591
|
+
}
|
|
592
|
+
return words.all;
|
|
593
|
+
}
|
|
594
|
+
function datePhrase(ir, words, opts) {
|
|
595
|
+
const pattern = ir.pattern;
|
|
596
|
+
const quartzDate = quartzDatePhrase(pattern.date, opts);
|
|
597
|
+
if (quartzDate) {
|
|
598
|
+
return quartzDate + monthScope(ir, opts);
|
|
599
|
+
}
|
|
600
|
+
if (isOpenStep(pattern.date)) {
|
|
601
|
+
return words.stepDate + stepDates(pattern.date) + monthScope(ir, opts);
|
|
602
|
+
}
|
|
603
|
+
if (pattern.month !== "*" && !monthFoldsIntoDate(ir)) {
|
|
604
|
+
return "on the " + dateOrdinals(ir, opts) + monthScope(ir, opts);
|
|
605
|
+
}
|
|
606
|
+
if (pattern.month !== "*") {
|
|
607
|
+
return "on " + monthDatePhrase(ir, opts);
|
|
608
|
+
}
|
|
609
|
+
return "on the " + dateOrdinals(ir, opts);
|
|
610
|
+
}
|
|
611
|
+
function monthFoldsIntoDate(ir) {
|
|
612
|
+
return !oddEvenMonth(ir.pattern.month) && // Reached only with a restricted month, which has segments.
|
|
613
|
+
ir.analyses.segments.month.every(function flat(segment) {
|
|
614
|
+
return segment.kind !== "range";
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
function dateOrWeekday(ir, opts) {
|
|
618
|
+
const pattern = ir.pattern;
|
|
619
|
+
const weekdayPart = quartzWeekdayPhrase(pattern.weekday, opts) || "on " + weekdayPhrase(ir, opts);
|
|
620
|
+
const quartzDate = quartzDatePhrase(pattern.date, opts);
|
|
621
|
+
if (quartzDate) {
|
|
622
|
+
return quartzDate + monthScope(ir, opts) + " or " + weekdayPart;
|
|
623
|
+
}
|
|
624
|
+
if (isOpenStep(pattern.date)) {
|
|
625
|
+
return stepDates(pattern.date) + monthScope(ir, opts) + " or " + weekdayPart;
|
|
626
|
+
}
|
|
627
|
+
if (pattern.month !== "*" && monthFoldsIntoDate(ir)) {
|
|
628
|
+
return "on " + monthDatePhrase(ir, opts) + " or " + weekdayPart + " in " + monthName(ir, opts);
|
|
629
|
+
}
|
|
630
|
+
return "on the " + dateOrdinals(ir, opts) + " or " + weekdayPart + monthScope(ir, opts);
|
|
631
|
+
}
|
|
632
|
+
function quartzDatePhrase(dateField, opts) {
|
|
633
|
+
if (dateField === "L") {
|
|
634
|
+
return "on the last day of the month";
|
|
635
|
+
}
|
|
636
|
+
if (dateField === "LW" || dateField === "WL") {
|
|
637
|
+
return "on the last weekday of the month";
|
|
638
|
+
}
|
|
639
|
+
const offset = /^L-(\d{1,2})$/.exec(dateField);
|
|
640
|
+
if (offset) {
|
|
641
|
+
return getNumber(+offset[1], opts) + " " + pluralize(offset[1], "day") + " before the last day of the month";
|
|
642
|
+
}
|
|
643
|
+
const nearest = /^(\d{1,2})W$|^W(\d{1,2})$/.exec(dateField);
|
|
644
|
+
if (nearest) {
|
|
645
|
+
return "on the weekday nearest the " + getOrdinal(nearest[1] || nearest[2]);
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
function quartzWeekdayPhrase(weekdayField, opts) {
|
|
649
|
+
const parts = weekdayField.split("#");
|
|
650
|
+
if (parts.length === 2) {
|
|
651
|
+
return "on the " + nthWeekdayNames[+parts[1]] + " " + getWeekday(parts[0], opts) + " of the month";
|
|
652
|
+
}
|
|
653
|
+
if (/L$/.test(weekdayField)) {
|
|
654
|
+
return "on the last " + getWeekday(weekdayField.slice(0, -1), opts) + " of the month";
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
function monthDatePhrase(ir, opts) {
|
|
658
|
+
const month = monthName(ir, opts);
|
|
659
|
+
const days = renderSegments(
|
|
660
|
+
ir.analyses.segments.date,
|
|
661
|
+
opts.style.ordinals ? getOrdinal : cardinalDay,
|
|
662
|
+
opts
|
|
663
|
+
);
|
|
664
|
+
return opts.style.dayFirst ? days + " " + month : month + " " + days;
|
|
665
|
+
}
|
|
666
|
+
function cardinalDay(value) {
|
|
667
|
+
return "" + value;
|
|
668
|
+
}
|
|
669
|
+
function monthScope(ir, opts) {
|
|
670
|
+
if (ir.pattern.month === "*") {
|
|
671
|
+
return "";
|
|
672
|
+
}
|
|
673
|
+
return " in " + monthName(ir, opts);
|
|
674
|
+
}
|
|
675
|
+
function stepDates(dateField) {
|
|
676
|
+
const parts = dateField.split("/");
|
|
677
|
+
const interval = +parts[1];
|
|
678
|
+
const start = parts[0];
|
|
679
|
+
const cadence = interval === 2 ? "every other" : "every " + getOrdinal(interval);
|
|
680
|
+
let phrase = cadence + " day of the month";
|
|
681
|
+
if (start !== "*" && start !== "1") {
|
|
682
|
+
phrase += " from the " + getOrdinal(start);
|
|
683
|
+
}
|
|
684
|
+
return phrase;
|
|
685
|
+
}
|
|
686
|
+
function dateOrdinals(ir, opts) {
|
|
687
|
+
return renderSegments(ir.analyses.segments.date, getOrdinal, opts);
|
|
688
|
+
}
|
|
689
|
+
function monthName(ir, opts) {
|
|
690
|
+
const oddEven = oddEvenMonth(ir.pattern.month);
|
|
691
|
+
if (oddEven) {
|
|
692
|
+
return oddEven;
|
|
693
|
+
}
|
|
694
|
+
return renderSegments(ir.analyses.segments.month, function name(value) {
|
|
695
|
+
return getMonth(value, opts);
|
|
696
|
+
}, opts);
|
|
697
|
+
}
|
|
698
|
+
function oddEvenMonth(monthField) {
|
|
699
|
+
if (!isOpenStep(monthField)) {
|
|
700
|
+
return null;
|
|
701
|
+
}
|
|
702
|
+
const [start, step] = monthField.split("/");
|
|
703
|
+
if (+step !== 2) {
|
|
704
|
+
return null;
|
|
705
|
+
}
|
|
706
|
+
if (start === "*" || start === "1") {
|
|
707
|
+
return "every odd-numbered month";
|
|
708
|
+
}
|
|
709
|
+
return start === "2" ? "every even-numbered month" : null;
|
|
710
|
+
}
|
|
711
|
+
function weekdayPhrase(ir, opts) {
|
|
712
|
+
return renderSegments(ir.analyses.segments.weekday, function name(value) {
|
|
713
|
+
return getWeekday(value, opts);
|
|
714
|
+
}, opts);
|
|
715
|
+
}
|
|
716
|
+
function renderSegments(segments, word, opts) {
|
|
717
|
+
const pieces = [];
|
|
718
|
+
segments.forEach(function expand(segment) {
|
|
719
|
+
if (segment.kind === "step") {
|
|
720
|
+
pieces.push(...segment.fires.map(word));
|
|
721
|
+
} else if (segment.kind === "range") {
|
|
722
|
+
pieces.push(segment.bounds.map(word).join(through(opts)));
|
|
723
|
+
} else {
|
|
724
|
+
pieces.push(word(segment.value));
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
return joinList(pieces, opts);
|
|
728
|
+
}
|
|
729
|
+
function isOpenStep(field) {
|
|
730
|
+
return field.indexOf("/") !== -1 && field.indexOf("-") === -1 && field.indexOf(",") === -1;
|
|
731
|
+
}
|
|
732
|
+
function applyYear(description, ir, opts) {
|
|
733
|
+
const yearField = ir.pattern.year;
|
|
734
|
+
if (yearField === "*") {
|
|
735
|
+
return description;
|
|
736
|
+
}
|
|
737
|
+
if (yearField.indexOf("/") !== -1) {
|
|
738
|
+
return description + " " + stepYears(yearField, opts);
|
|
739
|
+
}
|
|
740
|
+
const label = yearLabel(yearField, opts);
|
|
741
|
+
if (yearField.indexOf("-") === -1 && yearField.indexOf(",") === -1 && ir.pattern.date !== "*" && description.indexOf(" at ") !== -1) {
|
|
742
|
+
const yearGlue = opts.style.dayFirst ? " " : ", ";
|
|
743
|
+
return description.replace(" at ", yearGlue + label + " at ");
|
|
744
|
+
}
|
|
745
|
+
return description + " in " + label;
|
|
746
|
+
}
|
|
747
|
+
function yearLabel(yearField, opts) {
|
|
748
|
+
if (yearField.indexOf(",") !== -1) {
|
|
749
|
+
return joinList(yearField.split(","), opts);
|
|
750
|
+
}
|
|
751
|
+
return yearField;
|
|
752
|
+
}
|
|
753
|
+
function stepYears(yearField, opts) {
|
|
754
|
+
const parts = yearField.split("/");
|
|
755
|
+
const interval = +parts[1];
|
|
756
|
+
const start = parts[0];
|
|
757
|
+
if (interval <= 1) {
|
|
758
|
+
return "every year";
|
|
759
|
+
}
|
|
760
|
+
let phrase = "every " + getNumber(interval, opts) + " years";
|
|
761
|
+
if (start !== "*" && start !== "0") {
|
|
762
|
+
phrase += " from " + start;
|
|
763
|
+
}
|
|
764
|
+
return phrase;
|
|
765
|
+
}
|
|
766
|
+
function getTime(time, opts) {
|
|
767
|
+
const { hour, minute, plain } = time;
|
|
768
|
+
const second = typeof time.second === "number" && time.second > 0 ? time.second : 0;
|
|
769
|
+
if (!opts.ampm) {
|
|
770
|
+
return clockDigits({
|
|
771
|
+
hour,
|
|
772
|
+
minute,
|
|
773
|
+
second
|
|
774
|
+
}, { pad: true, sep: opts.style.sep });
|
|
775
|
+
}
|
|
776
|
+
return twelveHourTime({ hour, minute, second, plain }, opts);
|
|
777
|
+
}
|
|
778
|
+
function twelveHourTime(time, opts) {
|
|
779
|
+
const { hour, minute, second, plain } = time;
|
|
780
|
+
const style = opts.style;
|
|
781
|
+
if (!plain && +minute === 0 && !second) {
|
|
782
|
+
if (+hour === 0) {
|
|
783
|
+
return style.midnight;
|
|
784
|
+
}
|
|
785
|
+
if (+hour === 12) {
|
|
786
|
+
return style.midday;
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
const digits = clockDigits(
|
|
790
|
+
{ hour: hour % 12 || 12, minute, second },
|
|
791
|
+
{ lean: true, sep: style.sep }
|
|
792
|
+
);
|
|
793
|
+
return digits + (style.closeUp ? "" : " ") + (hour < 12 ? style.am : style.pm);
|
|
794
|
+
}
|
|
795
|
+
function getNumber(n, opts) {
|
|
796
|
+
return numeral(n, numbers, opts);
|
|
797
|
+
}
|
|
798
|
+
function pluralize(value, unit) {
|
|
799
|
+
return +value === 1 ? unit : unit + "s";
|
|
800
|
+
}
|
|
801
|
+
function through(opts) {
|
|
802
|
+
return opts.short ? "-" : opts.style.through;
|
|
803
|
+
}
|
|
804
|
+
function getOrdinal(n) {
|
|
805
|
+
let m = Math.abs(n);
|
|
806
|
+
let suffix = suffixes[m];
|
|
807
|
+
if (!suffix) {
|
|
808
|
+
m = (m % 100 - 20) % 10;
|
|
809
|
+
suffix = suffixes[m] || suffixes[0];
|
|
810
|
+
}
|
|
811
|
+
return n + suffix;
|
|
812
|
+
}
|
|
813
|
+
function getMonth(m, opts) {
|
|
814
|
+
const month = monthNames[m] || monthAbbreviations[m];
|
|
815
|
+
return month && month[opts.short ? 1 : 0];
|
|
816
|
+
}
|
|
817
|
+
function getWeekday(d, opts) {
|
|
818
|
+
const day = d === 7 || d === "7" ? 0 : d;
|
|
819
|
+
const weekday = weekdayNames[day] || weekdayAbbreviations[day];
|
|
820
|
+
return weekday && weekday[opts.short ? 1 : 0];
|
|
821
|
+
}
|
|
822
|
+
var en = {
|
|
823
|
+
describe,
|
|
824
|
+
fallback: "an unrecognizable cron pattern",
|
|
825
|
+
options: normalizeOptions,
|
|
826
|
+
reboot: "at system startup",
|
|
827
|
+
sentence: (description) => "Runs " + description + "."
|
|
828
|
+
};
|
|
829
|
+
var index_default = en;
|
|
830
|
+
module.exports = module.exports.default;
|