cronli5 0.7.2 → 0.8.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 +23 -0
- package/README.md +24 -7
- package/cronli5.min.js +2 -2
- package/dist/cronli5.cjs +59 -3
- package/dist/cronli5.js +59 -3
- package/dist/lang/de.cjs +1 -0
- package/dist/lang/de.js +1 -0
- package/dist/lang/en.cjs +1 -0
- package/dist/lang/en.js +1 -0
- package/dist/lang/es.cjs +1 -0
- package/dist/lang/es.js +1 -0
- package/dist/lang/fi.cjs +1 -0
- package/dist/lang/fi.js +1 -0
- package/dist/lang/fr.cjs +1 -0
- package/dist/lang/fr.js +1 -0
- package/dist/lang/pt.cjs +1 -0
- package/dist/lang/pt.js +1 -0
- package/dist/lang/zh.cjs +1 -0
- package/dist/lang/zh.js +1 -0
- package/package.json +1 -1
- package/src/core/index.ts +7 -3
- package/src/core/quartz.ts +97 -0
- package/src/core/schedule.ts +1 -0
- package/src/core/specs.ts +2 -2
- package/src/cronli5.ts +20 -3
- package/src/lang/de/index.ts +1 -0
- package/src/lang/en/index.ts +1 -0
- package/src/lang/es/index.ts +1 -0
- package/src/lang/fi/index.ts +1 -0
- package/src/lang/fr/index.ts +1 -0
- package/src/lang/pt/index.ts +1 -0
- package/src/lang/zh/index.ts +1 -0
- package/src/types.ts +44 -0
- package/types/core/quartz.d.ts +4 -0
- package/types/core/schedule.d.ts +1 -0
- package/types/cronli5.d.ts +4 -4
- package/types/types.d.ts +39 -0
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,29 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
8
|
|
|
9
|
+
## [0.8.0]
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- **`quartz` option.** `cronli5(pattern, { quartz: true })` reads the schedule as
|
|
14
|
+
Quartz: day-of-week is `1`=Sunday … `7`=Saturday (so `0 0 ? * 2` is **Monday**),
|
|
15
|
+
with the DOW-indexed operators (`6L`, `2#2`) and `?` following Quartz. Without
|
|
16
|
+
it, day-of-week stays standard cron (`0`/`7`=Sun, `1`=Mon).
|
|
17
|
+
- **`cronli5.sentence(expr, opts)` and `cronli5.fragment(expr, opts)`** —
|
|
18
|
+
convenience methods on the callable: `.sentence()` returns the capitalized
|
|
19
|
+
standalone ("Runs …."), `.fragment()` the embeddable lowercase fragment (the
|
|
20
|
+
default). Sugar over the `{ sentence }` option. (Deliberately no `toString`
|
|
21
|
+
method — it would collide with `Function.prototype.toString`.)
|
|
22
|
+
|
|
23
|
+
### Changed
|
|
24
|
+
|
|
25
|
+
- **Breaking: `?` now requires `{ quartz: true }`.** Previously `?` was silently
|
|
26
|
+
treated as `*` while day-of-week used standard indexing, so a genuine Quartz
|
|
27
|
+
cron like `0 0 ? * 2` rendered "every Tuesday" when the author meant Monday.
|
|
28
|
+
`?` (mandatory in Quartz, absent in standard cron) now throws a clear
|
|
29
|
+
`pass { quartz: true }` error by default — eliminating silent wrong output.
|
|
30
|
+
`L`, `W`, and `#` are unaffected and remain usable in standard mode.
|
|
31
|
+
|
|
9
32
|
## [0.7.2]
|
|
10
33
|
|
|
11
34
|
### Changed
|
package/README.md
CHANGED
|
@@ -91,6 +91,23 @@ cronli5(['*/5', '*', '*', '*', '*']); // 'every five minutes'
|
|
|
91
91
|
cronli5({ minute: '*/5' }); // 'every five minutes'
|
|
92
92
|
```
|
|
93
93
|
|
|
94
|
+
By default `cronli5(...)` returns the lowercase, embeddable **fragment**. For
|
|
95
|
+
the capitalized, standalone **sentence**, set [`sentence: true`](#options) — or
|
|
96
|
+
call the matching convenience method. `cronli5.sentence(...)` and
|
|
97
|
+
`cronli5.fragment(...)` are thin sugar over that option (each forwards all
|
|
98
|
+
other options) and read a little better at the call site:
|
|
99
|
+
```js
|
|
100
|
+
cronli5('0 0 * * *'); // 'every day at midnight' (fragment, default)
|
|
101
|
+
cronli5.fragment('0 0 * * *'); // 'every day at midnight' (same as above)
|
|
102
|
+
cronli5.sentence('0 0 * * *'); // 'Runs every day at midnight.'
|
|
103
|
+
cronli5.sentence('0 0 * * *', {lang: de}); // 'Läuft täglich um Mitternacht.'
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
(There is intentionally no `cronli5.toString(...)`: it would shadow
|
|
107
|
+
`Function.prototype.toString`, which the runtime calls with no arguments for
|
|
108
|
+
`String(cronli5)`, template literals, and console output — the named methods
|
|
109
|
+
sidestep that collision.)
|
|
110
|
+
|
|
94
111
|
TypeScript types are bundled, so usage is fully typed out of the box:
|
|
95
112
|
```ts
|
|
96
113
|
import cronli5, { type Cronli5Options } from 'cronli5';
|
|
@@ -147,8 +164,7 @@ It accepts the standard allowed values and the following operators:
|
|
|
147
164
|
### Extended Format Support
|
|
148
165
|
|
|
149
166
|
Ranges in cyclic fields may wrap around (`22-2` is an overnight window, and
|
|
150
|
-
`FRI-MON` is a long weekend). Quartz-style tokens are also supported in the date and weekday fields: `L` (last day, or `5L` for the last Friday), `W` (nearest weekday, e.g. `15W`), `#` (nth weekday, e.g. `1#2` for the second Monday)
|
|
151
|
-
value).
|
|
167
|
+
`FRI-MON` is a long weekend). Quartz-style tokens are also supported in the date and weekday fields: `L` (last day, or `5L` for the last Friday), `W` (nearest weekday, e.g. `15W`), and `#` (nth weekday, e.g. `1#2` for the second Monday). Quartz's `?` ("no specific value") and its day-of-week numbering (1 = Sunday) require the [`quartz` option](#options); see its note for why.
|
|
152
168
|
|
|
153
169
|
## Options
|
|
154
170
|
|
|
@@ -158,15 +174,16 @@ The `cronli5` function takes an `options` object as its 2nd parameter:
|
|
|
158
174
|
| --- | --- | --- |
|
|
159
175
|
| `ampm` | `true` (English) | Use a 12-hour clock. Set `false` for 24-hour time. The default is language-specific: English is 12-hour; Spanish and Finnish default to 24-hour (Finnish is 24-hour only). |
|
|
160
176
|
| `dialect` | `'us'` | The English style. `'us'` follows the [Chicago Manual of Style][chicago]: serial commas, `through` ranges, `9 a.m.`/`5:30 p.m.` times, `noon`/`midnight`, and `January 1` dates. `'gb'` follows the [Guardian style guide][guardian]: no serial comma, `to` ranges, `9am`/`5.30pm` times, `midday`/`midnight`, and `1 January` dates. `'house'` is cronli5's legacy voice (`9:30 AM`, `Monday - Friday`). A custom object defines your own style. (`'uk'` is a deprecated alias for `'gb'`.) See [docs/dialects.md](./docs/dialects.md). |
|
|
161
|
-
| `lang` | English | A language module, e.g. `import es from 'cronli5/lang/es'`. Each language owns its words, conventions, and dialects
|
|
177
|
+
| `lang` | English | A language module, e.g. `import es from 'cronli5/lang/es'`. Each language owns its words, conventions, and dialects — see [Languages](#languages). |
|
|
162
178
|
| `lenient` | `false` | Never throw: invalid input returns the language's fallback description (`'an unrecognizable cron pattern'`) instead. Useful when rendering arbitrary user crontabs. |
|
|
163
|
-
| `
|
|
179
|
+
| `quartz` | `false` | Read the pattern with [Quartz](https://www.quartz-scheduler.org/) semantics. Quartz numbers the day-of-week **1 = Sunday … 7 = Saturday** (standard cron uses 0/7 = Sunday, 1 = Monday) and requires exactly one of day-of-month or day-of-week to be `?` ("no specific value"). With this off, `?` is rejected outright rather than silently mis-read — a `?` is the unambiguous mark of a Quartz pattern, so `'0 0 ? * 2'` would otherwise read as Tuesday when its author meant Monday. The Quartz numbering also applies inside the day-of-week operators (`6L`, `2#2`) and the weekday `L` alias. Day names (`MON`) and the other fields are unaffected. Composable with `seconds`/`years`. |
|
|
180
|
+
| `sentence` | `false` | Return a complete standalone sentence (`'Runs every day at midnight.'`, `'Läuft täglich um Mitternacht.'`) instead of the embeddable fragment. Each language supplies its own wrapping. Wraps a schedule and `@reboot`, but not the lenient `fallback`. The methods `cronli5.sentence(...)` / `cronli5.fragment(...)` (see [Usage](#usage)) are sugar for this option set to `true` / `false`. |
|
|
164
181
|
| `short` | `false` | Compact output: abbreviated month and weekday names, and hyphenated ranges everywhere `through`/`to` would appear (`Mon-Fri`, `Jan-Mar`, `1st-5th`, `9 a.m.-5:45 p.m.`). |
|
|
165
182
|
| `seconds` | `false` | Always treat the first field of strings and arrays as the `second` field. |
|
|
166
183
|
| `years` | `false` | Treat the last field of a six-field string/array as the `year` field. Otherwise the first field of a six-field pattern is treated as the `second` field. Seven-field patterns are unambiguous (seconds first, year last) and need no option. |
|
|
167
184
|
|
|
168
|
-
When a specific year is given
|
|
169
|
-
`year` property, or a six-field pattern with `years: true`
|
|
185
|
+
When a specific year is given — via a seven-field pattern, an object's
|
|
186
|
+
`year` property, or a six-field pattern with `years: true` — it is
|
|
170
187
|
folded into a specific calendar date (`'on January 1, 2030 at noon'`)
|
|
171
188
|
or otherwise trails the description (`'every Friday at 1 p.m. in 2030'`).
|
|
172
189
|
|
|
@@ -300,7 +317,7 @@ it differs from `cronli5` in philosophy. `cronli5` writes one flowing sentence
|
|
|
300
317
|
and does additional validation; its languages are full renderers
|
|
301
318
|
([seven so far](#languages)). cRonstrue assembles per-field fragments from
|
|
302
319
|
translated templates, which is how it covers 39 locales. The same compound
|
|
303
|
-
pattern
|
|
320
|
+
pattern — `5,10 30 9 * * MON` — in every language:
|
|
304
321
|
|
|
305
322
|
<!-- BEGIN GENERATED: cronstrue-head-to-head -->
|
|
306
323
|
| Language | cronli5 | cRonstrue 3.14.0 |
|
package/cronli5.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";(()=>{var Or={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6},Nr={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12},k={second:{cyclic:!0,max:59,min:0,top:59},minute:{cyclic:!0,max:59,min:0,top:59},hour:{cyclic:!0,max:23,min:0,top:23},date:{aliases:{"?":"*"},cyclic:!0,max:31,min:1,top:31},month:{cyclic:!0,max:12,min:1,numbers:Nr,top:12},weekday:{aliases:{"?":"*",L:"6"},cyclic:!0,max:7,min:0,numbers:Or,top:6},year:{max:9999,min:1970}},M=["second","minute","hour","date","month","weekday","year"],tn={"@annually":"0 0 1 1 *","@yearly":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *"},A=6;function m(n,r){return(""+n).indexOf(r)!==-1}function Y(n){return Array.from(new Set(n))}function G(n){return/^\d+$/.test(n)}function d(n,r){return G(n)?+n:r[n.toUpperCase()]}function Tn(n){return M.forEach(function(e){zr(n[e],k[e],e)}),n}function zr(n,r,e){typeof n!="string"&&typeof n!="number"&&Mn(n,e);let t=""+n;t!=="*"&&(e==="date"&&U(t)||e==="weekday"&&q(t,r)||t.split(",").forEach(function(o){vr(o,r)||Mn(o,e)}))}function U(n){if(n==="L"||n==="LW"||n==="WL")return!0;let r=/^L-(\d{1,2})$/.exec(n);if(r)return+r[1]>=1&&+r[1]<=30;let e=/^(\d{1,2})W$|^W(\d{1,2})$/.exec(n);if(e){let t=+(e[1]||e[2]);return t>=1&&t<=31}return!1}function q(n,r){if(/L$/.test(n))return L(n.slice(0,-1),r);let e=n.split("#");return e.length===2?L(e[0],r)&&/^[1-5]$/.test(e[1]):!1}function vr(n,r){return m(n,"/")?wr(n,r):m(n,"-")?Wn(n,r):L(n,r)}function wr(n,r){let e=n.split("/");return e.length!==2||!G(e[1])||+e[1]<1?!1:e[0]==="*"||L(e[0],r)||Wn(e[0],r,!0)}function Wn(n,r,e){let t=n.split("-");return t.length!==2||!L(t[0],r)||!L(t[1],r)?!1:r.cyclic&&!e?!0:d(t[0],r.numbers)<=d(t[1],r.numbers)}function L(n,r){return n==="*"?!1:G(n)?+n>=r.min&&+n<=r.max:r.numbers?n.toUpperCase()in r.numbers:!1}function Mn(n,r){throw new Error('`cronli5` was passed an invalid field value "'+n+'" for the '+r+" field.")}var Pr={hour:24,minute:60,second:60};function Ln(n){M.forEach(function(e){let t=k[e].aliases,i=t&&t[""+n[e]];i&&(n[e]=i)})}function En(n){return M.forEach(function(e){let t=""+n[e];if(e==="date"&&U(t)||e==="weekday"&&q(t,k[e])){n[e]=t;return}n[e]=Cr(t,e,k[e])}),n}function Cr(n,r,e){let t=""+n;if(t==="*")return t;let i=Pr[r],o=t.split(",").map(function(s){return xr(Dn(Wr(Hr(Lr(Tr(Mr(s,e),e),e),e),e,i),e),e)}).join(",").split(",");return o.indexOf("*")!==-1?"*":Y(o).sort(function(s,f){return Hn(s,e)-Hn(f,e)}).join(",")}function xr(n,r){if(!r.numbers)return n;let e=n.split("/"),t=e[0].split("-").map(function(o){return Fr(o,r)}).join("-");return e.length===2?t+"/"+e[1]:t}function Fr(n,r){if(n==="*")return n;let e=d(n,r.numbers);return""+(e>r.top?r.min:e)}function Mr(n,r){let e=n.split("/");if(!r.cyclic||e.length!==2||+e[1]!=1)return n;let t=e[0];return m(t,"-")?t:t==="*"||d(t,r.numbers)===r.min?"*":t+"-"+r.top}function Tr(n,r){let e=n.split("/");if(!r.cyclic||typeof r.top!="number"||e.length!==2||m(e[0],"-"))return n;let t=e[0];return(t==="*"?r.min:d(t,r.numbers))+ +e[1]<=r.top?n:t==="*"?""+r.min:t}function Wr(n,r,e){let t=n.split("/");if(typeof e!="number"||t.length!==2||m(t[0],"-"))return n;let i=+t[1],o=t[0]==="*"?r.min:d(t[0]);if(e%i===0&&o<i)return n;let u=[];for(let s=o;s<=r.top;s+=i)u.push(s);return u.join(",")}function Hr(n,r){let e=n.split("/");return e.length!==2||!m(e[0],"-")?n:Dn(e[0],r)==="*"?"*/"+e[1]:n}function Dn(n,r){if(typeof r.top!="number"||m(n,"/")||!m(n,"-"))return n;let e=n.split("-"),t=d(e[0],r.numbers),i=d(e[1],r.numbers);if(t>i)return n;let o=r.top,u={};for(let s=t;s<=i;s+=1)u[s>o?r.min:s]=!0;for(let s=r.min;s<=o;s+=1)if(!u[s])return n;return"*"}function Lr(n,r){let e=n.split("/")[0];if(!m(e,"-"))return n;let t=e.split("-");return d(t[0],r.numbers)!==d(t[1],r.numbers)?n:t[0]}function Hn(n,r){let e=n.split("/")[0].split("-")[0];return e==="*"?r.min:d(e,r.numbers)}function jn(n,r){let e=n instanceof Array;if(n===null||typeof n>"u"||n===""||e&&n.length===0)throw new Error("`cronli5` expects a non-empty cron pattern as the first argument.");if(e)return Rn(n,r);if(typeof n=="object")return Er(n);if(typeof n=="string")return Dr(n,r);throw new Error("`cronli5` was passed an unexpected type.")}function Rn(n,r){if(n.length>7)throw new Error("`cronli5` was passed a cron pattern with more than seven fields.");return!r.seconds&&n.length<(r.years?7:6)&&n.unshift("0"),{second:n[0]||"0",minute:n[1]||"*",hour:n[2]||"*",date:n[3]||"*",month:n[4]||"*",weekday:n[5]||"*",year:n[6]||"*"}}function Er(n){if(!n.second&&!n.minute&&!n.hour)throw new Error("`cronli5` expects that any object being interpreted as a cron pattern have at least one of the following properties: `second`, `minute`, or `hour`");let r=typeof n.second<"u",e=typeof n.minute<"u",t=r?"*":"0",i=r||e?"*":"0";return{second:T(n.second,"0"),minute:T(n.minute,t),hour:T(n.hour,i),date:T(n.date,"*"),month:T(n.month,"*"),weekday:T(n.weekday,"*"),year:T(n.year,"*")}}function T(n,r){return typeof n>"u"?r:n}function Dr(n,r){let e=jr(n).split(/\s+/);return Rn(e,r)}function jr(n){let r=n.trim();if(r.charAt(0)!=="@")return n;let e=r.toLowerCase();if(Object.hasOwn(tn,e))return tn[e];throw new Error("`cronli5` does not recognize the macro `"+r+"`.")}function An(n){return n===0?7:n}function Un(n){let r=n.flatMap(function(i){return i.kind==="step"?i.fires.map(function(u){return{kind:"single",value:""+u}}):[i]});function e(t){return t.kind==="range"?An(+t.bounds[0]):An(+t.value)}return r.map(function(i,o){return[i,o]}).sort(function(i,o){return e(i[0])-e(o[0])||i[1]-o[1]}).map(function(i){return i[0]})}function on(n){if(n.length<5)return null;let r=n[1]-n[0];if(r<2)return null;for(let e=2;e<n.length;e+=1)if(n[e]-n[e-1]!==r)return null;return{start:n[0],interval:r,last:n[n.length-1]}}function c(n,r){return n.analyses.segments[r]??[]}function O(n,r){return c(n,r)[0]}function Z(n){let r=[];for(let e of n){if(e.kind!=="single")return null;r.push(+e.value)}return r}function un(n){return n.start<n.interval&&24%n.interval===0}function Rr(n,r,e){return e-1-(e-1-n)%r}function sn(n,r){let{start:e,interval:t,last:i,cycle:o}=n,u=o%t===0&&i===Rr(e,t,o);return e===0&&u?r.bare():e<t&&u?r.offset():r.bounded()}function qn(n){if(n.length<2)return null;let r=n[1]-n[0];if(r<2)return null;for(let e=2;e<n.length;e+=1)if(n[e]-n[e-1]!==r)return null;return n[0]!==0&&n.length<5?null:{interval:r,last:n[n.length-1],start:n[0]}}function Qn(n){return n!=="*"&&!m(n,",")&&!m(n,"-")&&!m(n,"/")}function an(n){return m(n,"-")&&!m(n,",")&&!m(n,"/")}function Ar(n){return m(n,"/")&&!m(n,",")}function cn(n){return n!=="*"&&!m(n,"-")&&!m(n,"/")}function mn(n){return n!=="*"&&!an(n)&&!Ar(n)}function E(n){return n.indexOf("/")!==-1&&n.indexOf("-")===-1&&n.indexOf(",")===-1}function Q(n,r,e){let t=[],i=n;for(;i<=e;)t.push(i),i+=r;return t}function Vn(n,r,e,t){let i=n.split("/"),o=+i[1];if(m(i[0],"-")){let s=i[0].split("-");return Q(d(s[0],t),o,d(s[1],t))}let u=i[0]==="*"?r:d(i[0],t);return Q(u,o,e)}function fn(n,r,e){let t=[];return n.split(",").forEach(function(o){if(m(o,"/"))t.push(...Vn(o,r,e));else if(m(o,"-")){let u=o.split("-");+u[0]<=+u[1]?t.push(...Q(+u[0],1,+u[1])):(t.push(...Q(+u[0],1,e)),t.push(...Q(r,1,+u[1])))}else t.push(+o)}),Y(t)}function Ur(n){return cn(n)?n.split(",").map(Number):[0]}function qr(n){if(n==="*")return[0,59];if(an(n)){let r=n.split("-");if(+r[0]<=+r[1])return[+r[0],+r[1]]}return null}function Qr(n){return n==="*"?59:Math.max(...fn(n,0,59))}function Vr(n){if(Qn(n)&&n!=="0")return+n}function Ir(n,r){return n==="*"?"wildcard":r==="date"&&U(n)||r==="weekday"&&q(n,k.weekday)?"quartz":m(n,",")?"list":m(n,"/")?"step":m(n,"-")?"range":"single"}function $r(n,r,e){return r==="wildcard"||r==="quartz"?null:n.split(",").map(function(i){if(m(i,"/")){let o=i.split("/");return{fires:Vn(i,e.min,e.top,e.numbers),interval:+o[1],kind:"step",startToken:o[0]}}return m(i,"-")?{bounds:i.split("-"),kind:"range"}:{kind:"single",value:i}})}function In(n){let r={},e={};M.forEach(function(u){r[u]=Ir(n[u],u),e[u]=$r(n[u],r[u],k[u])});let i={analyses:{clockSecond:Vr(n.second),lastMinuteFire:Qr(n.minute),minuteSpan:qr(n.minute),segments:e},pattern:n,shapes:r};return{...i,plan:Jr(i)}}function Jr(n){let{analyses:r,pattern:e,shapes:t}=n;if(e.second!=="0"){let i=Kr(e,t,r);if(i)return i}return $n(e,t,r)||Jn(e,t,r)}function Kr(n,r,e){let t=Yr(n,r);return t||(n.hour==="*"&&r.minute==="single"&&n.second!=="*"?{kind:"secondsWithinMinute",singleSecond:r.second==="single"}:r.second==="single"&&cn(n.minute)&&mn(n.hour)?null:{kind:"composeSeconds",rest:$n(n,r,e,!0)||Jn(n,r,e,!0)})}function Yr(n,r){return n.minute!=="*"||n.hour!=="*"?null:n.second==="*"?{kind:"everySecond"}:r.second==="single"?{kind:"secondPastMinute"}:{kind:"standaloneSeconds"}}function $n(n,r,e,t=!1){if(r.minute==="step")return{hours:Zr(n,r,e),kind:"minuteFrequency"};if(r.hour==="single"&&e.minuteSpan)return{hour:+n.hour,kind:"minuteSpanInHour",span:e.minuteSpan};let i=Br(n,r);if(i)return i;let o=Gr(n,r);if(o)return o;if(n.hour==="*")return Xr(n,r,t)}function ln(n){let[r,e]=n.split("/"),t=r==="*"?0:+r;return r.indexOf("-")===-1&&24%+e===0&&t<+e}function Gr(n,r){return r.hour!=="step"?null:n.minute==="*"?ln(n.hour)?{form:"wildcard",kind:"minuteSpanAcrossHourStep"}:{form:"wildcard",kind:"minutesAcrossHours",times:V(n.hour)}:r.minute==="range"?{form:"range",kind:"minuteSpanAcrossHourStep"}:r.minute==="list"&&ln(n.hour)?{form:"list",kind:"minuteSpanAcrossHourStep"}:null}function Zr(n,r,e){if(r.hour==="list")return{kind:"during",times:V(n.hour)};if(r.hour==="range"){let t=n.hour.split("-");return{from:+t[0],kind:"window",last:e.lastMinuteFire,to:+t[1]}}return r.hour==="single"?{from:+n.hour,kind:"window",last:e.lastMinuteFire,to:+n.hour}:r.hour==="step"?ln(n.hour)?{kind:"step"}:{kind:"during",times:V(n.hour)}:{kind:"none"}}function Br(n,r){return mn(n.hour)?n.minute==="*"?{form:"wildcard",kind:"minutesAcrossHours",times:V(n.hour)}:r.minute==="range"||r.minute==="list"&&m(n.minute,"-")&&!m(n.minute,"/")?{form:r.minute==="range"?"range":"list",kind:"minutesAcrossHours",times:V(n.hour)}:null:null}function Xr(n,r,e){if(r.minute==="range")return{kind:"rangeOfMinutes"};if(r.minute==="list")return{kind:"multipleMinutes"};if(n.minute==="*")return{kind:"everyMinute"};if(n.minute!=="0"||e)return{kind:"singleMinute"}}function Jn(n,r,e,t=!1){let i=t&&n.minute==="0";return r.hour==="range"&&!i?_r(n,r,e):r.hour==="step"&&n.minute==="0"&&!t?{kind:"hourStep"}:n.hour==="*"&&!i?{kind:"everyHour"}:ne(n,e,i)}function _r(n,r,e){let t=n.hour.split("-"),i="lead";return n.minute==="*"?i="wildcard":r.minute==="range"&&(i="range"),{boundMinute:r.minute==="range"||r.minute==="list"?null:e.lastMinuteFire,from:+t[0],kind:"hourRange",last:e.lastMinuteFire,minuteForm:i,to:+t[1]}}function ne(n,r,e=!1){let t=fn(n.hour,0,23),i=Ur(n.minute);if(!e&&t.length*i.length>A)return{fold:i.length===1,kind:"compactClockTimes",minute:i[0]};let o=[];return t.forEach(function(s){i.forEach(function(S){o.push({hour:s,minute:S,second:r.clockSecond})})}),{kind:"clockTimes",times:o}}function V(n){let r=fn(n,0,23);return r.length<=A?{fires:r,kind:"fires"}:{kind:"segments"}}function Kn(n,r){let e=jn(n,r);return Ln(e),Tn(e),En(e)}function w(n){return n=""+n,n.length<2?"0"+n:n}function Yn(n,r,e){return e.short?n:r[n]||n}function dn(n,{sep:r,pad:e,lean:t}){let i=e?w(n.hour):""+n.hour;return t&&!n.minute&&!n.second?i:i+r+w(n.minute)+(n.second?r+w(n.second):"")}var gn={gb:{am:"am",closeUp:!0,dayFirst:!0,midday:"midday",midnight:"midnight",ordinals:!1,pm:"pm",sep:".",serialComma:!1,through:" to "},us:{am:"a.m.",closeUp:!1,dayFirst:!1,midday:"noon",midnight:"midnight",ordinals:!1,pm:"p.m.",sep:":",serialComma:!0,through:" through ",untilWindow:!0},house:{am:"AM",closeUp:!1,dayFirst:!1,midday:"noon",midnight:"midnight",ordinals:!0,pm:"PM",sep:":",serialComma:!0,through:" - "}};function Gn(n){return typeof n=="object"&&n!==null?{...gn.us,untilWindow:!1,...n}:gn[n==="uk"?"gb":n]||gn.us}var re=["zero","one","two","three","four","five","six","seven","eight","nine","ten"],hn=["th","st","nd","rd"],ee=[null,["January","Jan"],["February","Feb"],["March","Mar"],["April","Apr"],["May","May"],["June","Jun"],["July","Jul"],["August","Aug"],["September","Sep"],["October","Oct"],["November","Nov"],["December","Dec"]],P=[["Sunday","Sun"],["Monday","Mon"],["Tuesday","Tue"],["Wednesday","Wed"],["Thursday","Thu"],["Friday","Fri"],["Saturday","Sat"]],te={SUN:P[0],MON:P[1],TUE:P[2],WED:P[3],THU:P[4],FRI:P[5],SAT:P[6]},ie=[null,"first","second","third","fourth","fifth"];function oe(n){return n=n||{},{ampm:typeof n.ampm=="boolean"?n.ampm:!0,lenient:!!n.lenient,seconds:!!n.seconds,short:!!n.short,style:Gn(n.dialect),years:!!n.years}}function ue(n,r){let e=me(n,r);if(e!==null)return Bn(e,n,r);let t=Qe(n,r)??Xn(n,n.plan,r),i=K(n,r)?nt(n,r):"";return Bn(i+t,n,r)}function Xn(n,r,e){let t=Ve[r.kind];return t(n,r,e)}function pn(n){return n==="step"||n==="range"||n==="list"}function se(n,r){if(!r.style.untilWindow||r.short||n.plan.kind!=="composeSeconds"||n.plan.rest.kind==="clockTimes"||K(n,r))return!1;let{shapes:e}=n;return pn(e.second)&&pn(e.minute)&&pn(e.hour)}function ae(n,r){let e=On(n);if(e)return B(e,r);if(n.shapes.hour==="range"){let t=c(n,"hour").find(function(o){return o.kind==="range"});return R({continuous:!1,from:+t.bounds[0],throughMinute:0,to:+t.bounds[1]},r)}return"during the "+j(n,{minute:0,second:null},!1,r)+" hours"}function ce(n,r){return n.shapes.minute==="step"?X(O(n,"minute"),"minute","hour",r):n.shapes.minute==="range"?$(n.pattern.minute,r):H(c(n,"minute"),"minute","hour",r)??z(F(c(n,"minute"),r),"minute","hour",r)}function me(n,r){if(!se(n,r))return null;let e=ae(n,r),t=ce(n,r),i=x(n,"minute",r),o=e+", "+t+", and within each of those minutes, "+i,u=a(n,r).trim();return u?u+", "+o:o}function le(n,r,e){return"every second"+a(n,e)}function fe(n,r,e){return D(n,e)+a(n,e)}function de(n,r,e){let t=n.pattern.second;return g(t,e)+" "+v(t,"second")+" past the minute, every minute"+a(n,e)}function ge(n,r,e){let t=n.pattern.minute,i=g(t,e),o=v(t,"minute");if(r.singleSecond){let u=n.pattern.second;return i+" "+o+" and "+g(u,e)+" "+v(u,"second")+" past the hour, every hour"+a(n,e)}return D(n,e)+", "+i+" "+o+" past the hour, every hour"+a(n,e)}function he(n,r,e){if(!(r.rest.kind==="clockTimes"||r.rest.kind==="compactClockTimes")||n.shapes.minute!=="single")return null;let i=+n.pattern.minute;return zn(n,i,e)??vn(n,i,e)}function pe(n,r,e){return+r.times[0].minute==0&&n.shapes.minute==="single"?D(n,e)+" for one minute at "+be(n,r,e):D(n,e)+" of "+Se(n,r,e)}function ye(n,r,e){let t=he(n,r,e);return t!==null?t:r.rest.kind==="clockTimes"&&(n.shapes.second==="wildcard"||n.shapes.second==="step")?pe(n,r.rest,e):n.shapes.second==="wildcard"&&r.rest.kind==="minuteFrequency"&&r.rest.hours.kind==="none"&&n.pattern.minute==="*/2"?"every second of every other minute"+a(n,e):(r.rest.kind==="compactClockTimes"&&n.analyses.clockSecond?"":D(n,e)+", ")+Xn(n,r.rest,e)}function be(n,r,e){let t=r.times.map(function(u){return l({hour:u.hour,minute:0},e)}),i=_(n,Cn,e);return p(t,e)+(i&&", "+i)}function Se(n,r,e){let t=r.times.map(function(u){return l({hour:u.hour,minute:u.minute,second:u.second,explicit:!0},e)}),i=_(n,Cn,e);return p(t,e)+(i&&", "+i)}function D(n,r){return x(n,"minute",r)}function x(n,r,e){let t=n.pattern.second,i=n.shapes.second;if(t==="*")return"every second";if(i==="step")return X(O(n,"second"),"second",r,e);if(i==="range"){let o=t.split("-"),u=wn();return"every second from "+u(o[0])+h(e)+u(o[1])+" past the "+r}return i==="single"?"at "+g(t,e)+" "+v(t,"second")+" past the "+r:H(c(n,"second"),"second",r,e)??z(F(c(n,"second"),e),"second",r,e)}function ke(n,r,e){return"every minute"+a(n,e)}function Oe(n,r,e){let t=n.pattern.minute;return g(t,e)+" "+v(t,"minute")+" past the hour, every hour"+a(n,e)}function Ne(n,r,e){return $(n.pattern.minute,e)+a(n,e)}function ze(n,r,e){return(H(c(n,"minute"),"minute","hour",e)??z(F(c(n,"minute"),e),"minute","hour",e))+a(n,e)}function ve(n,r,e){let t=X(O(n,"minute"),"minute","hour",e);if(r.hours.kind==="during"){let i=J(n,e);t+=i?", "+i:" during the "+I(n,r.hours.times,!1,e)+" hours"}else r.hours.kind==="window"?t+=" "+R({continuous:!1,from:r.hours.from,throughMinute:r.hours.last,to:r.hours.to},e):r.hours.kind==="step"&&(t+=" "+kn(O(n,"hour"),e));return t+a(n,e)}function we(n,r,e){return n.pattern.minute==="*"?"every minute of the "+l({hour:r.hour,minute:0},e)+" hour"+a(n,e):"every minute from "+l({hour:r.hour,minute:r.span[0]},e)+h(e)+l({hour:r.hour,minute:r.span[1]},e)+a(n,e)}function Pe(n,r,e){let t=J(n,e);if(r.form==="wildcard")return t!==null?"every minute, "+t+a(n,e):"every minute during the "+I(n,r.times,!1,e)+" hours"+a(n,e);if(r.form==="range"){let u=$(n.pattern.minute,e);return t!==null?u+", "+t+a(n,e):Ye(r.times)?u+", at "+I(n,r.times,!0,e)+a(n,e):u+" during the "+I(n,r.times,!1,e)+" hours"+a(n,e)}let i=H(c(n,"minute"),"minute","hour",e)??z(F(c(n,"minute"),e),"minute","hour",e);if(t!==null)return i+", "+t+a(n,e);let o=I(n,r.times,!0,e);return i+", at "+o+a(n,e)}var _n={2:"other",3:"third",4:"fourth",6:"sixth",8:"eighth",12:"twelfth"};function kn(n,r){let e="during every "+_n[n.interval]+" hour",t=n.startToken==="*"?0:+n.startToken;return t===0?e:e+" starting at "+l({hour:t,minute:0},r)}function Ce(n,r,e){let t=O(n,"hour");if(r.form==="wildcard")return"every minute "+kn(t,e)+a(n,e);let i=r.form==="list"?H(c(n,"minute"),"minute","hour",e)??z(F(c(n,"minute"),e),"minute","hour",e):$(n.pattern.minute,e),o=J(n,e);return i+", "+(o??or(t,e))+a(n,e)}function $(n,r){let e=n.split("-"),t=wn();return"every minute from "+t(e[0])+h(r)+t(e[1])+" past the hour"}function xe(n,r,e){return"every hour"+a(n,e)}function Fe(n,r,e){let t=We(Te(r),e);return r.minuteForm==="wildcard"?"every minute "+t+a(n,e):r.minuteForm==="range"?$(n.pattern.minute,e)+", "+t+a(n,e):nr(n,e)+" "+t+a(n,e)}function nr(n,r){return n.pattern.minute==="0"?"every hour":H(c(n,"minute"),"minute","hour",r)??z(F(c(n,"minute"),r),"minute","hour",r)}function Me(n,r,e){let t=J(n,e);return t!==null?t+a(n,e):or(O(n,"hour"),e)+a(n,e)}function Te(n){let r=n.minuteForm==="wildcard",e=r?n.boundMinute??0:0;return{from:n.from,closeMinute:e,to:n.to,continuous:r}}function R(n,r){let{from:e,to:t,throughMinute:i,continuous:o}=n,u="from "+l({hour:e,minute:0},r);return r.style.untilWindow&&!r.short&&e!==t?o?u+" until "+l({hour:(t+1)%24,minute:0},r):u+h(r)+l({hour:t,minute:0},r):u+h(r)+l({hour:t,minute:i},r)}function We(n,r){return R({continuous:n.continuous,from:n.from,throughMinute:n.closeMinute,to:n.to},r)}function He(n,r,e){if(n.shapes.minute==="single"){let o=+n.pattern.minute,u=zn(n,o,e)??vn(n,o,e);if(u!==null)return u}let t=Pn(r.times),i=r.times.map(function(u){return l({hour:u.hour,minute:u.minute,second:u.second,plain:t},e)});return cr(n,e)+"at "+p(i,e)+rr(n,e)}function rr(n,r){return K(n,r)?lr(n,r):""}function Le(n,r,e){if(r.fold){let u=zn(n,+r.minute,e)??vn(n,+r.minute,e);if(u!==null)return u;if(c(n,"hour").some(function(y){return y.kind==="range"})&&!n.analyses.clockSecond)return Ee(n,r,e)+a(n,e);let f={minute:r.minute,second:n.analyses.clockSecond};return cr(n,e)+"at "+j(n,f,!0,e)+rr(n,e)}let t=H(c(n,"minute"),"minute","hour",e)??z(F(c(n,"minute"),e),"minute","hour",e),i=J(n,e),o=i?t+", "+i+a(n,e):t+", at "+j(n,{minute:0,second:null},!0,e)+a(n,e);return n.analyses.clockSecond?D(n,e)+", "+o:o}function Ee(n,r,e){let t=r.minute,i=[],o=er(n).map(function(f){return l({hour:f,minute:t},e)});return c(n,"hour").forEach(function(f){f.kind==="range"&&i.push(R({continuous:!1,from:+f.bounds[0],throughMinute:t,to:+f.bounds[1]},e))}),nr(n,e)+" "+p(i,e)+tr(o,e)}function er(n){let r=[];return c(n,"hour").forEach(function(t){t.kind==="step"?r.push(...t.fires):t.kind!=="range"&&r.push(+t.value)}),r}function tr(n,r){return n.length?" and at "+p(n,r):""}function W(n){return n==="*"||n.startsWith("*/")&&n.indexOf("-")===-1}function De(n,r){let{second:e,minute:t}=n.pattern;return W(e)?{secondLead:!0,text:x(n,"minute",r)}:e==="0"&&W(t)?{secondLead:!1,text:t==="*"?"every minute":X(O(n,"minute"),"minute","hour",r)}:null}function je(n,r){let e=n.pattern.minute;if(e==="*")return"";if(W(e))return" of every other minute";let t=c(n,"minute");if(n.shapes.minute==="single")return" during minute :"+w(e);if(n.shapes.minute==="range"){let o=e.split("-");return" during minutes :"+w(o[0])+h(r)+":"+w(o[1])}let i=F(t,r).map(function(u){return":"+w(u)});return" during minutes "+p(i,r)}function Re(n,r){let e=n.pattern.hour;if(e==="*")return n.pattern.minute!=="*"&&!W(n.pattern.minute)?" of every hour":"";if(W(e))return e==="*/2"?" of every other hour":"";if(n.shapes.hour==="single"){let t=+e;return n.shapes.minute==="step"?" from "+l({hour:t,minute:0},r)+" until "+l({hour:(t+1)%24,minute:0},r):n.pattern.minute!=="*"&&!W(n.pattern.minute)?" at "+l({hour:t,minute:0},r):" of the "+l({hour:t,minute:0},r)+" hour"}if(n.shapes.hour==="range"){let t=e.split("-");return" "+R({continuous:n.pattern.minute==="*",from:+t[0],throughMinute:0,to:+t[1]},r)}return" during the "+j(n,{minute:0,second:null},!1,r)+" hours"}function Ae(n){if(n.shapes.hour!=="step")return!0;let r=O(n,"hour");return n.pattern.hour==="*/2"||r.startToken.indexOf("-")!==-1}function Ue(n){if(n.shapes.minute!=="list")return!1;let r=Z(c(n,"minute"));return r!==null&&on(r)!==null}function qe(n,r){let{minute:e,hour:t}=n.pattern,i=W(e)&&e!=="*";return Ae(n)?r.secondLead?i?e==="*/2"&&n.shapes.hour!=="range":!(Ue(n)||n.shapes.minute==="list"&&n.shapes.hour==="list"):t==="*/2"?!0:n.shapes.hour==="single"&&e==="*/2":!1}function Qe(n,r){if(!r.style.untilWindow||r.short||n.pattern.minute==="*"&&n.pattern.hour==="*")return null;let e=De(n,r);if(!e||!qe(n,e))return null;let t=e.secondLead?je(n,r):"";return e.text+t+Re(n,r)+a(n,r)}var Ve={clockTimes:He,compactClockTimes:Le,composeSeconds:ye,everyHour:xe,everyMinute:ke,everySecond:le,hourRange:Fe,hourStep:Me,minuteFrequency:ve,minuteSpanAcrossHourStep:Ce,minuteSpanInHour:we,minutesAcrossHours:Pe,multipleMinutes:ze,rangeOfMinutes:Ne,secondPastMinute:de,secondsWithinMinute:ge,singleMinute:Oe,standaloneSeconds:fe};function ir(n,r){let{interval:e,start:t,last:i,cycle:o,unit:u,anchor:s}=n,f="every "+g(e,r)+" "+u+"s";return sn({start:t,interval:e,last:i,cycle:o},{bare:()=>f,offset:()=>f+" from "+g(t,r)+" "+v(t,u)+" past the "+s,bounded:()=>{let S=wn();return f+" from "+S(t)+h(r)+S(i)+" "+v(i,u)+" past the "+s}})}function H(n,r,e,t){let i=Z(n),o=i&&on(i);return o?ir({...o,cycle:60,unit:r,anchor:e},t):null}function X(n,r,e,t){if(n.startToken.indexOf("-")!==-1)return z(Zn(n.fires,t),r,e,t);let i=n.startToken==="*"?0:+n.startToken;return i!==0&&n.fires.length<=3?z(Zn(n.fires,t),r,e,t):ir({interval:n.interval,start:i,last:n.fires[n.fires.length-1],cycle:60,unit:r,anchor:e},t)}function or(n,r){if(n.startToken.indexOf("-")!==-1)return"at "+yn(n.fires,r);let e=n.startToken==="*"?0:+n.startToken,t=n.interval;return e===0?"every "+g(t,r)+" hours":n.fires.length<=3?"at "+yn(n.fires,r):"every "+g(t,r)+" hours from "+l({hour:e,minute:0},r)}function B(n,r){let{start:e,interval:t,last:i}=n,o="every "+g(t,r)+" hours";return sn({start:e,interval:t,last:i,cycle:24},{bare:()=>o,offset:()=>o+" from "+l({hour:e,minute:0},r),bounded:()=>o+" from "+l({hour:e,minute:0},r)+h(r)+l({hour:i,minute:0},r)})}function J(n,r){let e=On(n);return!e||un(e)?null:B(e,r)}function On(n){let r=c(n,"hour");if(r.length===1&&r[0].kind==="step"){let t=r[0];if(t.fires.length<2)return null;let i=t.startToken==="*"?0:+t.startToken.split("-")[0];return{interval:t.interval,last:t.fires[t.fires.length-1],start:i}}let e=Z(r);return e&&qn(e)}function Nn(n){return n.pattern.second==="*"||n.shapes.second==="step"}function ur(n,r,e){if(r===0)return Nn(n)?x(n,"minute",e)+" for one minute":x(n,"hour",e);let t=g(r,e)+" "+v(r,"minute")+" past the hour";return n.pattern.second==="0"?t:x(n,"minute",e)+", "+t}function zn(n,r,e){let t=On(n);if(!t)return null;let i=(t.last-t.start)/t.interval+1;if(n.pattern.second==="0"&&i<=A&&un(t))return null;let o=r===0&&Nn(n)&&Ie(n);return o?x(n,"minute",e)+" for one minute "+kn(o,e)+a(n,e):r===0&&n.pattern.second==="0"?B(t,e)+a(n,e):ur(n,r,e)+", "+B(t,e)+a(n,e)}function Ie(n){let r=c(n,"hour"),e=r.length===1&&r[0];return!e||e.kind!=="step"||e.startToken.indexOf("-")!==-1||!(e.interval in _n)?null:e}function $e(n){return c(n,"hour").some(function(e){return e.kind==="range"})}function Je(n,r){let e=[],t=er(n);c(n,"hour").forEach(function(s){s.kind==="range"&&e.push(R({continuous:!1,from:+s.bounds[0],throughMinute:0,to:+s.bounds[1]},r))});let i="every hour "+p(e,r),o=t.map(function(s){return l({hour:s,minute:0},r)});return i+tr(o,r)}function vn(n,r,e){return r!==0||!$e(n)||n.pattern.second==="0"?null:Nn(n)?x(n,"minute",e)+" for one minute during the "+j(n,{minute:0,second:null},!1,e)+" hours"+a(n,e):ur(n,r,e)+", "+Je(n,e)+a(n,e)}function wn(){return function(r){return""+r}}function sr(n,r){return n>1?function(t){return""+t}:function(t){return g(t,r)}}function Zn(n,r){return n.map(sr(n.length,r))}function F(n,r){let e=n.reduce(function(o,u){return u.kind==="range"?o+1:o+(u.kind==="step"?u.fires.length:1)},0),t=sr(e,r);return n.flatMap(function(o){return o.kind==="range"?[t(o.bounds[0])+h(r)+t(o.bounds[1])]:o.kind==="step"?o.fires.map(t):[t(o.value)]})}function z(n,r,e,t){return"at "+p(n,t)+" "+r+"s past the "+e}function Ke(n,r,e){return(+n==0||+n==12)&&+r==0&&!(typeof e=="number"&&e>0)}function Pn(n){let r=n.filter(function(t){return Ke(t.hour,t.minute,t.second)});return r.length>0&&r.length<n.length}function yn(n,r){let e=Pn(n.map(function(o){return{hour:o,minute:0}})),t=n.map(function(o){return l({hour:o,minute:0,plain:e},r)});return p(t,r)}function Ye(n){return n.kind==="fires"&&n.fires.length===1}function I(n,r,e,t){return r.kind==="fires"?yn(r.fires,t):j(n,{minute:0,second:null},e,t)}function Ge(n){return n.kind==="range"?n.bounds:n.kind==="step"?n.fires:[n.value]}function j(n,r,e,t){let{minute:i,second:o}=r,u=c(n,"hour"),s=Pn(u.flatMap(function(y){return Ge(y).map(function(en){return{hour:+en,minute:i,second:o}})})),f=[];return u.forEach(function(y){y.kind==="step"?f.push(...y.fires.map(function(en){return l({hour:en,minute:i,second:o,plain:s},t)})):y.kind==="range"?f.push(l({hour:y.bounds[0],minute:i,second:o,plain:s},t)+h(t)+l({hour:y.bounds[1],minute:i,second:o,plain:s},t)):f.push(l({hour:y.value,minute:i,second:o,plain:s},t))}),p(Ze(f,u,e),t)}function Ze(n,r,e){let t=r.some(function(o){return o.kind==="range"});return!e||!t?n:n.map(function(o,u){return u===0?o:"at "+o})}function ar(n,r,e){if(n.length<=1)return n.join("");if(n.length===2)return n[0]+r+n[1];let t=e.style.serialComma?","+r:r;return n.slice(0,-1).join(", ")+t+n[n.length-1]}function p(n,r){return ar(n," and ",r)}function Be(n,r){return ar(n," or ",r)}var Xe={all:"",month:"in ",recurringWeekday:!0,stepDate:"on ",weekday:"on "},Cn={all:"every day",month:"every day in ",recurringWeekday:!1,stepDate:"",weekday:"every "};function a(n,r){if(K(n,r))return lr(n,r);let e=_(n,Xe,r);return e&&" "+e}function cr(n,r){return K(n,r)?"":_(n,Cn,r)+" "}function _(n,r,e){let t=n.pattern;if(t.date!=="*"&&t.weekday!=="*")return it(n,e);if(t.date!=="*")return _e(n,r,e);if(t.weekday!=="*"){let i=xn(t.weekday,e);return i?bn(i,n,e):r.weekday+pr(n,r.recurringWeekday,e)+dr(n,e)}return t.month!=="*"?r.month+N(n,e):r.all}function _e(n,r,e){let t=n.pattern,i=nn(t.date,e);return i?bn(i,n,e):E(t.date)?bn(r.stepDate+gr(t.date),n,e):t.month!=="*"&&!mr(n)?"on the "+Sn(n,e)+dr(n,e):t.month!=="*"?"on "+fr(n,e):"on the "+Sn(n,e)}function mr(n){return!hr(n.pattern.month)&&c(n,"month").every(function(e){return e.kind!=="range"})}function K(n,r){return n.pattern.date!=="*"&&n.pattern.weekday!=="*"&&!!r.style.untilWindow&&!r.short}function lr(n,r){let e=[...rt(n,r),...et(n,r)];return" whenever the day is "+Be(e,r)}function nt(n,r){return n.pattern.month==="*"?"":"in "+N(n,r)+" "}function rt(n,r){let e=n.pattern.date,t=nn(e,r);if(t)return[t.replace(/^on /,"")];let i=tt(e);if(i)return[i];let o=[];return c(n,"date").forEach(function(s){s.kind==="range"?o.push("from the "+b(s.bounds[0])+h(r)+"the "+b(s.bounds[1])):s.kind==="step"?s.fires.forEach(function(S){o.push("the "+b(S))}):o.push("the "+b(s.value))}),o}function et(n,r){let e=n.pattern.weekday,t=xn(e,r);if(t)return[t.replace(/^on /,"")];let i=[];return c(n,"weekday").forEach(function(u){u.kind==="range"&&u.bounds[0]==="1"&&u.bounds[1]==="5"?i.push("a weekday"):u.kind==="range"?i.push("a "+C(u.bounds[0],r)+h(r)+"a "+C(u.bounds[1],r)):u.kind==="step"?u.fires.forEach(function(f){i.push("a "+C(f,r))}):i.push("a "+C(u.value,r))}),i}function tt(n){if(!E(n))return null;let[r,e]=n.split("/");return+e!=2?null:r==="*"||r==="1"?"an odd-numbered day":r==="2"?"an even-numbered day":null}function it(n,r){let e=n.pattern,t=xn(e.weekday,r)||"on "+pr(n,!1,r);return e.month!=="*"&&mr(n)&&!nn(e.date,r)&&!E(e.date)?"on "+fr(n,r)+" or "+t+" in "+N(n,r):ot(n,r)+" or "+t+ut(n,r)}function ot(n,r){let e=n.pattern,t=nn(e.date,r);return t||(E(e.date)?gr(e.date):"on the "+Sn(n,r))}function ut(n,r){return n.pattern.month==="*"?"":", in "+N(n,r)}function nn(n,r){if(n==="L")return"on the last day of the month";if(n==="LW"||n==="WL")return"on the last weekday of the month";let e=/^L-(\d{1,2})$/.exec(n);if(e)return g(+e[1],r)+" "+v(e[1],"day")+" before the last day of the month";let t=/^(\d{1,2})W$|^W(\d{1,2})$/.exec(n);if(t)return"on the weekday nearest the "+b(t[1]||t[2])}function xn(n,r){let e=n.split("#");if(e.length===2)return"on the "+ie[+e[1]]+" "+C(e[0],r)+" of the month";if(/L$/.test(n))return"on the last "+C(n.slice(0,-1),r)+" of the month"}function fr(n,r){let e=N(n,r),t=rn(c(n,"date"),r.style.ordinals?b:st,r);return r.style.dayFirst&&n.shapes.date==="single"&&n.shapes.month!=="single"?"the "+b(n.pattern.date)+" of "+e:r.style.dayFirst?t+" "+e:e+" "+t}function st(n){return""+n}function dr(n,r){return n.pattern.month==="*"?"":" in "+N(n,r)}function bn(n,r,e){if(r.pattern.month==="*")return n;let t=n.indexOf(" of the month")!==-1;return t&&r.shapes.month==="range"?n.replace(" of the month"," of each month")+" from "+N(r,e):t&&(r.shapes.month==="single"||r.shapes.month==="step")?n.replace(" of the month","")+" in "+N(r,e):n+" in "+N(r,e)}function gr(n){let r=n.split("/"),e=+r[1],t=r[0],o=(e===2?"every other":"every "+b(e))+" day of the month";return t!=="*"&&t!=="1"&&(o+=" from the "+b(t)),o}function Sn(n,r){return rn(c(n,"date"),b,r)}function N(n,r){let e=hr(n.pattern.month);return e||rn(c(n,"month"),function(i){return ft(i,r)},r)}function hr(n){if(!E(n))return null;let[r,e]=n.split("/");return+e!=2?null:r==="*"||r==="1"?"every odd-numbered month":r==="2"?"every even-numbered month":null}function pr(n,r,e){let t=Un(c(n,"weekday")),i=t.some(function(s){return s.kind==="range"});return rn(t,r&&!i?function(s){return at(s,e)}:function(s){return C(s,e)},e)}function at(n,r){let e=C(n,r);return r.short?e:e+"s"}function rn(n,r,e){let t=[];return n.forEach(function(o){o.kind==="step"?t.push(...o.fires.map(r)):o.kind==="range"?t.push(o.bounds.map(r).join(h(e))):t.push(r(o.value))}),p(t,e)}function Bn(n,r,e){let t=r.pattern.year;if(t==="*")return n;if(t.indexOf("/")!==-1)return n+", "+mt(t,e);let i=ct(t,e);if(t.indexOf("-")===-1&&t.indexOf(",")===-1&&r.pattern.date!=="*"&&n.indexOf(" at ")!==-1){let o=e.style.dayFirst?" ":", ";return n.replace(" at ",o+i+" at ")}return n+" in "+i}function ct(n,r){return n.indexOf(",")!==-1?p(n.split(","),r):n.indexOf("-")!==-1?n.split("-").join(h(r)):n}function mt(n,r){let e=n.split("/"),t=+e[1],i=e[0];if(t<=1)return"every year";let o=t===2?"every other year":"every "+g(t,r)+" years";return i!=="*"&&i!=="0"&&(o+=" from "+i),o}function l(n,r){let{hour:e,minute:t,plain:i,explicit:o}=n,u=typeof n.second=="number"&&n.second>0?n.second:0;return r.ampm?lt({hour:e,minute:t,second:u,plain:i,explicit:o},r):dn({hour:e,minute:t,second:u},{pad:!0,sep:r.style.sep})}function lt(n,r){let{hour:e,minute:t,second:i,plain:o,explicit:u}=n,s=r.style;if(!o&&!u&&+t==0&&!i){if(+e==0)return s.midnight;if(+e==12)return s.midday}return dn({hour:e%12||12,minute:t,second:i},{lean:!u,sep:s.sep})+(s.closeUp?"":" ")+(e<12?s.am:s.pm)}function g(n,r){return Yn(n,re,r)}function v(n,r){return+n==1?r:r+"s"}function h(n){return n.short?"-":n.style.through}function b(n){let r=Math.abs(n),e=hn[r];return e||(r=(r%100-20)%10,e=hn[r]||hn[0]),n+e}function ft(n,r){let e=ee[+n];return e&&e[r.short?1:0]}function C(n,r){let e=n===7||n==="7"?0:n,t=P[e]||te[e];return t&&t[r.short?1:0]}var dt={describe:ue,fallback:"an unrecognizable cron pattern",options:oe,reboot:"at system startup",sentence:n=>"Runs "+n+(n.endsWith(".")?"":".")},yr=dt;/**
|
|
1
|
+
"use strict";(()=>{var wr={SUN:0,MON:1,TUE:2,WED:3,THU:4,FRI:5,SAT:6},vr={JAN:1,FEB:2,MAR:3,APR:4,MAY:5,JUN:6,JUL:7,AUG:8,SEP:9,OCT:10,NOV:11,DEC:12},k={second:{cyclic:!0,max:59,min:0,top:59},minute:{cyclic:!0,max:59,min:0,top:59},hour:{cyclic:!0,max:23,min:0,top:23},date:{cyclic:!0,max:31,min:1,top:31},month:{cyclic:!0,max:12,min:1,numbers:vr,top:12},weekday:{aliases:{L:"6"},cyclic:!0,max:7,min:0,numbers:wr,top:6},year:{max:9999,min:1970}},F=["second","minute","hour","date","month","weekday","year"],tn={"@annually":"0 0 1 1 *","@yearly":"0 0 1 1 *","@monthly":"0 0 1 * *","@weekly":"0 0 * * 0","@daily":"0 0 * * *","@midnight":"0 0 * * *","@hourly":"0 * * * *"},U=6;function f(n,r){return(""+n).indexOf(r)!==-1}function G(n){return Array.from(new Set(n))}function L(n){return/^\d+$/.test(n)}function d(n,r){return L(n)?+n:r[n.toUpperCase()]}function Wn(n){return F.forEach(function(e){Cr(n[e],k[e],e)}),n}function Cr(n,r,e){typeof n!="string"&&typeof n!="number"&&Tn(n,e);let t=""+n;t!=="*"&&(e==="date"&&q(t)||e==="weekday"&&Q(t,r)||t.split(",").forEach(function(o){xr(o,r)||Tn(o,e)}))}function q(n){if(n==="L"||n==="LW"||n==="WL")return!0;let r=/^L-(\d{1,2})$/.exec(n);if(r)return+r[1]>=1&&+r[1]<=30;let e=/^(\d{1,2})W$|^W(\d{1,2})$/.exec(n);if(e){let t=+(e[1]||e[2]);return t>=1&&t<=31}return!1}function Q(n,r){if(/L$/.test(n))return E(n.slice(0,-1),r);let e=n.split("#");return e.length===2?E(e[0],r)&&/^[1-5]$/.test(e[1]):!1}function xr(n,r){return f(n,"/")?Pr(n,r):f(n,"-")?Hn(n,r):E(n,r)}function Pr(n,r){let e=n.split("/");return e.length!==2||!L(e[1])||+e[1]<1?!1:e[0]==="*"||E(e[0],r)||Hn(e[0],r,!0)}function Hn(n,r,e){let t=n.split("-");return t.length!==2||!E(t[0],r)||!E(t[1],r)?!1:r.cyclic&&!e?!0:d(t[0],r.numbers)<=d(t[1],r.numbers)}function E(n,r){return n==="*"?!1:L(n)?+n>=r.min&&+n<=r.max:r.numbers?n.toUpperCase()in r.numbers:!1}function Tn(n,r){throw new Error('`cronli5` was passed an invalid field value "'+n+'" for the '+r+" field.")}var Mr={hour:24,minute:60,second:60};function En(n){F.forEach(function(e){let t=k[e].aliases,i=t&&t[""+n[e]];i&&(n[e]=i)})}function jn(n){return F.forEach(function(e){let t=""+n[e];if(e==="date"&&q(t)||e==="weekday"&&Q(t,k[e])){n[e]=t;return}n[e]=Fr(t,e,k[e])}),n}function Fr(n,r,e){let t=""+n;if(t==="*")return t;let i=Mr[r],o=t.split(",").map(function(s){return Tr(Dn(Er(jr(Dr(Lr(Hr(s,e),e),e),e),e,i),e),e)}).join(",").split(",");return o.indexOf("*")!==-1?"*":G(o).sort(function(s,m){return Ln(s,e)-Ln(m,e)}).join(",")}function Tr(n,r){if(!r.numbers)return n;let e=n.split("/"),t=e[0].split("-").map(function(o){return Wr(o,r)}).join("-");return e.length===2?t+"/"+e[1]:t}function Wr(n,r){if(n==="*")return n;let e=d(n,r.numbers);return""+(e>r.top?r.min:e)}function Hr(n,r){let e=n.split("/");if(!r.cyclic||e.length!==2||+e[1]!=1)return n;let t=e[0];return f(t,"-")?t:t==="*"||d(t,r.numbers)===r.min?"*":t+"-"+r.top}function Lr(n,r){let e=n.split("/");if(!r.cyclic||typeof r.top!="number"||e.length!==2||f(e[0],"-"))return n;let t=e[0];return(t==="*"?r.min:d(t,r.numbers))+ +e[1]<=r.top?n:t==="*"?""+r.min:t}function Er(n,r,e){let t=n.split("/");if(typeof e!="number"||t.length!==2||f(t[0],"-"))return n;let i=+t[1],o=t[0]==="*"?r.min:d(t[0]);if(e%i===0&&o<i)return n;let u=[];for(let s=o;s<=r.top;s+=i)u.push(s);return u.join(",")}function jr(n,r){let e=n.split("/");return e.length!==2||!f(e[0],"-")?n:Dn(e[0],r)==="*"?"*/"+e[1]:n}function Dn(n,r){if(typeof r.top!="number"||f(n,"/")||!f(n,"-"))return n;let e=n.split("-"),t=d(e[0],r.numbers),i=d(e[1],r.numbers);if(t>i)return n;let o=r.top,u={};for(let s=t;s<=i;s+=1)u[s>o?r.min:s]=!0;for(let s=r.min;s<=o;s+=1)if(!u[s])return n;return"*"}function Dr(n,r){let e=n.split("/")[0];if(!f(e,"-"))return n;let t=e.split("-");return d(t[0],r.numbers)!==d(t[1],r.numbers)?n:t[0]}function Ln(n,r){let e=n.split("/")[0].split("-")[0];return e==="*"?r.min:d(e,r.numbers)}var Rr="`?` is a Quartz token \u2014 pass { quartz: true } to enable Quartz semantics.";function An(n,r){if(!r){Rn(n.date),Rn(n.weekday);return}if(""+n.date=="?"&&(n.date="*"),""+n.weekday=="?"){n.weekday="*";return}n.weekday=Ar(""+n.weekday)}function Rn(n){if(""+n=="?")throw new Error(Rr)}function Ar(n){return n==="*"?n:n.split(",").map(Ur).join(",")}function Ur(n){let r=/(#\d+|L)$/.exec(n),e=r?r[0]:"",i=(e?n.slice(0,-e.length):n).split("/"),o=i[0].split("-").map(qr).join("-");return(i.length===2?o+"/"+i[1]:o)+e}function qr(n){if(!L(n))return n;if(n==="0")throw new Error('`cronli5` was passed an invalid Quartz day-of-week value "0"; Quartz numbers weekdays 1 (Sunday) through 7 (Saturday).');return""+(+n-1)}function Un(n,r){let e=n instanceof Array;if(n===null||typeof n>"u"||n===""||e&&n.length===0)throw new Error("`cronli5` expects a non-empty cron pattern as the first argument.");if(e)return qn(n,r);if(typeof n=="object")return Qr(n);if(typeof n=="string")return Vr(n,r);throw new Error("`cronli5` was passed an unexpected type.")}function qn(n,r){if(n.length>7)throw new Error("`cronli5` was passed a cron pattern with more than seven fields.");return!r.seconds&&n.length<(r.years?7:6)&&n.unshift("0"),{second:n[0]||"0",minute:n[1]||"*",hour:n[2]||"*",date:n[3]||"*",month:n[4]||"*",weekday:n[5]||"*",year:n[6]||"*"}}function Qr(n){if(!n.second&&!n.minute&&!n.hour)throw new Error("`cronli5` expects that any object being interpreted as a cron pattern have at least one of the following properties: `second`, `minute`, or `hour`");let r=typeof n.second<"u",e=typeof n.minute<"u",t=r?"*":"0",i=r||e?"*":"0";return{second:T(n.second,"0"),minute:T(n.minute,t),hour:T(n.hour,i),date:T(n.date,"*"),month:T(n.month,"*"),weekday:T(n.weekday,"*"),year:T(n.year,"*")}}function T(n,r){return typeof n>"u"?r:n}function Vr(n,r){let e=Ir(n).split(/\s+/);return qn(e,r)}function Ir(n){let r=n.trim();if(r.charAt(0)!=="@")return n;let e=r.toLowerCase();if(Object.hasOwn(tn,e))return tn[e];throw new Error("`cronli5` does not recognize the macro `"+r+"`.")}function Qn(n){return n===0?7:n}function Vn(n){let r=n.flatMap(function(i){return i.kind==="step"?i.fires.map(function(u){return{kind:"single",value:""+u}}):[i]});function e(t){return t.kind==="range"?Qn(+t.bounds[0]):Qn(+t.value)}return r.map(function(i,o){return[i,o]}).sort(function(i,o){return e(i[0])-e(o[0])||i[1]-o[1]}).map(function(i){return i[0]})}function on(n){if(n.length<5)return null;let r=n[1]-n[0];if(r<2)return null;for(let e=2;e<n.length;e+=1)if(n[e]-n[e-1]!==r)return null;return{start:n[0],interval:r,last:n[n.length-1]}}function c(n,r){return n.analyses.segments[r]??[]}function O(n,r){return c(n,r)[0]}function Z(n){let r=[];for(let e of n){if(e.kind!=="single")return null;r.push(+e.value)}return r}function un(n){return n.start<n.interval&&24%n.interval===0}function $r(n,r,e){return e-1-(e-1-n)%r}function sn(n,r){let{start:e,interval:t,last:i,cycle:o}=n,u=o%t===0&&i===$r(e,t,o);return e===0&&u?r.bare():e<t&&u?r.offset():r.bounded()}function In(n){if(n.length<2)return null;let r=n[1]-n[0];if(r<2)return null;for(let e=2;e<n.length;e+=1)if(n[e]-n[e-1]!==r)return null;return n[0]!==0&&n.length<5?null:{interval:r,last:n[n.length-1],start:n[0]}}function $n(n){return n!=="*"&&!f(n,",")&&!f(n,"-")&&!f(n,"/")}function an(n){return f(n,"-")&&!f(n,",")&&!f(n,"/")}function Jr(n){return f(n,"/")&&!f(n,",")}function cn(n){return n!=="*"&&!f(n,"-")&&!f(n,"/")}function fn(n){return n!=="*"&&!an(n)&&!Jr(n)}function j(n){return n.indexOf("/")!==-1&&n.indexOf("-")===-1&&n.indexOf(",")===-1}function V(n,r,e){let t=[],i=n;for(;i<=e;)t.push(i),i+=r;return t}function Jn(n,r,e,t){let i=n.split("/"),o=+i[1];if(f(i[0],"-")){let s=i[0].split("-");return V(d(s[0],t),o,d(s[1],t))}let u=i[0]==="*"?r:d(i[0],t);return V(u,o,e)}function mn(n,r,e){let t=[];return n.split(",").forEach(function(o){if(f(o,"/"))t.push(...Jn(o,r,e));else if(f(o,"-")){let u=o.split("-");+u[0]<=+u[1]?t.push(...V(+u[0],1,+u[1])):(t.push(...V(+u[0],1,e)),t.push(...V(r,1,+u[1])))}else t.push(+o)}),G(t)}function Kr(n){return cn(n)?n.split(",").map(Number):[0]}function Yr(n){if(n==="*")return[0,59];if(an(n)){let r=n.split("-");if(+r[0]<=+r[1])return[+r[0],+r[1]]}return null}function Gr(n){return n==="*"?59:Math.max(...mn(n,0,59))}function Zr(n){if($n(n)&&n!=="0")return+n}function Br(n,r){return n==="*"?"wildcard":r==="date"&&q(n)||r==="weekday"&&Q(n,k.weekday)?"quartz":f(n,",")?"list":f(n,"/")?"step":f(n,"-")?"range":"single"}function Xr(n,r,e){return r==="wildcard"||r==="quartz"?null:n.split(",").map(function(i){if(f(i,"/")){let o=i.split("/");return{fires:Jn(i,e.min,e.top,e.numbers),interval:+o[1],kind:"step",startToken:o[0]}}return f(i,"-")?{bounds:i.split("-"),kind:"range"}:{kind:"single",value:i}})}function Kn(n){let r={},e={};F.forEach(function(u){r[u]=Br(n[u],u),e[u]=Xr(n[u],r[u],k[u])});let i={analyses:{clockSecond:Zr(n.second),lastMinuteFire:Gr(n.minute),minuteSpan:Yr(n.minute),segments:e},pattern:n,shapes:r};return{...i,plan:_r(i)}}function _r(n){let{analyses:r,pattern:e,shapes:t}=n;if(e.second!=="0"){let i=ne(e,t,r);if(i)return i}return Yn(e,t,r)||Gn(e,t,r)}function ne(n,r,e){let t=re(n,r);return t||(n.hour==="*"&&r.minute==="single"&&n.second!=="*"?{kind:"secondsWithinMinute",singleSecond:r.second==="single"}:r.second==="single"&&cn(n.minute)&&fn(n.hour)?null:{kind:"composeSeconds",rest:Yn(n,r,e,!0)||Gn(n,r,e,!0)})}function re(n,r){return n.minute!=="*"||n.hour!=="*"?null:n.second==="*"?{kind:"everySecond"}:r.second==="single"?{kind:"secondPastMinute"}:{kind:"standaloneSeconds"}}function Yn(n,r,e,t=!1){if(r.minute==="step")return{hours:te(n,r,e),kind:"minuteFrequency"};if(r.hour==="single"&&e.minuteSpan)return{hour:+n.hour,kind:"minuteSpanInHour",span:e.minuteSpan};let i=ie(n,r);if(i)return i;let o=ee(n,r);if(o)return o;if(n.hour==="*")return oe(n,r,t)}function ln(n){let[r,e]=n.split("/"),t=r==="*"?0:+r;return r.indexOf("-")===-1&&24%+e===0&&t<+e}function ee(n,r){return r.hour!=="step"?null:n.minute==="*"?ln(n.hour)?{form:"wildcard",kind:"minuteSpanAcrossHourStep"}:{form:"wildcard",kind:"minutesAcrossHours",times:I(n.hour)}:r.minute==="range"?{form:"range",kind:"minuteSpanAcrossHourStep"}:r.minute==="list"&&ln(n.hour)?{form:"list",kind:"minuteSpanAcrossHourStep"}:null}function te(n,r,e){if(r.hour==="list")return{kind:"during",times:I(n.hour)};if(r.hour==="range"){let t=n.hour.split("-");return{from:+t[0],kind:"window",last:e.lastMinuteFire,to:+t[1]}}return r.hour==="single"?{from:+n.hour,kind:"window",last:e.lastMinuteFire,to:+n.hour}:r.hour==="step"?ln(n.hour)?{kind:"step"}:{kind:"during",times:I(n.hour)}:{kind:"none"}}function ie(n,r){return fn(n.hour)?n.minute==="*"?{form:"wildcard",kind:"minutesAcrossHours",times:I(n.hour)}:r.minute==="range"||r.minute==="list"&&f(n.minute,"-")&&!f(n.minute,"/")?{form:r.minute==="range"?"range":"list",kind:"minutesAcrossHours",times:I(n.hour)}:null:null}function oe(n,r,e){if(r.minute==="range")return{kind:"rangeOfMinutes"};if(r.minute==="list")return{kind:"multipleMinutes"};if(n.minute==="*")return{kind:"everyMinute"};if(n.minute!=="0"||e)return{kind:"singleMinute"}}function Gn(n,r,e,t=!1){let i=t&&n.minute==="0";return r.hour==="range"&&!i?ue(n,r,e):r.hour==="step"&&n.minute==="0"&&!t?{kind:"hourStep"}:n.hour==="*"&&!i?{kind:"everyHour"}:se(n,e,i)}function ue(n,r,e){let t=n.hour.split("-"),i="lead";return n.minute==="*"?i="wildcard":r.minute==="range"&&(i="range"),{boundMinute:r.minute==="range"||r.minute==="list"?null:e.lastMinuteFire,from:+t[0],kind:"hourRange",last:e.lastMinuteFire,minuteForm:i,to:+t[1]}}function se(n,r,e=!1){let t=mn(n.hour,0,23),i=Kr(n.minute);if(!e&&t.length*i.length>U)return{fold:i.length===1,kind:"compactClockTimes",minute:i[0]};let o=[];return t.forEach(function(s){i.forEach(function(S){o.push({hour:s,minute:S,second:r.clockSecond})})}),{kind:"clockTimes",times:o}}function I(n){let r=mn(n,0,23);return r.length<=U?{fires:r,kind:"fires"}:{kind:"segments"}}function Zn(n,r){let e=Un(n,r);return An(e,r.quartz),En(e),Wn(e),jn(e)}function v(n){return n=""+n,n.length<2?"0"+n:n}function Bn(n,r,e){return e.short?n:r[n]||n}function dn(n,{sep:r,pad:e,lean:t}){let i=e?v(n.hour):""+n.hour;return t&&!n.minute&&!n.second?i:i+r+v(n.minute)+(n.second?r+v(n.second):"")}var gn={gb:{am:"am",closeUp:!0,dayFirst:!0,midday:"midday",midnight:"midnight",ordinals:!1,pm:"pm",sep:".",serialComma:!1,through:" to "},us:{am:"a.m.",closeUp:!1,dayFirst:!1,midday:"noon",midnight:"midnight",ordinals:!1,pm:"p.m.",sep:":",serialComma:!0,through:" through ",untilWindow:!0},house:{am:"AM",closeUp:!1,dayFirst:!1,midday:"noon",midnight:"midnight",ordinals:!0,pm:"PM",sep:":",serialComma:!0,through:" - "}};function Xn(n){return typeof n=="object"&&n!==null?{...gn.us,untilWindow:!1,...n}:gn[n==="uk"?"gb":n]||gn.us}var ae=["zero","one","two","three","four","five","six","seven","eight","nine","ten"],hn=["th","st","nd","rd"],ce=[null,["January","Jan"],["February","Feb"],["March","Mar"],["April","Apr"],["May","May"],["June","Jun"],["July","Jul"],["August","Aug"],["September","Sep"],["October","Oct"],["November","Nov"],["December","Dec"]],C=[["Sunday","Sun"],["Monday","Mon"],["Tuesday","Tue"],["Wednesday","Wed"],["Thursday","Thu"],["Friday","Fri"],["Saturday","Sat"]],fe={SUN:C[0],MON:C[1],TUE:C[2],WED:C[3],THU:C[4],FRI:C[5],SAT:C[6]},le=[null,"first","second","third","fourth","fifth"];function me(n){return n=n||{},{ampm:typeof n.ampm=="boolean"?n.ampm:!0,lenient:!!n.lenient,quartz:!!n.quartz,seconds:!!n.seconds,short:!!n.short,style:Xn(n.dialect),years:!!n.years}}function de(n,r){let e=ye(n,r);if(e!==null)return nr(e,n,r);let t=Ge(n,r)??rr(n,n.plan,r),i=Y(n,r)?st(n,r):"";return nr(i+t,n,r)}function rr(n,r,e){let t=Ze[r.kind];return t(n,r,e)}function pn(n){return n==="step"||n==="range"||n==="list"}function ge(n,r){if(!r.style.untilWindow||r.short||n.plan.kind!=="composeSeconds"||n.plan.rest.kind==="clockTimes"||Y(n,r))return!1;let{shapes:e}=n;return pn(e.second)&&pn(e.minute)&&pn(e.hour)}function he(n,r){let e=On(n);if(e)return B(e,r);if(n.shapes.hour==="range"){let t=c(n,"hour").find(function(o){return o.kind==="range"});return A({continuous:!1,from:+t.bounds[0],throughMinute:0,to:+t.bounds[1]},r)}return"during the "+R(n,{minute:0,second:null},!1,r)+" hours"}function pe(n,r){return n.shapes.minute==="step"?X(O(n,"minute"),"minute","hour",r):n.shapes.minute==="range"?J(n.pattern.minute,r):H(c(n,"minute"),"minute","hour",r)??z(M(c(n,"minute"),r),"minute","hour",r)}function ye(n,r){if(!ge(n,r))return null;let e=he(n,r),t=pe(n,r),i=P(n,"minute",r),o=e+", "+t+", and within each of those minutes, "+i,u=a(n,r).trim();return u?u+", "+o:o}function be(n,r,e){return"every second"+a(n,e)}function Se(n,r,e){return D(n,e)+a(n,e)}function ke(n,r,e){let t=n.pattern.second;return g(t,e)+" "+w(t,"second")+" past the minute, every minute"+a(n,e)}function Oe(n,r,e){let t=n.pattern.minute,i=g(t,e),o=w(t,"minute");if(r.singleSecond){let u=n.pattern.second;return i+" "+o+" and "+g(u,e)+" "+w(u,"second")+" past the hour, every hour"+a(n,e)}return D(n,e)+", "+i+" "+o+" past the hour, every hour"+a(n,e)}function Ne(n,r,e){if(!(r.rest.kind==="clockTimes"||r.rest.kind==="compactClockTimes")||n.shapes.minute!=="single")return null;let i=+n.pattern.minute;return zn(n,i,e)??wn(n,i,e)}function ze(n,r,e){return+r.times[0].minute==0&&n.shapes.minute==="single"?D(n,e)+" for one minute at "+ve(n,r,e):D(n,e)+" of "+Ce(n,r,e)}function we(n,r,e){let t=Ne(n,r,e);return t!==null?t:r.rest.kind==="clockTimes"&&(n.shapes.second==="wildcard"||n.shapes.second==="step")?ze(n,r.rest,e):n.shapes.second==="wildcard"&&r.rest.kind==="minuteFrequency"&&r.rest.hours.kind==="none"&&n.pattern.minute==="*/2"?"every second of every other minute"+a(n,e):(r.rest.kind==="compactClockTimes"&&n.analyses.clockSecond?"":D(n,e)+", ")+rr(n,r.rest,e)}function ve(n,r,e){let t=r.times.map(function(u){return l({hour:u.hour,minute:0},e)}),i=_(n,xn,e);return p(t,e)+(i&&", "+i)}function Ce(n,r,e){let t=r.times.map(function(u){return l({hour:u.hour,minute:u.minute,second:u.second,explicit:!0},e)}),i=_(n,xn,e);return p(t,e)+(i&&", "+i)}function D(n,r){return P(n,"minute",r)}function P(n,r,e){let t=n.pattern.second,i=n.shapes.second;if(t==="*")return"every second";if(i==="step")return X(O(n,"second"),"second",r,e);if(i==="range"){let o=t.split("-"),u=vn();return"every second from "+u(o[0])+h(e)+u(o[1])+" past the "+r}return i==="single"?"at "+g(t,e)+" "+w(t,"second")+" past the "+r:H(c(n,"second"),"second",r,e)??z(M(c(n,"second"),e),"second",r,e)}function xe(n,r,e){return"every minute"+a(n,e)}function Pe(n,r,e){let t=n.pattern.minute;return g(t,e)+" "+w(t,"minute")+" past the hour, every hour"+a(n,e)}function Me(n,r,e){return J(n.pattern.minute,e)+a(n,e)}function Fe(n,r,e){return(H(c(n,"minute"),"minute","hour",e)??z(M(c(n,"minute"),e),"minute","hour",e))+a(n,e)}function Te(n,r,e){let t=X(O(n,"minute"),"minute","hour",e);if(r.hours.kind==="during"){let i=K(n,e);t+=i?", "+i:" during the "+$(n,r.hours.times,!1,e)+" hours"}else r.hours.kind==="window"?t+=" "+A({continuous:!1,from:r.hours.from,throughMinute:r.hours.last,to:r.hours.to},e):r.hours.kind==="step"&&(t+=" "+kn(O(n,"hour"),e));return t+a(n,e)}function We(n,r,e){return n.pattern.minute==="*"?"every minute of the "+l({hour:r.hour,minute:0},e)+" hour"+a(n,e):"every minute from "+l({hour:r.hour,minute:r.span[0]},e)+h(e)+l({hour:r.hour,minute:r.span[1]},e)+a(n,e)}function He(n,r,e){let t=K(n,e);if(r.form==="wildcard")return t!==null?"every minute, "+t+a(n,e):"every minute during the "+$(n,r.times,!1,e)+" hours"+a(n,e);if(r.form==="range"){let u=J(n.pattern.minute,e);return t!==null?u+", "+t+a(n,e):rt(r.times)?u+", at "+$(n,r.times,!0,e)+a(n,e):u+" during the "+$(n,r.times,!1,e)+" hours"+a(n,e)}let i=H(c(n,"minute"),"minute","hour",e)??z(M(c(n,"minute"),e),"minute","hour",e);if(t!==null)return i+", "+t+a(n,e);let o=$(n,r.times,!0,e);return i+", at "+o+a(n,e)}var er={2:"other",3:"third",4:"fourth",6:"sixth",8:"eighth",12:"twelfth"};function kn(n,r){let e="during every "+er[n.interval]+" hour",t=n.startToken==="*"?0:+n.startToken;return t===0?e:e+" starting at "+l({hour:t,minute:0},r)}function Le(n,r,e){let t=O(n,"hour");if(r.form==="wildcard")return"every minute "+kn(t,e)+a(n,e);let i=r.form==="list"?H(c(n,"minute"),"minute","hour",e)??z(M(c(n,"minute"),e),"minute","hour",e):J(n.pattern.minute,e),o=K(n,e);return i+", "+(o??ar(t,e))+a(n,e)}function J(n,r){let e=n.split("-"),t=vn();return"every minute from "+t(e[0])+h(r)+t(e[1])+" past the hour"}function Ee(n,r,e){return"every hour"+a(n,e)}function je(n,r,e){let t=Ae(Re(r),e);return r.minuteForm==="wildcard"?"every minute "+t+a(n,e):r.minuteForm==="range"?J(n.pattern.minute,e)+", "+t+a(n,e):tr(n,e)+" "+t+a(n,e)}function tr(n,r){return n.pattern.minute==="0"?"every hour":H(c(n,"minute"),"minute","hour",r)??z(M(c(n,"minute"),r),"minute","hour",r)}function De(n,r,e){let t=K(n,e);return t!==null?t+a(n,e):ar(O(n,"hour"),e)+a(n,e)}function Re(n){let r=n.minuteForm==="wildcard",e=r?n.boundMinute??0:0;return{from:n.from,closeMinute:e,to:n.to,continuous:r}}function A(n,r){let{from:e,to:t,throughMinute:i,continuous:o}=n,u="from "+l({hour:e,minute:0},r);return r.style.untilWindow&&!r.short&&e!==t?o?u+" until "+l({hour:(t+1)%24,minute:0},r):u+h(r)+l({hour:t,minute:0},r):u+h(r)+l({hour:t,minute:i},r)}function Ae(n,r){return A({continuous:n.continuous,from:n.from,throughMinute:n.closeMinute,to:n.to},r)}function Ue(n,r,e){if(n.shapes.minute==="single"){let o=+n.pattern.minute,u=zn(n,o,e)??wn(n,o,e);if(u!==null)return u}let t=Cn(r.times),i=r.times.map(function(u){return l({hour:u.hour,minute:u.minute,second:u.second,plain:t},e)});return mr(n,e)+"at "+p(i,e)+ir(n,e)}function ir(n,r){return Y(n,r)?gr(n,r):""}function qe(n,r,e){if(r.fold){let u=zn(n,+r.minute,e)??wn(n,+r.minute,e);if(u!==null)return u;if(c(n,"hour").some(function(y){return y.kind==="range"})&&!n.analyses.clockSecond)return Qe(n,r,e)+a(n,e);let m={minute:r.minute,second:n.analyses.clockSecond};return mr(n,e)+"at "+R(n,m,!0,e)+ir(n,e)}let t=H(c(n,"minute"),"minute","hour",e)??z(M(c(n,"minute"),e),"minute","hour",e),i=K(n,e),o=i?t+", "+i+a(n,e):t+", at "+R(n,{minute:0,second:null},!0,e)+a(n,e);return n.analyses.clockSecond?D(n,e)+", "+o:o}function Qe(n,r,e){let t=r.minute,i=[],o=or(n).map(function(m){return l({hour:m,minute:t},e)});return c(n,"hour").forEach(function(m){m.kind==="range"&&i.push(A({continuous:!1,from:+m.bounds[0],throughMinute:t,to:+m.bounds[1]},e))}),tr(n,e)+" "+p(i,e)+ur(o,e)}function or(n){let r=[];return c(n,"hour").forEach(function(t){t.kind==="step"?r.push(...t.fires):t.kind!=="range"&&r.push(+t.value)}),r}function ur(n,r){return n.length?" and at "+p(n,r):""}function W(n){return n==="*"||n.startsWith("*/")&&n.indexOf("-")===-1}function Ve(n,r){let{second:e,minute:t}=n.pattern;return W(e)?{secondLead:!0,text:P(n,"minute",r)}:e==="0"&&W(t)?{secondLead:!1,text:t==="*"?"every minute":X(O(n,"minute"),"minute","hour",r)}:null}function Ie(n,r){let e=n.pattern.minute;if(e==="*")return"";if(W(e))return" of every other minute";let t=c(n,"minute");if(n.shapes.minute==="single")return" during minute :"+v(e);if(n.shapes.minute==="range"){let o=e.split("-");return" during minutes :"+v(o[0])+h(r)+":"+v(o[1])}let i=M(t,r).map(function(u){return":"+v(u)});return" during minutes "+p(i,r)}function $e(n,r){let e=n.pattern.hour;if(e==="*")return n.pattern.minute!=="*"&&!W(n.pattern.minute)?" of every hour":"";if(W(e))return e==="*/2"?" of every other hour":"";if(n.shapes.hour==="single"){let t=+e;return n.shapes.minute==="step"?" from "+l({hour:t,minute:0},r)+" until "+l({hour:(t+1)%24,minute:0},r):n.pattern.minute!=="*"&&!W(n.pattern.minute)?" at "+l({hour:t,minute:0},r):" of the "+l({hour:t,minute:0},r)+" hour"}if(n.shapes.hour==="range"){let t=e.split("-");return" "+A({continuous:n.pattern.minute==="*",from:+t[0],throughMinute:0,to:+t[1]},r)}return" during the "+R(n,{minute:0,second:null},!1,r)+" hours"}function Je(n){if(n.shapes.hour!=="step")return!0;let r=O(n,"hour");return n.pattern.hour==="*/2"||r.startToken.indexOf("-")!==-1}function Ke(n){if(n.shapes.minute!=="list")return!1;let r=Z(c(n,"minute"));return r!==null&&on(r)!==null}function Ye(n,r){let{minute:e,hour:t}=n.pattern,i=W(e)&&e!=="*";return Je(n)?r.secondLead?i?e==="*/2"&&n.shapes.hour!=="range":!(Ke(n)||n.shapes.minute==="list"&&n.shapes.hour==="list"):t==="*/2"?!0:n.shapes.hour==="single"&&e==="*/2":!1}function Ge(n,r){if(!r.style.untilWindow||r.short||n.pattern.minute==="*"&&n.pattern.hour==="*")return null;let e=Ve(n,r);if(!e||!Ye(n,e))return null;let t=e.secondLead?Ie(n,r):"";return e.text+t+$e(n,r)+a(n,r)}var Ze={clockTimes:Ue,compactClockTimes:qe,composeSeconds:we,everyHour:Ee,everyMinute:xe,everySecond:be,hourRange:je,hourStep:De,minuteFrequency:Te,minuteSpanAcrossHourStep:Le,minuteSpanInHour:We,minutesAcrossHours:He,multipleMinutes:Fe,rangeOfMinutes:Me,secondPastMinute:ke,secondsWithinMinute:Oe,singleMinute:Pe,standaloneSeconds:Se};function sr(n,r){let{interval:e,start:t,last:i,cycle:o,unit:u,anchor:s}=n,m="every "+g(e,r)+" "+u+"s";return sn({start:t,interval:e,last:i,cycle:o},{bare:()=>m,offset:()=>m+" from "+g(t,r)+" "+w(t,u)+" past the "+s,bounded:()=>{let S=vn();return m+" from "+S(t)+h(r)+S(i)+" "+w(i,u)+" past the "+s}})}function H(n,r,e,t){let i=Z(n),o=i&&on(i);return o?sr({...o,cycle:60,unit:r,anchor:e},t):null}function X(n,r,e,t){if(n.startToken.indexOf("-")!==-1)return z(_n(n.fires,t),r,e,t);let i=n.startToken==="*"?0:+n.startToken;return i!==0&&n.fires.length<=3?z(_n(n.fires,t),r,e,t):sr({interval:n.interval,start:i,last:n.fires[n.fires.length-1],cycle:60,unit:r,anchor:e},t)}function ar(n,r){if(n.startToken.indexOf("-")!==-1)return"at "+yn(n.fires,r);let e=n.startToken==="*"?0:+n.startToken,t=n.interval;return e===0?"every "+g(t,r)+" hours":n.fires.length<=3?"at "+yn(n.fires,r):"every "+g(t,r)+" hours from "+l({hour:e,minute:0},r)}function B(n,r){let{start:e,interval:t,last:i}=n,o="every "+g(t,r)+" hours";return sn({start:e,interval:t,last:i,cycle:24},{bare:()=>o,offset:()=>o+" from "+l({hour:e,minute:0},r),bounded:()=>o+" from "+l({hour:e,minute:0},r)+h(r)+l({hour:i,minute:0},r)})}function K(n,r){let e=On(n);return!e||un(e)?null:B(e,r)}function On(n){let r=c(n,"hour");if(r.length===1&&r[0].kind==="step"){let t=r[0];if(t.fires.length<2)return null;let i=t.startToken==="*"?0:+t.startToken.split("-")[0];return{interval:t.interval,last:t.fires[t.fires.length-1],start:i}}let e=Z(r);return e&&In(e)}function Nn(n){return n.pattern.second==="*"||n.shapes.second==="step"}function cr(n,r,e){if(r===0)return Nn(n)?P(n,"minute",e)+" for one minute":P(n,"hour",e);let t=g(r,e)+" "+w(r,"minute")+" past the hour";return n.pattern.second==="0"?t:P(n,"minute",e)+", "+t}function zn(n,r,e){let t=On(n);if(!t)return null;let i=(t.last-t.start)/t.interval+1;if(n.pattern.second==="0"&&i<=U&&un(t))return null;let o=r===0&&Nn(n)&&Be(n);return o?P(n,"minute",e)+" for one minute "+kn(o,e)+a(n,e):r===0&&n.pattern.second==="0"?B(t,e)+a(n,e):cr(n,r,e)+", "+B(t,e)+a(n,e)}function Be(n){let r=c(n,"hour"),e=r.length===1&&r[0];return!e||e.kind!=="step"||e.startToken.indexOf("-")!==-1||!(e.interval in er)?null:e}function Xe(n){return c(n,"hour").some(function(e){return e.kind==="range"})}function _e(n,r){let e=[],t=or(n);c(n,"hour").forEach(function(s){s.kind==="range"&&e.push(A({continuous:!1,from:+s.bounds[0],throughMinute:0,to:+s.bounds[1]},r))});let i="every hour "+p(e,r),o=t.map(function(s){return l({hour:s,minute:0},r)});return i+ur(o,r)}function wn(n,r,e){return r!==0||!Xe(n)||n.pattern.second==="0"?null:Nn(n)?P(n,"minute",e)+" for one minute during the "+R(n,{minute:0,second:null},!1,e)+" hours"+a(n,e):cr(n,r,e)+", "+_e(n,e)+a(n,e)}function vn(){return function(r){return""+r}}function fr(n,r){return n>1?function(t){return""+t}:function(t){return g(t,r)}}function _n(n,r){return n.map(fr(n.length,r))}function M(n,r){let e=n.reduce(function(o,u){return u.kind==="range"?o+1:o+(u.kind==="step"?u.fires.length:1)},0),t=fr(e,r);return n.flatMap(function(o){return o.kind==="range"?[t(o.bounds[0])+h(r)+t(o.bounds[1])]:o.kind==="step"?o.fires.map(t):[t(o.value)]})}function z(n,r,e,t){return"at "+p(n,t)+" "+r+"s past the "+e}function nt(n,r,e){return(+n==0||+n==12)&&+r==0&&!(typeof e=="number"&&e>0)}function Cn(n){let r=n.filter(function(t){return nt(t.hour,t.minute,t.second)});return r.length>0&&r.length<n.length}function yn(n,r){let e=Cn(n.map(function(o){return{hour:o,minute:0}})),t=n.map(function(o){return l({hour:o,minute:0,plain:e},r)});return p(t,r)}function rt(n){return n.kind==="fires"&&n.fires.length===1}function $(n,r,e,t){return r.kind==="fires"?yn(r.fires,t):R(n,{minute:0,second:null},e,t)}function et(n){return n.kind==="range"?n.bounds:n.kind==="step"?n.fires:[n.value]}function R(n,r,e,t){let{minute:i,second:o}=r,u=c(n,"hour"),s=Cn(u.flatMap(function(y){return et(y).map(function(en){return{hour:+en,minute:i,second:o}})})),m=[];return u.forEach(function(y){y.kind==="step"?m.push(...y.fires.map(function(en){return l({hour:en,minute:i,second:o,plain:s},t)})):y.kind==="range"?m.push(l({hour:y.bounds[0],minute:i,second:o,plain:s},t)+h(t)+l({hour:y.bounds[1],minute:i,second:o,plain:s},t)):m.push(l({hour:y.value,minute:i,second:o,plain:s},t))}),p(tt(m,u,e),t)}function tt(n,r,e){let t=r.some(function(o){return o.kind==="range"});return!e||!t?n:n.map(function(o,u){return u===0?o:"at "+o})}function lr(n,r,e){if(n.length<=1)return n.join("");if(n.length===2)return n[0]+r+n[1];let t=e.style.serialComma?","+r:r;return n.slice(0,-1).join(", ")+t+n[n.length-1]}function p(n,r){return lr(n," and ",r)}function it(n,r){return lr(n," or ",r)}var ot={all:"",month:"in ",recurringWeekday:!0,stepDate:"on ",weekday:"on "},xn={all:"every day",month:"every day in ",recurringWeekday:!1,stepDate:"",weekday:"every "};function a(n,r){if(Y(n,r))return gr(n,r);let e=_(n,ot,r);return e&&" "+e}function mr(n,r){return Y(n,r)?"":_(n,xn,r)+" "}function _(n,r,e){let t=n.pattern;if(t.date!=="*"&&t.weekday!=="*")return lt(n,e);if(t.date!=="*")return ut(n,r,e);if(t.weekday!=="*"){let i=Pn(t.weekday,e);return i?bn(i,n,e):r.weekday+Sr(n,r.recurringWeekday,e)+pr(n,e)}return t.month!=="*"?r.month+N(n,e):r.all}function ut(n,r,e){let t=n.pattern,i=nn(t.date,e);return i?bn(i,n,e):j(t.date)?bn(r.stepDate+yr(t.date),n,e):t.month!=="*"&&!dr(n)?"on the "+Sn(n,e)+pr(n,e):t.month!=="*"?"on "+hr(n,e):"on the "+Sn(n,e)}function dr(n){return!br(n.pattern.month)&&c(n,"month").every(function(e){return e.kind!=="range"})}function Y(n,r){return n.pattern.date!=="*"&&n.pattern.weekday!=="*"&&!!r.style.untilWindow&&!r.short}function gr(n,r){let e=[...at(n,r),...ct(n,r)];return" whenever the day is "+it(e,r)}function st(n,r){return n.pattern.month==="*"?"":"in "+N(n,r)+" "}function at(n,r){let e=n.pattern.date,t=nn(e,r);if(t)return[t.replace(/^on /,"")];let i=ft(e);if(i)return[i];let o=[];return c(n,"date").forEach(function(s){s.kind==="range"?o.push("from the "+b(s.bounds[0])+h(r)+"the "+b(s.bounds[1])):s.kind==="step"?s.fires.forEach(function(S){o.push("the "+b(S))}):o.push("the "+b(s.value))}),o}function ct(n,r){let e=n.pattern.weekday,t=Pn(e,r);if(t)return[t.replace(/^on /,"")];let i=[];return c(n,"weekday").forEach(function(u){u.kind==="range"&&u.bounds[0]==="1"&&u.bounds[1]==="5"?i.push("a weekday"):u.kind==="range"?i.push("a "+x(u.bounds[0],r)+h(r)+"a "+x(u.bounds[1],r)):u.kind==="step"?u.fires.forEach(function(m){i.push("a "+x(m,r))}):i.push("a "+x(u.value,r))}),i}function ft(n){if(!j(n))return null;let[r,e]=n.split("/");return+e!=2?null:r==="*"||r==="1"?"an odd-numbered day":r==="2"?"an even-numbered day":null}function lt(n,r){let e=n.pattern,t=Pn(e.weekday,r)||"on "+Sr(n,!1,r);return e.month!=="*"&&dr(n)&&!nn(e.date,r)&&!j(e.date)?"on "+hr(n,r)+" or "+t+" in "+N(n,r):mt(n,r)+" or "+t+dt(n,r)}function mt(n,r){let e=n.pattern,t=nn(e.date,r);return t||(j(e.date)?yr(e.date):"on the "+Sn(n,r))}function dt(n,r){return n.pattern.month==="*"?"":", in "+N(n,r)}function nn(n,r){if(n==="L")return"on the last day of the month";if(n==="LW"||n==="WL")return"on the last weekday of the month";let e=/^L-(\d{1,2})$/.exec(n);if(e)return g(+e[1],r)+" "+w(e[1],"day")+" before the last day of the month";let t=/^(\d{1,2})W$|^W(\d{1,2})$/.exec(n);if(t)return"on the weekday nearest the "+b(t[1]||t[2])}function Pn(n,r){let e=n.split("#");if(e.length===2)return"on the "+le[+e[1]]+" "+x(e[0],r)+" of the month";if(/L$/.test(n))return"on the last "+x(n.slice(0,-1),r)+" of the month"}function hr(n,r){let e=N(n,r),t=rn(c(n,"date"),r.style.ordinals?b:gt,r);return r.style.dayFirst&&n.shapes.date==="single"&&n.shapes.month!=="single"?"the "+b(n.pattern.date)+" of "+e:r.style.dayFirst?t+" "+e:e+" "+t}function gt(n){return""+n}function pr(n,r){return n.pattern.month==="*"?"":" in "+N(n,r)}function bn(n,r,e){if(r.pattern.month==="*")return n;let t=n.indexOf(" of the month")!==-1;return t&&r.shapes.month==="range"?n.replace(" of the month"," of each month")+" from "+N(r,e):t&&(r.shapes.month==="single"||r.shapes.month==="step")?n.replace(" of the month","")+" in "+N(r,e):n+" in "+N(r,e)}function yr(n){let r=n.split("/"),e=+r[1],t=r[0],o=(e===2?"every other":"every "+b(e))+" day of the month";return t!=="*"&&t!=="1"&&(o+=" from the "+b(t)),o}function Sn(n,r){return rn(c(n,"date"),b,r)}function N(n,r){let e=br(n.pattern.month);return e||rn(c(n,"month"),function(i){return St(i,r)},r)}function br(n){if(!j(n))return null;let[r,e]=n.split("/");return+e!=2?null:r==="*"||r==="1"?"every odd-numbered month":r==="2"?"every even-numbered month":null}function Sr(n,r,e){let t=Vn(c(n,"weekday")),i=t.some(function(s){return s.kind==="range"});return rn(t,r&&!i?function(s){return ht(s,e)}:function(s){return x(s,e)},e)}function ht(n,r){let e=x(n,r);return r.short?e:e+"s"}function rn(n,r,e){let t=[];return n.forEach(function(o){o.kind==="step"?t.push(...o.fires.map(r)):o.kind==="range"?t.push(o.bounds.map(r).join(h(e))):t.push(r(o.value))}),p(t,e)}function nr(n,r,e){let t=r.pattern.year;if(t==="*")return n;if(t.indexOf("/")!==-1)return n+", "+yt(t,e);let i=pt(t,e);if(t.indexOf("-")===-1&&t.indexOf(",")===-1&&r.pattern.date!=="*"&&n.indexOf(" at ")!==-1){let o=e.style.dayFirst?" ":", ";return n.replace(" at ",o+i+" at ")}return n+" in "+i}function pt(n,r){return n.indexOf(",")!==-1?p(n.split(","),r):n.indexOf("-")!==-1?n.split("-").join(h(r)):n}function yt(n,r){let e=n.split("/"),t=+e[1],i=e[0];if(t<=1)return"every year";let o=t===2?"every other year":"every "+g(t,r)+" years";return i!=="*"&&i!=="0"&&(o+=" from "+i),o}function l(n,r){let{hour:e,minute:t,plain:i,explicit:o}=n,u=typeof n.second=="number"&&n.second>0?n.second:0;return r.ampm?bt({hour:e,minute:t,second:u,plain:i,explicit:o},r):dn({hour:e,minute:t,second:u},{pad:!0,sep:r.style.sep})}function bt(n,r){let{hour:e,minute:t,second:i,plain:o,explicit:u}=n,s=r.style;if(!o&&!u&&+t==0&&!i){if(+e==0)return s.midnight;if(+e==12)return s.midday}return dn({hour:e%12||12,minute:t,second:i},{lean:!u,sep:s.sep})+(s.closeUp?"":" ")+(e<12?s.am:s.pm)}function g(n,r){return Bn(n,ae,r)}function w(n,r){return+n==1?r:r+"s"}function h(n){return n.short?"-":n.style.through}function b(n){let r=Math.abs(n),e=hn[r];return e||(r=(r%100-20)%10,e=hn[r]||hn[0]),n+e}function St(n,r){let e=ce[+n];return e&&e[r.short?1:0]}function x(n,r){let e=n===7||n==="7"?0:n,t=C[e]||fe[e];return t&&t[r.short?1:0]}var kt={describe:de,fallback:"an unrecognizable cron pattern",options:me,reboot:"at system startup",sentence:n=>"Runs "+n+(n.endsWith(".")?"":".")},kr=kt;/**
|
|
2
2
|
* @license MIT, Copyright (c) 2026 Andrew Brož
|
|
3
|
-
*/function
|
|
3
|
+
*/function Mn(n,r){let e=r&&r.lang||kr,t=e.options(r);if(!t.lenient)return Or(Nr(n,e,t),e,r);try{return Or(Nr(n,e,t),e,r)}catch{return e.fallback}}function Or(n,r,e){return e&&e.sentence?r.sentence(n):n}function Nr(n,r,e){if(typeof n=="string"&&n.trim().toLowerCase()==="@reboot")return r.reboot;let t=Kn(Zn(n,e)),i=r.plan?r.plan(t,t.plan):t.plan;return r.describe({...t,plan:i},e)}function Ot(n,r){return Mn(n,{...r,sentence:!0})}function Nt(n,r){return Mn(n,{...r,sentence:!1})}var zt=Object.assign(Mn,{sentence:Ot,fragment:Nt}),Fn=zt;typeof globalThis<"u"&&Object.assign(globalThis,{cronli5:Fn});var pi=Fn;})();
|
package/dist/cronli5.cjs
CHANGED
|
@@ -52,10 +52,10 @@ var fieldSpecs = {
|
|
|
52
52
|
second: { cyclic: true, max: 59, min: 0, top: 59 },
|
|
53
53
|
minute: { cyclic: true, max: 59, min: 0, top: 59 },
|
|
54
54
|
hour: { cyclic: true, max: 23, min: 0, top: 23 },
|
|
55
|
-
date: {
|
|
55
|
+
date: { cyclic: true, max: 31, min: 1, top: 31 },
|
|
56
56
|
month: { cyclic: true, max: 12, min: 1, numbers: monthNumbers, top: 12 },
|
|
57
57
|
weekday: {
|
|
58
|
-
aliases: {
|
|
58
|
+
aliases: { L: "6" },
|
|
59
59
|
cyclic: true,
|
|
60
60
|
max: 7,
|
|
61
61
|
min: 0,
|
|
@@ -352,6 +352,53 @@ function firstFire(segment, spec) {
|
|
|
352
352
|
return start === "*" ? spec.min : toFieldNumber(start, spec.numbers);
|
|
353
353
|
}
|
|
354
354
|
|
|
355
|
+
// src/core/quartz.ts
|
|
356
|
+
var quartzTokenMessage = "`?` is a Quartz token \u2014 pass { quartz: true } to enable Quartz semantics.";
|
|
357
|
+
function applyQuartz(cronPattern, quartz) {
|
|
358
|
+
if (!quartz) {
|
|
359
|
+
rejectQuartzToken(cronPattern.date);
|
|
360
|
+
rejectQuartzToken(cronPattern.weekday);
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
if ("" + cronPattern.date === "?") {
|
|
364
|
+
cronPattern.date = "*";
|
|
365
|
+
}
|
|
366
|
+
if ("" + cronPattern.weekday === "?") {
|
|
367
|
+
cronPattern.weekday = "*";
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
cronPattern.weekday = reindexWeekday("" + cronPattern.weekday);
|
|
371
|
+
}
|
|
372
|
+
function rejectQuartzToken(value) {
|
|
373
|
+
if ("" + value === "?") {
|
|
374
|
+
throw new Error(quartzTokenMessage);
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function reindexWeekday(value) {
|
|
378
|
+
if (value === "*") {
|
|
379
|
+
return value;
|
|
380
|
+
}
|
|
381
|
+
return value.split(",").map(reindexSegment).join(",");
|
|
382
|
+
}
|
|
383
|
+
function reindexSegment(segment) {
|
|
384
|
+
const operator = /(#\d+|L)$/.exec(segment);
|
|
385
|
+
const suffix = operator ? operator[0] : "";
|
|
386
|
+
const core = suffix ? segment.slice(0, -suffix.length) : segment;
|
|
387
|
+
const step = core.split("/");
|
|
388
|
+
const range = step[0].split("-").map(reindexNumber).join("-");
|
|
389
|
+
const head = step.length === 2 ? range + "/" + step[1] : range;
|
|
390
|
+
return head + suffix;
|
|
391
|
+
}
|
|
392
|
+
function reindexNumber(token) {
|
|
393
|
+
if (!isNonNegativeInteger(token)) {
|
|
394
|
+
return token;
|
|
395
|
+
}
|
|
396
|
+
if (token === "0") {
|
|
397
|
+
throw new Error('`cronli5` was passed an invalid Quartz day-of-week value "0"; Quartz numbers weekdays 1 (Sunday) through 7 (Saturday).');
|
|
398
|
+
}
|
|
399
|
+
return "" + (+token - 1);
|
|
400
|
+
}
|
|
401
|
+
|
|
355
402
|
// src/core/parse.ts
|
|
356
403
|
function parseCronPattern(cronPattern, opts) {
|
|
357
404
|
const isArray = cronPattern instanceof Array;
|
|
@@ -892,6 +939,7 @@ function hourTimesPlan(hourField) {
|
|
|
892
939
|
// src/core/index.ts
|
|
893
940
|
function prepare(cronPattern, opts) {
|
|
894
941
|
const pattern = parseCronPattern(cronPattern, opts);
|
|
942
|
+
applyQuartz(pattern, opts.quartz);
|
|
895
943
|
applyQuartzAliases(pattern);
|
|
896
944
|
validateCronPattern(pattern);
|
|
897
945
|
return normalizeCronPattern(pattern);
|
|
@@ -1020,6 +1068,7 @@ function normalizeOptions(options) {
|
|
|
1020
1068
|
return {
|
|
1021
1069
|
ampm: typeof options.ampm === "boolean" ? options.ampm : true,
|
|
1022
1070
|
lenient: !!options.lenient,
|
|
1071
|
+
quartz: !!options.quartz,
|
|
1023
1072
|
seconds: !!options.seconds,
|
|
1024
1073
|
short: !!options.short,
|
|
1025
1074
|
style: resolveDialect(options.dialect),
|
|
@@ -2322,7 +2371,14 @@ function interpretCronPattern(cronPattern, lang, opts) {
|
|
|
2322
2371
|
const plan = lang.plan ? lang.plan(schedule, schedule.plan) : schedule.plan;
|
|
2323
2372
|
return lang.describe({ ...schedule, plan }, opts);
|
|
2324
2373
|
}
|
|
2325
|
-
|
|
2374
|
+
function sentence(cronPattern, options) {
|
|
2375
|
+
return cronli5(cronPattern, { ...options, sentence: true });
|
|
2376
|
+
}
|
|
2377
|
+
function fragment(cronPattern, options) {
|
|
2378
|
+
return cronli5(cronPattern, { ...options, sentence: false });
|
|
2379
|
+
}
|
|
2380
|
+
var callable = Object.assign(cronli5, { sentence, fragment });
|
|
2381
|
+
var cronli5_default = callable;
|
|
2326
2382
|
/**
|
|
2327
2383
|
* @license MIT, Copyright (c) 2026 Andrew Brož
|
|
2328
2384
|
*/
|
package/dist/cronli5.js
CHANGED
|
@@ -26,10 +26,10 @@ var fieldSpecs = {
|
|
|
26
26
|
second: { cyclic: true, max: 59, min: 0, top: 59 },
|
|
27
27
|
minute: { cyclic: true, max: 59, min: 0, top: 59 },
|
|
28
28
|
hour: { cyclic: true, max: 23, min: 0, top: 23 },
|
|
29
|
-
date: {
|
|
29
|
+
date: { cyclic: true, max: 31, min: 1, top: 31 },
|
|
30
30
|
month: { cyclic: true, max: 12, min: 1, numbers: monthNumbers, top: 12 },
|
|
31
31
|
weekday: {
|
|
32
|
-
aliases: {
|
|
32
|
+
aliases: { L: "6" },
|
|
33
33
|
cyclic: true,
|
|
34
34
|
max: 7,
|
|
35
35
|
min: 0,
|
|
@@ -326,6 +326,53 @@ function firstFire(segment, spec) {
|
|
|
326
326
|
return start === "*" ? spec.min : toFieldNumber(start, spec.numbers);
|
|
327
327
|
}
|
|
328
328
|
|
|
329
|
+
// src/core/quartz.ts
|
|
330
|
+
var quartzTokenMessage = "`?` is a Quartz token \u2014 pass { quartz: true } to enable Quartz semantics.";
|
|
331
|
+
function applyQuartz(cronPattern, quartz) {
|
|
332
|
+
if (!quartz) {
|
|
333
|
+
rejectQuartzToken(cronPattern.date);
|
|
334
|
+
rejectQuartzToken(cronPattern.weekday);
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
if ("" + cronPattern.date === "?") {
|
|
338
|
+
cronPattern.date = "*";
|
|
339
|
+
}
|
|
340
|
+
if ("" + cronPattern.weekday === "?") {
|
|
341
|
+
cronPattern.weekday = "*";
|
|
342
|
+
return;
|
|
343
|
+
}
|
|
344
|
+
cronPattern.weekday = reindexWeekday("" + cronPattern.weekday);
|
|
345
|
+
}
|
|
346
|
+
function rejectQuartzToken(value) {
|
|
347
|
+
if ("" + value === "?") {
|
|
348
|
+
throw new Error(quartzTokenMessage);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
function reindexWeekday(value) {
|
|
352
|
+
if (value === "*") {
|
|
353
|
+
return value;
|
|
354
|
+
}
|
|
355
|
+
return value.split(",").map(reindexSegment).join(",");
|
|
356
|
+
}
|
|
357
|
+
function reindexSegment(segment) {
|
|
358
|
+
const operator = /(#\d+|L)$/.exec(segment);
|
|
359
|
+
const suffix = operator ? operator[0] : "";
|
|
360
|
+
const core = suffix ? segment.slice(0, -suffix.length) : segment;
|
|
361
|
+
const step = core.split("/");
|
|
362
|
+
const range = step[0].split("-").map(reindexNumber).join("-");
|
|
363
|
+
const head = step.length === 2 ? range + "/" + step[1] : range;
|
|
364
|
+
return head + suffix;
|
|
365
|
+
}
|
|
366
|
+
function reindexNumber(token) {
|
|
367
|
+
if (!isNonNegativeInteger(token)) {
|
|
368
|
+
return token;
|
|
369
|
+
}
|
|
370
|
+
if (token === "0") {
|
|
371
|
+
throw new Error('`cronli5` was passed an invalid Quartz day-of-week value "0"; Quartz numbers weekdays 1 (Sunday) through 7 (Saturday).');
|
|
372
|
+
}
|
|
373
|
+
return "" + (+token - 1);
|
|
374
|
+
}
|
|
375
|
+
|
|
329
376
|
// src/core/parse.ts
|
|
330
377
|
function parseCronPattern(cronPattern, opts) {
|
|
331
378
|
const isArray = cronPattern instanceof Array;
|
|
@@ -866,6 +913,7 @@ function hourTimesPlan(hourField) {
|
|
|
866
913
|
// src/core/index.ts
|
|
867
914
|
function prepare(cronPattern, opts) {
|
|
868
915
|
const pattern = parseCronPattern(cronPattern, opts);
|
|
916
|
+
applyQuartz(pattern, opts.quartz);
|
|
869
917
|
applyQuartzAliases(pattern);
|
|
870
918
|
validateCronPattern(pattern);
|
|
871
919
|
return normalizeCronPattern(pattern);
|
|
@@ -994,6 +1042,7 @@ function normalizeOptions(options) {
|
|
|
994
1042
|
return {
|
|
995
1043
|
ampm: typeof options.ampm === "boolean" ? options.ampm : true,
|
|
996
1044
|
lenient: !!options.lenient,
|
|
1045
|
+
quartz: !!options.quartz,
|
|
997
1046
|
seconds: !!options.seconds,
|
|
998
1047
|
short: !!options.short,
|
|
999
1048
|
style: resolveDialect(options.dialect),
|
|
@@ -2296,7 +2345,14 @@ function interpretCronPattern(cronPattern, lang, opts) {
|
|
|
2296
2345
|
const plan = lang.plan ? lang.plan(schedule, schedule.plan) : schedule.plan;
|
|
2297
2346
|
return lang.describe({ ...schedule, plan }, opts);
|
|
2298
2347
|
}
|
|
2299
|
-
|
|
2348
|
+
function sentence(cronPattern, options) {
|
|
2349
|
+
return cronli5(cronPattern, { ...options, sentence: true });
|
|
2350
|
+
}
|
|
2351
|
+
function fragment(cronPattern, options) {
|
|
2352
|
+
return cronli5(cronPattern, { ...options, sentence: false });
|
|
2353
|
+
}
|
|
2354
|
+
var callable = Object.assign(cronli5, { sentence, fragment });
|
|
2355
|
+
var cronli5_default = callable;
|
|
2300
2356
|
export {
|
|
2301
2357
|
cronli5_default as default
|
|
2302
2358
|
};
|
package/dist/lang/de.cjs
CHANGED
package/dist/lang/de.js
CHANGED
package/dist/lang/en.cjs
CHANGED
|
@@ -249,6 +249,7 @@ function normalizeOptions(options) {
|
|
|
249
249
|
return {
|
|
250
250
|
ampm: typeof options.ampm === "boolean" ? options.ampm : true,
|
|
251
251
|
lenient: !!options.lenient,
|
|
252
|
+
quartz: !!options.quartz,
|
|
252
253
|
seconds: !!options.seconds,
|
|
253
254
|
short: !!options.short,
|
|
254
255
|
style: resolveDialect(options.dialect),
|
package/dist/lang/en.js
CHANGED
|
@@ -223,6 +223,7 @@ function normalizeOptions(options) {
|
|
|
223
223
|
return {
|
|
224
224
|
ampm: typeof options.ampm === "boolean" ? options.ampm : true,
|
|
225
225
|
lenient: !!options.lenient,
|
|
226
|
+
quartz: !!options.quartz,
|
|
226
227
|
seconds: !!options.seconds,
|
|
227
228
|
short: !!options.short,
|
|
228
229
|
style: resolveDialect(options.dialect),
|
package/dist/lang/es.cjs
CHANGED
|
@@ -231,6 +231,7 @@ function normalizeOptions(options) {
|
|
|
231
231
|
// 12-hour for Mexico/US); an explicit `{ampm}` option overrides it.
|
|
232
232
|
ampm: typeof options.ampm === "boolean" ? options.ampm : style.ampm,
|
|
233
233
|
lenient: !!options.lenient,
|
|
234
|
+
quartz: !!options.quartz,
|
|
234
235
|
seconds: !!options.seconds,
|
|
235
236
|
short: !!options.short,
|
|
236
237
|
style,
|
package/dist/lang/es.js
CHANGED
|
@@ -205,6 +205,7 @@ function normalizeOptions(options) {
|
|
|
205
205
|
// 12-hour for Mexico/US); an explicit `{ampm}` option overrides it.
|
|
206
206
|
ampm: typeof options.ampm === "boolean" ? options.ampm : style.ampm,
|
|
207
207
|
lenient: !!options.lenient,
|
|
208
|
+
quartz: !!options.quartz,
|
|
208
209
|
seconds: !!options.seconds,
|
|
209
210
|
short: !!options.short,
|
|
210
211
|
style,
|
package/dist/lang/fi.cjs
CHANGED
package/dist/lang/fi.js
CHANGED
package/dist/lang/fr.cjs
CHANGED
|
@@ -219,6 +219,7 @@ function normalizeOptions(options) {
|
|
|
219
219
|
// satisfied without the 12-hour machinery the es donor carried.
|
|
220
220
|
ampm: false,
|
|
221
221
|
lenient: !!options.lenient,
|
|
222
|
+
quartz: !!options.quartz,
|
|
222
223
|
seconds: !!options.seconds,
|
|
223
224
|
short: !!options.short,
|
|
224
225
|
style,
|
package/dist/lang/fr.js
CHANGED
|
@@ -193,6 +193,7 @@ function normalizeOptions(options) {
|
|
|
193
193
|
// satisfied without the 12-hour machinery the es donor carried.
|
|
194
194
|
ampm: false,
|
|
195
195
|
lenient: !!options.lenient,
|
|
196
|
+
quartz: !!options.quartz,
|
|
196
197
|
seconds: !!options.seconds,
|
|
197
198
|
short: !!options.short,
|
|
198
199
|
style,
|
package/dist/lang/pt.cjs
CHANGED
|
@@ -305,6 +305,7 @@ function normalizeOptions(options) {
|
|
|
305
305
|
// `{ampm}` option overrides it.
|
|
306
306
|
ampm: typeof options.ampm === "boolean" ? options.ampm : style.ampm,
|
|
307
307
|
lenient: !!options.lenient,
|
|
308
|
+
quartz: !!options.quartz,
|
|
308
309
|
seconds: !!options.seconds,
|
|
309
310
|
short: !!options.short,
|
|
310
311
|
style,
|
package/dist/lang/pt.js
CHANGED
|
@@ -279,6 +279,7 @@ function normalizeOptions(options) {
|
|
|
279
279
|
// `{ampm}` option overrides it.
|
|
280
280
|
ampm: typeof options.ampm === "boolean" ? options.ampm : style.ampm,
|
|
281
281
|
lenient: !!options.lenient,
|
|
282
|
+
quartz: !!options.quartz,
|
|
282
283
|
seconds: !!options.seconds,
|
|
283
284
|
short: !!options.short,
|
|
284
285
|
style,
|
package/dist/lang/zh.cjs
CHANGED
package/dist/lang/zh.js
CHANGED
package/package.json
CHANGED
package/src/core/index.ts
CHANGED
|
@@ -5,16 +5,20 @@
|
|
|
5
5
|
|
|
6
6
|
import {applyQuartzAliases, normalizeCronPattern} from './normalize.js';
|
|
7
7
|
import type {NormalizedOptions, Pattern} from './schedule.js';
|
|
8
|
+
import {applyQuartz} from './quartz.js';
|
|
8
9
|
import {parseCronPattern} from './parse.js';
|
|
9
10
|
import type {CronPattern} from '../types.js';
|
|
10
11
|
import {validateCronPattern} from './validate.js';
|
|
11
12
|
|
|
12
|
-
// Parse, alias, validate, and normalize cron input
|
|
13
|
-
// cron-like object of string fields, ready for semantic
|
|
14
|
-
// rendering.
|
|
13
|
+
// Parse, apply Quartz semantics, alias, validate, and normalize cron input
|
|
14
|
+
// into a canonical cron-like object of string fields, ready for semantic
|
|
15
|
+
// analysis and rendering. Quartz handling runs first: it gates the `?` token
|
|
16
|
+
// (rejected unless `quartz`) and re-indexes the Quartz day-of-week to the
|
|
17
|
+
// canonical cron numbering the rest of the core expects.
|
|
15
18
|
function prepare(cronPattern: CronPattern, opts: NormalizedOptions): Pattern {
|
|
16
19
|
const pattern = parseCronPattern(cronPattern, opts);
|
|
17
20
|
|
|
21
|
+
applyQuartz(pattern, opts.quartz);
|
|
18
22
|
applyQuartzAliases(pattern);
|
|
19
23
|
validateCronPattern(pattern);
|
|
20
24
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Quartz input semantics. cronli5 accepts Quartz tokens (`?`, `L`, `W`, `#`),
|
|
2
|
+
// but Quartz numbers the day-of-week differently from standard cron: Quartz is
|
|
3
|
+
// 1 = Sunday … 7 = Saturday, while cron is 0/7 = Sunday, 1 = Monday. Reading a
|
|
4
|
+
// Quartz pattern with cron indexing silently shifts every weekday by one, so a
|
|
5
|
+
// Quartz `2` (Monday) would read as Tuesday. This module gates and re-indexes
|
|
6
|
+
// the input so the rest of the core keeps facing canonical cron values.
|
|
7
|
+
//
|
|
8
|
+
// The `?` token (Quartz's "no specific value", mandatory in Quartz, absent in
|
|
9
|
+
// standard cron) is the unambiguous mark of a Quartz pattern. Outside Quartz
|
|
10
|
+
// mode it is rejected outright rather than aliased to `*`, so a real Quartz
|
|
11
|
+
// cron errors loudly instead of being mis-read; inside Quartz mode it is the
|
|
12
|
+
// equivalent of `*`.
|
|
13
|
+
|
|
14
|
+
import type {CronLike} from './specs.js';
|
|
15
|
+
import {isNonNegativeInteger} from './util.js';
|
|
16
|
+
|
|
17
|
+
// The error a `?` raises outside Quartz mode: a clear pointer at the option
|
|
18
|
+
// that makes Quartz semantics (and `?`) available.
|
|
19
|
+
const quartzTokenMessage =
|
|
20
|
+
'`?` is a Quartz token — pass { quartz: true } to enable Quartz semantics.';
|
|
21
|
+
|
|
22
|
+
// In standard (non-Quartz) mode, `?` is not a valid value: reject it with a
|
|
23
|
+
// pointer at the `quartz` option. In Quartz mode, accept `?` as `*` and
|
|
24
|
+
// re-index the day-of-week from Quartz numbering (1 = Sunday) to the canonical
|
|
25
|
+
// cron numbering (0 = Sunday) the rest of the core expects. Operates in place
|
|
26
|
+
// on the raw cron-like object, before aliasing and validation.
|
|
27
|
+
function applyQuartz(cronPattern: CronLike, quartz: boolean): void {
|
|
28
|
+
if (!quartz) {
|
|
29
|
+
rejectQuartzToken(cronPattern.date);
|
|
30
|
+
rejectQuartzToken(cronPattern.weekday);
|
|
31
|
+
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if ('' + cronPattern.date === '?') {
|
|
36
|
+
cronPattern.date = '*';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if ('' + cronPattern.weekday === '?') {
|
|
40
|
+
cronPattern.weekday = '*';
|
|
41
|
+
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
cronPattern.weekday = reindexWeekday('' + cronPattern.weekday);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Throw the Quartz-token error if a field is exactly `?`.
|
|
49
|
+
function rejectQuartzToken(value: string | number): void {
|
|
50
|
+
if ('' + value === '?') {
|
|
51
|
+
throw new Error(quartzTokenMessage);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Re-index a Quartz day-of-week field to canonical cron numbering. Every
|
|
56
|
+
// numeric weekday position maps n -> n-1 (Quartz 1 = Sunday becomes cron 0),
|
|
57
|
+
// across singles, ranges, and step bounds, and inside the DOW operators `nL`
|
|
58
|
+
// (last weekday) and `n#k` (kth weekday). Day NAMES (`MON`) are unambiguous and
|
|
59
|
+
// left untouched, as is the bare `L` alias (Saturday in both numberings) and
|
|
60
|
+
// `*`. Quartz has no weekday 0; it is rejected here.
|
|
61
|
+
function reindexWeekday(value: string): string {
|
|
62
|
+
if (value === '*') {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return value.split(',').map(reindexSegment).join(',');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Re-index one comma-separated weekday segment: a single, a range, or either
|
|
70
|
+
// of those followed by a `#k` or `L` operator (or a `/step`).
|
|
71
|
+
function reindexSegment(segment: string): string {
|
|
72
|
+
const operator = (/(#\d+|L)$/).exec(segment);
|
|
73
|
+
const suffix = operator ? operator[0] : '';
|
|
74
|
+
const core = suffix ? segment.slice(0, -suffix.length) : segment;
|
|
75
|
+
const step = core.split('/');
|
|
76
|
+
const range = step[0].split('-').map(reindexNumber).join('-');
|
|
77
|
+
const head = step.length === 2 ? range + '/' + step[1] : range;
|
|
78
|
+
|
|
79
|
+
return head + suffix;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Re-index a single weekday token: a number maps n -> n-1 (rejecting 0, which
|
|
83
|
+
// Quartz does not use); a name passes through unchanged.
|
|
84
|
+
function reindexNumber(token: string): string {
|
|
85
|
+
if (!isNonNegativeInteger(token)) {
|
|
86
|
+
return token;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (token === '0') {
|
|
90
|
+
throw new Error('`cronli5` was passed an invalid Quartz day-of-week ' +
|
|
91
|
+
'value "0"; Quartz numbers weekdays 1 (Sunday) through 7 (Saturday).');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return '' + (+token - 1);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export {applyQuartz, quartzTokenMessage};
|
package/src/core/schedule.ts
CHANGED
package/src/core/specs.ts
CHANGED
|
@@ -55,9 +55,9 @@ const fieldSpecs: Record<Field, FieldSpec> = {
|
|
|
55
55
|
second: {cyclic: true, max: 59, min: 0, top: 59},
|
|
56
56
|
minute: {cyclic: true, max: 59, min: 0, top: 59},
|
|
57
57
|
hour: {cyclic: true, max: 23, min: 0, top: 23},
|
|
58
|
-
date: {
|
|
58
|
+
date: {cyclic: true, max: 31, min: 1, top: 31},
|
|
59
59
|
month: {cyclic: true, max: 12, min: 1, numbers: monthNumbers, top: 12},
|
|
60
|
-
weekday: {aliases: {
|
|
60
|
+
weekday: {aliases: {L: '6'}, cyclic: true, max: 7, min: 0,
|
|
61
61
|
numbers: weekdayNumbers, top: 6},
|
|
62
62
|
year: {max: 9999, min: 1970}
|
|
63
63
|
};
|
package/src/cronli5.ts
CHANGED
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
import {analyze, prepare} from './core/index.js';
|
|
31
31
|
import type {NormalizedOptions} from './core/schedule.js';
|
|
32
|
-
import type {CronPattern, Cronli5Language, Cronli5Options}
|
|
32
|
+
import type {Cronli5, CronPattern, Cronli5Language, Cronli5Options}
|
|
33
33
|
from './types.js';
|
|
34
34
|
import en from './lang/en/index.js';
|
|
35
35
|
|
|
@@ -88,8 +88,25 @@ function interpretCronPattern(
|
|
|
88
88
|
return lang.describe({...schedule, plan}, opts);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
export
|
|
91
|
+
// Two named convenience methods are attached to the callable export as sugar
|
|
92
|
+
// over the `sentence` option: `.sentence(...)` forces the capitalized
|
|
93
|
+
// standalone, `.fragment(...)` forces the embeddable fragment (the default).
|
|
94
|
+
// The method's own intent wins, so a passed-through `sentence` flag is
|
|
95
|
+
// overridden. There is no `toString` method on purpose — it would shadow
|
|
96
|
+
// `Function.prototype.toString` (called arg-less by `String()`, template
|
|
97
|
+
// literals, and console/debug) and break coercion; named methods sidestep that.
|
|
98
|
+
function sentence(cronPattern: CronPattern, options?: Cronli5Options): string {
|
|
99
|
+
return cronli5(cronPattern, {...options, sentence: true});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function fragment(cronPattern: CronPattern, options?: Cronli5Options): string {
|
|
103
|
+
return cronli5(cronPattern, {...options, sentence: false});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const callable: Cronli5 = Object.assign(cronli5, {sentence, fragment});
|
|
107
|
+
|
|
108
|
+
export default callable;
|
|
92
109
|
export type {
|
|
93
|
-
Cronli5Dialect, Cronli5Language, Cronli5Options, CronPattern,
|
|
110
|
+
Cronli5, Cronli5Dialect, Cronli5Language, Cronli5Options, CronPattern,
|
|
94
111
|
CronPatternObject
|
|
95
112
|
} from './types.js';
|
package/src/lang/de/index.ts
CHANGED
|
@@ -1464,6 +1464,7 @@ function normalizeOptions(options?: Cronli5Options): Opts {
|
|
|
1464
1464
|
return {
|
|
1465
1465
|
ampm: typeof options.ampm === 'boolean' ? options.ampm : false,
|
|
1466
1466
|
lenient: !!options.lenient,
|
|
1467
|
+
quartz: !!options.quartz,
|
|
1467
1468
|
seconds: !!options.seconds,
|
|
1468
1469
|
short: !!options.short,
|
|
1469
1470
|
style,
|
package/src/lang/en/index.ts
CHANGED
|
@@ -137,6 +137,7 @@ function normalizeOptions(options?: Cronli5Options): NormalizedOptions {
|
|
|
137
137
|
return {
|
|
138
138
|
ampm: typeof options.ampm === 'boolean' ? options.ampm : true,
|
|
139
139
|
lenient: !!options.lenient,
|
|
140
|
+
quartz: !!options.quartz,
|
|
140
141
|
seconds: !!options.seconds,
|
|
141
142
|
short: !!options.short,
|
|
142
143
|
style: resolveDialect(options.dialect),
|
package/src/lang/es/index.ts
CHANGED
|
@@ -125,6 +125,7 @@ function normalizeOptions(options?: Cronli5Options): Opts {
|
|
|
125
125
|
// 12-hour for Mexico/US); an explicit `{ampm}` option overrides it.
|
|
126
126
|
ampm: typeof options.ampm === 'boolean' ? options.ampm : style.ampm,
|
|
127
127
|
lenient: !!options.lenient,
|
|
128
|
+
quartz: !!options.quartz,
|
|
128
129
|
seconds: !!options.seconds,
|
|
129
130
|
short: !!options.short,
|
|
130
131
|
style,
|
package/src/lang/fi/index.ts
CHANGED
|
@@ -200,6 +200,7 @@ function normalizeOptions(options?: Cronli5Options): NormalizedOptions {
|
|
|
200
200
|
return {
|
|
201
201
|
ampm: false,
|
|
202
202
|
lenient: !!options.lenient,
|
|
203
|
+
quartz: !!options.quartz,
|
|
203
204
|
seconds: !!options.seconds,
|
|
204
205
|
short: !!options.short,
|
|
205
206
|
style: resolveDialect(options.dialect),
|
package/src/lang/fr/index.ts
CHANGED
|
@@ -138,6 +138,7 @@ function normalizeOptions(options?: Cronli5Options): Opts {
|
|
|
138
138
|
// satisfied without the 12-hour machinery the es donor carried.
|
|
139
139
|
ampm: false,
|
|
140
140
|
lenient: !!options.lenient,
|
|
141
|
+
quartz: !!options.quartz,
|
|
141
142
|
seconds: !!options.seconds,
|
|
142
143
|
short: !!options.short,
|
|
143
144
|
style,
|
package/src/lang/pt/index.ts
CHANGED
|
@@ -269,6 +269,7 @@ function normalizeOptions(options?: Cronli5Options): Opts {
|
|
|
269
269
|
// `{ampm}` option overrides it.
|
|
270
270
|
ampm: typeof options.ampm === 'boolean' ? options.ampm : style.ampm,
|
|
271
271
|
lenient: !!options.lenient,
|
|
272
|
+
quartz: !!options.quartz,
|
|
272
273
|
seconds: !!options.seconds,
|
|
273
274
|
short: !!options.short,
|
|
274
275
|
style,
|
package/src/lang/zh/index.ts
CHANGED
|
@@ -1503,6 +1503,7 @@ function normalizeOptions(options?: Cronli5Options): Opts {
|
|
|
1503
1503
|
return {
|
|
1504
1504
|
ampm: typeof options.ampm === 'boolean' ? options.ampm : false,
|
|
1505
1505
|
lenient: !!options.lenient,
|
|
1506
|
+
quartz: !!options.quartz,
|
|
1506
1507
|
seconds: !!options.seconds,
|
|
1507
1508
|
short: !!options.short,
|
|
1508
1509
|
style,
|
package/src/types.ts
CHANGED
|
@@ -96,6 +96,20 @@ export interface Cronli5Options {
|
|
|
96
96
|
*/
|
|
97
97
|
lenient?: boolean;
|
|
98
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Read the pattern with Quartz semantics. Quartz numbers the day-of-week
|
|
101
|
+
* **1 = Sunday, 2 = Monday, … 7 = Saturday** (standard cron uses
|
|
102
|
+
* 0/7 = Sunday, 1 = Monday), and **requires** exactly one of day-of-month or
|
|
103
|
+
* day-of-week to be `?` ("no specific value"). Off by default; with it off,
|
|
104
|
+
* `?` is rejected (rather than silently mis-read as standard cron), since a
|
|
105
|
+
* `?` is the unambiguous mark of a Quartz pattern. The Quartz numbering also
|
|
106
|
+
* applies inside the day-of-week operators (`6L`, `2#2`) and the weekday `L`
|
|
107
|
+
* alias (Saturday). Day names (`MON`, `SUN`) and the day-of-month, month,
|
|
108
|
+
* hour, and minute fields are unaffected. Composable with `seconds`/`years`.
|
|
109
|
+
* Defaults to `false`.
|
|
110
|
+
*/
|
|
111
|
+
quartz?: boolean;
|
|
112
|
+
|
|
99
113
|
/**
|
|
100
114
|
* Return a complete standalone sentence (`'Runs every day at midnight.'`)
|
|
101
115
|
* instead of the embeddable fragment (`'every day at midnight'`). Each
|
|
@@ -122,6 +136,36 @@ export interface Cronli5Options {
|
|
|
122
136
|
years?: boolean;
|
|
123
137
|
}
|
|
124
138
|
|
|
139
|
+
/**
|
|
140
|
+
* The callable default export: a function that turns a cron pattern into a
|
|
141
|
+
* description, carrying two named convenience methods that are sugar over the
|
|
142
|
+
* `sentence` option.
|
|
143
|
+
*
|
|
144
|
+
* There is deliberately **no** `toString` method: it would shadow
|
|
145
|
+
* `Function.prototype.toString`, which the runtime calls arg-less for
|
|
146
|
+
* `String(cronli5)`, template-literal coercion, and `console`/debug output.
|
|
147
|
+
* The named methods avoid that collision.
|
|
148
|
+
*/
|
|
149
|
+
export interface Cronli5 {
|
|
150
|
+
|
|
151
|
+
/** Describe a cron pattern (lowercase embeddable fragment by default). */
|
|
152
|
+
(cronPattern: CronPattern, options?: Cronli5Options): string;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Describe a cron pattern as a capitalized standalone sentence
|
|
156
|
+
* (`'Runs every day at midnight.'`). Sugar for
|
|
157
|
+
* `{...options, sentence: true}`.
|
|
158
|
+
*/
|
|
159
|
+
sentence(cronPattern: CronPattern, options?: Cronli5Options): string;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Describe a cron pattern as a lowercase embeddable fragment
|
|
163
|
+
* (`'every day at midnight'`) — the default form. Sugar for
|
|
164
|
+
* `{...options, sentence: false}`.
|
|
165
|
+
*/
|
|
166
|
+
fragment(cronPattern: CronPattern, options?: Cronli5Options): string;
|
|
167
|
+
}
|
|
168
|
+
|
|
125
169
|
/**
|
|
126
170
|
* Object form of a cron pattern. Fields may be strings or numbers; at least
|
|
127
171
|
* one of `second`, `minute`, or `hour` is required.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { CronLike } from './specs.js';
|
|
2
|
+
declare const quartzTokenMessage = "`?` is a Quartz token \u2014 pass { quartz: true } to enable Quartz semantics.";
|
|
3
|
+
declare function applyQuartz(cronPattern: CronLike, quartz: boolean): void;
|
|
4
|
+
export { applyQuartz, quartzTokenMessage };
|
package/types/core/schedule.d.ts
CHANGED
package/types/cronli5.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @license MIT, Copyright (c) 2026 Andrew Brož
|
|
3
3
|
*/
|
|
4
|
-
import type {
|
|
5
|
-
declare
|
|
6
|
-
export default
|
|
7
|
-
export type { Cronli5Dialect, Cronli5Language, Cronli5Options, CronPattern, CronPatternObject } from './types.js';
|
|
4
|
+
import type { Cronli5 } from './types.js';
|
|
5
|
+
declare const callable: Cronli5;
|
|
6
|
+
export default callable;
|
|
7
|
+
export type { Cronli5, Cronli5Dialect, Cronli5Language, Cronli5Options, CronPattern, CronPatternObject } from './types.js';
|
package/types/types.d.ts
CHANGED
|
@@ -71,6 +71,19 @@ export interface Cronli5Options {
|
|
|
71
71
|
* Defaults to `false`.
|
|
72
72
|
*/
|
|
73
73
|
lenient?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Read the pattern with Quartz semantics. Quartz numbers the day-of-week
|
|
76
|
+
* **1 = Sunday, 2 = Monday, … 7 = Saturday** (standard cron uses
|
|
77
|
+
* 0/7 = Sunday, 1 = Monday), and **requires** exactly one of day-of-month or
|
|
78
|
+
* day-of-week to be `?` ("no specific value"). Off by default; with it off,
|
|
79
|
+
* `?` is rejected (rather than silently mis-read as standard cron), since a
|
|
80
|
+
* `?` is the unambiguous mark of a Quartz pattern. The Quartz numbering also
|
|
81
|
+
* applies inside the day-of-week operators (`6L`, `2#2`) and the weekday `L`
|
|
82
|
+
* alias (Saturday). Day names (`MON`, `SUN`) and the day-of-month, month,
|
|
83
|
+
* hour, and minute fields are unaffected. Composable with `seconds`/`years`.
|
|
84
|
+
* Defaults to `false`.
|
|
85
|
+
*/
|
|
86
|
+
quartz?: boolean;
|
|
74
87
|
/**
|
|
75
88
|
* Return a complete standalone sentence (`'Runs every day at midnight.'`)
|
|
76
89
|
* instead of the embeddable fragment (`'every day at midnight'`). Each
|
|
@@ -93,6 +106,32 @@ export interface Cronli5Options {
|
|
|
93
106
|
*/
|
|
94
107
|
years?: boolean;
|
|
95
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* The callable default export: a function that turns a cron pattern into a
|
|
111
|
+
* description, carrying two named convenience methods that are sugar over the
|
|
112
|
+
* `sentence` option.
|
|
113
|
+
*
|
|
114
|
+
* There is deliberately **no** `toString` method: it would shadow
|
|
115
|
+
* `Function.prototype.toString`, which the runtime calls arg-less for
|
|
116
|
+
* `String(cronli5)`, template-literal coercion, and `console`/debug output.
|
|
117
|
+
* The named methods avoid that collision.
|
|
118
|
+
*/
|
|
119
|
+
export interface Cronli5 {
|
|
120
|
+
/** Describe a cron pattern (lowercase embeddable fragment by default). */
|
|
121
|
+
(cronPattern: CronPattern, options?: Cronli5Options): string;
|
|
122
|
+
/**
|
|
123
|
+
* Describe a cron pattern as a capitalized standalone sentence
|
|
124
|
+
* (`'Runs every day at midnight.'`). Sugar for
|
|
125
|
+
* `{...options, sentence: true}`.
|
|
126
|
+
*/
|
|
127
|
+
sentence(cronPattern: CronPattern, options?: Cronli5Options): string;
|
|
128
|
+
/**
|
|
129
|
+
* Describe a cron pattern as a lowercase embeddable fragment
|
|
130
|
+
* (`'every day at midnight'`) — the default form. Sugar for
|
|
131
|
+
* `{...options, sentence: false}`.
|
|
132
|
+
*/
|
|
133
|
+
fragment(cronPattern: CronPattern, options?: Cronli5Options): string;
|
|
134
|
+
}
|
|
96
135
|
/**
|
|
97
136
|
* Object form of a cron pattern. Fields may be strings or numbers; at least
|
|
98
137
|
* one of `second`, `minute`, or `hour` is required.
|