@leancodepl/api-date-datefns 9.7.3 → 10.0.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/dist/index.js CHANGED
@@ -1,2775 +1,57 @@
1
- const U = /* @__PURE__ */ Symbol.for("constructDateFrom");
2
- function x(r, e) {
3
- return typeof r == "function" ? r(e) : r && typeof r == "object" && U in r ? r[U](e) : r instanceof Date ? new r.constructor(e) : new Date(e);
4
- }
5
- function p(r, e) {
6
- return x(e || r, r);
7
- }
8
- function se(r, e, t) {
9
- const n = p(r, t?.in);
10
- return isNaN(e) ? x(t?.in || r, NaN) : (e && n.setDate(n.getDate() + e), n);
11
- }
12
- let ge = {};
13
- function H() {
14
- return ge;
15
- }
16
- function O(r, e) {
17
- const t = H(), n = e?.weekStartsOn ?? e?.locale?.options?.weekStartsOn ?? t.weekStartsOn ?? t.locale?.options?.weekStartsOn ?? 0, a = p(r, e?.in), s = a.getDay(), o = (s < n ? 7 : 0) + s - n;
18
- return a.setDate(a.getDate() - o), a.setHours(0, 0, 0, 0), a;
19
- }
20
- function _(r, e) {
21
- return O(r, { ...e, weekStartsOn: 1 });
22
- }
23
- function oe(r, e) {
24
- const t = p(r, e?.in), n = t.getFullYear(), a = x(t, 0);
25
- a.setFullYear(n + 1, 0, 4), a.setHours(0, 0, 0, 0);
26
- const s = _(a), o = x(t, 0);
27
- o.setFullYear(n, 0, 4), o.setHours(0, 0, 0, 0);
28
- const i = _(o);
29
- return t.getTime() >= s.getTime() ? n + 1 : t.getTime() >= i.getTime() ? n : n - 1;
30
- }
31
- function F(r) {
32
- const e = p(r), t = new Date(
33
- Date.UTC(
34
- e.getFullYear(),
35
- e.getMonth(),
36
- e.getDate(),
37
- e.getHours(),
38
- e.getMinutes(),
39
- e.getSeconds(),
40
- e.getMilliseconds()
41
- )
42
- );
43
- return t.setUTCFullYear(e.getFullYear()), +r - +t;
44
- }
45
- function pe(r, ...e) {
46
- const t = x.bind(
47
- null,
48
- e.find((n) => typeof n == "object")
49
- );
50
- return e.map(t);
51
- }
52
- function S(r, e) {
53
- const t = p(r, e?.in);
54
- return t.setHours(0, 0, 0, 0), t;
55
- }
56
- function xe(r, e, t) {
57
- const [n, a] = pe(
58
- t?.in,
59
- r,
60
- e
61
- ), s = S(n), o = S(a), i = +s - F(s), b = +o - F(o);
62
- return Math.round((i - b) / 864e5);
63
- }
64
- function Me(r, e) {
65
- const t = oe(r, e), n = x(r, 0);
66
- return n.setFullYear(t, 0, 4), n.setHours(0, 0, 0, 0), _(n);
67
- }
68
- function Pe(r) {
69
- return r instanceof Date || typeof r == "object" && Object.prototype.toString.call(r) === "[object Date]";
70
- }
71
- function Te(r) {
72
- return !(!Pe(r) && typeof r != "number" || isNaN(+p(r)));
73
- }
74
- function De(r, e) {
75
- const t = p(r, e?.in);
76
- return t.setFullYear(t.getFullYear(), 0, 1), t.setHours(0, 0, 0, 0), t;
77
- }
78
- const ke = {
79
- lessThanXSeconds: {
80
- one: "less than a second",
81
- other: "less than {{count}} seconds"
82
- },
83
- xSeconds: {
84
- one: "1 second",
85
- other: "{{count}} seconds"
86
- },
87
- halfAMinute: "half a minute",
88
- lessThanXMinutes: {
89
- one: "less than a minute",
90
- other: "less than {{count}} minutes"
91
- },
92
- xMinutes: {
93
- one: "1 minute",
94
- other: "{{count}} minutes"
95
- },
96
- aboutXHours: {
97
- one: "about 1 hour",
98
- other: "about {{count}} hours"
99
- },
100
- xHours: {
101
- one: "1 hour",
102
- other: "{{count}} hours"
103
- },
104
- xDays: {
105
- one: "1 day",
106
- other: "{{count}} days"
107
- },
108
- aboutXWeeks: {
109
- one: "about 1 week",
110
- other: "about {{count}} weeks"
111
- },
112
- xWeeks: {
113
- one: "1 week",
114
- other: "{{count}} weeks"
115
- },
116
- aboutXMonths: {
117
- one: "about 1 month",
118
- other: "about {{count}} months"
119
- },
120
- xMonths: {
121
- one: "1 month",
122
- other: "{{count}} months"
123
- },
124
- aboutXYears: {
125
- one: "about 1 year",
126
- other: "about {{count}} years"
127
- },
128
- xYears: {
129
- one: "1 year",
130
- other: "{{count}} years"
131
- },
132
- overXYears: {
133
- one: "over 1 year",
134
- other: "over {{count}} years"
135
- },
136
- almostXYears: {
137
- one: "almost 1 year",
138
- other: "almost {{count}} years"
139
- }
140
- }, Oe = (r, e, t) => {
141
- let n;
142
- const a = ke[r];
143
- return typeof a == "string" ? n = a : e === 1 ? n = a.one : n = a.other.replace("{{count}}", e.toString()), t?.addSuffix ? t.comparison && t.comparison > 0 ? "in " + n : n + " ago" : n;
144
- };
145
- function Q(r) {
146
- return (e = {}) => {
147
- const t = e.width ? String(e.width) : r.defaultWidth;
148
- return r.formats[t] || r.formats[r.defaultWidth];
149
- };
150
- }
151
- const ve = {
152
- full: "EEEE, MMMM do, y",
153
- long: "MMMM do, y",
154
- medium: "MMM d, y",
155
- short: "MM/dd/yyyy"
156
- }, Ye = {
157
- full: "h:mm:ss a zzzz",
158
- long: "h:mm:ss a z",
159
- medium: "h:mm:ss a",
160
- short: "h:mm a"
161
- }, Ee = {
162
- full: "{{date}} 'at' {{time}}",
163
- long: "{{date}} 'at' {{time}}",
164
- medium: "{{date}}, {{time}}",
165
- short: "{{date}}, {{time}}"
166
- }, We = {
167
- date: Q({
168
- formats: ve,
169
- defaultWidth: "full"
170
- }),
171
- time: Q({
172
- formats: Ye,
173
- defaultWidth: "full"
174
- }),
175
- dateTime: Q({
176
- formats: Ee,
177
- defaultWidth: "full"
178
- })
179
- }, _e = {
180
- lastWeek: "'last' eeee 'at' p",
181
- yesterday: "'yesterday at' p",
182
- today: "'today at' p",
183
- tomorrow: "'tomorrow at' p",
184
- nextWeek: "eeee 'at' p",
185
- other: "P"
186
- }, He = (r, e, t, n) => _e[r];
187
- function q(r) {
188
- return (e, t) => {
189
- const n = t?.context ? String(t.context) : "standalone";
190
- let a;
191
- if (n === "formatting" && r.formattingValues) {
192
- const o = r.defaultFormattingWidth || r.defaultWidth, i = t?.width ? String(t.width) : o;
193
- a = r.formattingValues[i] || r.formattingValues[o];
194
- } else {
195
- const o = r.defaultWidth, i = t?.width ? String(t.width) : r.defaultWidth;
196
- a = r.values[i] || r.values[o];
197
- }
198
- const s = r.argumentCallback ? r.argumentCallback(e) : e;
199
- return a[s];
200
- };
201
- }
202
- const qe = {
203
- narrow: ["B", "A"],
204
- abbreviated: ["BC", "AD"],
205
- wide: ["Before Christ", "Anno Domini"]
206
- }, Ne = {
207
- narrow: ["1", "2", "3", "4"],
208
- abbreviated: ["Q1", "Q2", "Q3", "Q4"],
209
- wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
210
- }, Ie = {
211
- narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
212
- abbreviated: [
213
- "Jan",
214
- "Feb",
215
- "Mar",
216
- "Apr",
217
- "May",
218
- "Jun",
219
- "Jul",
220
- "Aug",
221
- "Sep",
222
- "Oct",
223
- "Nov",
224
- "Dec"
225
- ],
226
- wide: [
227
- "January",
228
- "February",
229
- "March",
230
- "April",
231
- "May",
232
- "June",
233
- "July",
234
- "August",
235
- "September",
236
- "October",
237
- "November",
238
- "December"
239
- ]
240
- }, Fe = {
241
- narrow: ["S", "M", "T", "W", "T", "F", "S"],
242
- short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
243
- abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
244
- wide: [
245
- "Sunday",
246
- "Monday",
247
- "Tuesday",
248
- "Wednesday",
249
- "Thursday",
250
- "Friday",
251
- "Saturday"
252
- ]
253
- }, Le = {
254
- narrow: {
255
- am: "a",
256
- pm: "p",
257
- midnight: "mi",
258
- noon: "n",
259
- morning: "morning",
260
- afternoon: "afternoon",
261
- evening: "evening",
262
- night: "night"
263
- },
264
- abbreviated: {
265
- am: "AM",
266
- pm: "PM",
267
- midnight: "midnight",
268
- noon: "noon",
269
- morning: "morning",
270
- afternoon: "afternoon",
271
- evening: "evening",
272
- night: "night"
273
- },
274
- wide: {
275
- am: "a.m.",
276
- pm: "p.m.",
277
- midnight: "midnight",
278
- noon: "noon",
279
- morning: "morning",
280
- afternoon: "afternoon",
281
- evening: "evening",
282
- night: "night"
283
- }
284
- }, Ce = {
285
- narrow: {
286
- am: "a",
287
- pm: "p",
288
- midnight: "mi",
289
- noon: "n",
290
- morning: "in the morning",
291
- afternoon: "in the afternoon",
292
- evening: "in the evening",
293
- night: "at night"
294
- },
295
- abbreviated: {
296
- am: "AM",
297
- pm: "PM",
298
- midnight: "midnight",
299
- noon: "noon",
300
- morning: "in the morning",
301
- afternoon: "in the afternoon",
302
- evening: "in the evening",
303
- night: "at night"
304
- },
305
- wide: {
306
- am: "a.m.",
307
- pm: "p.m.",
308
- midnight: "midnight",
309
- noon: "noon",
310
- morning: "in the morning",
311
- afternoon: "in the afternoon",
312
- evening: "in the evening",
313
- night: "at night"
314
- }
315
- }, Qe = (r, e) => {
316
- const t = Number(r), n = t % 100;
317
- if (n > 20 || n < 10)
318
- switch (n % 10) {
319
- case 1:
320
- return t + "st";
321
- case 2:
322
- return t + "nd";
323
- case 3:
324
- return t + "rd";
325
- }
326
- return t + "th";
327
- }, Re = {
328
- ordinalNumber: Qe,
329
- era: q({
330
- values: qe,
331
- defaultWidth: "wide"
332
- }),
333
- quarter: q({
334
- values: Ne,
335
- defaultWidth: "wide",
336
- argumentCallback: (r) => r - 1
337
- }),
338
- month: q({
339
- values: Ie,
340
- defaultWidth: "wide"
341
- }),
342
- day: q({
343
- values: Fe,
344
- defaultWidth: "wide"
345
- }),
346
- dayPeriod: q({
347
- values: Le,
348
- defaultWidth: "wide",
349
- formattingValues: Ce,
350
- defaultFormattingWidth: "wide"
351
- })
352
- };
353
- function N(r) {
354
- return (e, t = {}) => {
355
- const n = t.width, a = n && r.matchPatterns[n] || r.matchPatterns[r.defaultMatchWidth], s = e.match(a);
356
- if (!s)
357
- return null;
358
- const o = s[0], i = n && r.parsePatterns[n] || r.parsePatterns[r.defaultParseWidth], b = Array.isArray(i) ? Ae(i, (g) => g.test(o)) : (
359
- // [TODO] -- I challenge you to fix the type
360
- Xe(i, (g) => g.test(o))
361
- );
362
- let M;
363
- M = r.valueCallback ? r.valueCallback(b) : b, M = t.valueCallback ? (
364
- // [TODO] -- I challenge you to fix the type
365
- t.valueCallback(M)
366
- ) : M;
367
- const m = e.slice(o.length);
368
- return { value: M, rest: m };
369
- };
370
- }
371
- function Xe(r, e) {
372
- for (const t in r)
373
- if (Object.prototype.hasOwnProperty.call(r, t) && e(r[t]))
374
- return t;
375
- }
376
- function Ae(r, e) {
377
- for (let t = 0; t < r.length; t++)
378
- if (e(r[t]))
379
- return t;
380
- }
381
- function Be(r) {
382
- return (e, t = {}) => {
383
- const n = e.match(r.matchPattern);
384
- if (!n) return null;
385
- const a = n[0], s = e.match(r.parsePattern);
386
- if (!s) return null;
387
- let o = r.valueCallback ? r.valueCallback(s[0]) : s[0];
388
- o = t.valueCallback ? t.valueCallback(o) : o;
389
- const i = e.slice(a.length);
390
- return { value: o, rest: i };
391
- };
392
- }
393
- const Ge = /^(\d+)(th|st|nd|rd)?/i, $e = /\d+/i, je = {
394
- narrow: /^(b|a)/i,
395
- abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
396
- wide: /^(before christ|before common era|anno domini|common era)/i
397
- }, Ve = {
398
- any: [/^b/i, /^(a|c)/i]
399
- }, ze = {
400
- narrow: /^[1234]/i,
401
- abbreviated: /^q[1234]/i,
402
- wide: /^[1234](th|st|nd|rd)? quarter/i
403
- }, Je = {
404
- any: [/1/i, /2/i, /3/i, /4/i]
405
- }, Ze = {
406
- narrow: /^[jfmasond]/i,
407
- abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
408
- wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
409
- }, Ke = {
410
- narrow: [
411
- /^j/i,
412
- /^f/i,
413
- /^m/i,
414
- /^a/i,
415
- /^m/i,
416
- /^j/i,
417
- /^j/i,
418
- /^a/i,
419
- /^s/i,
420
- /^o/i,
421
- /^n/i,
422
- /^d/i
423
- ],
424
- any: [
425
- /^ja/i,
426
- /^f/i,
427
- /^mar/i,
428
- /^ap/i,
429
- /^may/i,
430
- /^jun/i,
431
- /^jul/i,
432
- /^au/i,
433
- /^s/i,
434
- /^o/i,
435
- /^n/i,
436
- /^d/i
437
- ]
438
- }, Ue = {
439
- narrow: /^[smtwf]/i,
440
- short: /^(su|mo|tu|we|th|fr|sa)/i,
441
- abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
442
- wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
443
- }, Se = {
444
- narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
445
- any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
446
- }, et = {
447
- narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
448
- any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
449
- }, tt = {
450
- any: {
451
- am: /^a/i,
452
- pm: /^p/i,
453
- midnight: /^mi/i,
454
- noon: /^no/i,
455
- morning: /morning/i,
456
- afternoon: /afternoon/i,
457
- evening: /evening/i,
458
- night: /night/i
459
- }
460
- }, nt = {
461
- ordinalNumber: Be({
462
- matchPattern: Ge,
463
- parsePattern: $e,
464
- valueCallback: (r) => parseInt(r, 10)
465
- }),
466
- era: N({
467
- matchPatterns: je,
468
- defaultMatchWidth: "wide",
469
- parsePatterns: Ve,
470
- defaultParseWidth: "any"
471
- }),
472
- quarter: N({
473
- matchPatterns: ze,
474
- defaultMatchWidth: "wide",
475
- parsePatterns: Je,
476
- defaultParseWidth: "any",
477
- valueCallback: (r) => r + 1
478
- }),
479
- month: N({
480
- matchPatterns: Ze,
481
- defaultMatchWidth: "wide",
482
- parsePatterns: Ke,
483
- defaultParseWidth: "any"
484
- }),
485
- day: N({
486
- matchPatterns: Ue,
487
- defaultMatchWidth: "wide",
488
- parsePatterns: Se,
489
- defaultParseWidth: "any"
490
- }),
491
- dayPeriod: N({
492
- matchPatterns: et,
493
- defaultMatchWidth: "any",
494
- parsePatterns: tt,
495
- defaultParseWidth: "any"
496
- })
497
- }, ie = {
498
- code: "en-US",
499
- formatDistance: Oe,
500
- formatLong: We,
501
- formatRelative: He,
502
- localize: Re,
503
- match: nt,
504
- options: {
505
- weekStartsOn: 0,
506
- firstWeekContainsDate: 1
507
- }
508
- };
509
- function rt(r, e) {
510
- const t = p(r, e?.in);
511
- return xe(t, De(t)) + 1;
512
- }
513
- function ue(r, e) {
514
- const t = p(r, e?.in), n = +_(t) - +Me(t);
515
- return Math.round(n / 6048e5) + 1;
516
- }
517
- function B(r, e) {
518
- const t = p(r, e?.in), n = t.getFullYear(), a = H(), s = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? a.firstWeekContainsDate ?? a.locale?.options?.firstWeekContainsDate ?? 1, o = x(e?.in || r, 0);
519
- o.setFullYear(n + 1, 0, s), o.setHours(0, 0, 0, 0);
520
- const i = O(o, e), b = x(e?.in || r, 0);
521
- b.setFullYear(n, 0, s), b.setHours(0, 0, 0, 0);
522
- const M = O(b, e);
523
- return +t >= +i ? n + 1 : +t >= +M ? n : n - 1;
524
- }
525
- function at(r, e) {
526
- const t = H(), n = e?.firstWeekContainsDate ?? e?.locale?.options?.firstWeekContainsDate ?? t.firstWeekContainsDate ?? t.locale?.options?.firstWeekContainsDate ?? 1, a = B(r, e), s = x(e?.in || r, 0);
527
- return s.setFullYear(a, 0, n), s.setHours(0, 0, 0, 0), O(s, e);
528
- }
529
- function ce(r, e) {
530
- const t = p(r, e?.in), n = +O(t, e) - +at(t, e);
531
- return Math.round(n / 6048e5) + 1;
532
- }
533
- function d(r, e) {
534
- const t = r < 0 ? "-" : "", n = Math.abs(r).toString().padStart(e, "0");
535
- return t + n;
536
- }
537
- const k = {
538
- // Year
539
- y(r, e) {
540
- const t = r.getFullYear(), n = t > 0 ? t : 1 - t;
541
- return d(e === "yy" ? n % 100 : n, e.length);
542
- },
543
- // Month
544
- M(r, e) {
545
- const t = r.getMonth();
546
- return e === "M" ? String(t + 1) : d(t + 1, 2);
547
- },
548
- // Day of the month
549
- d(r, e) {
550
- return d(r.getDate(), e.length);
551
- },
552
- // AM or PM
553
- a(r, e) {
554
- const t = r.getHours() / 12 >= 1 ? "pm" : "am";
555
- switch (e) {
556
- case "a":
557
- case "aa":
558
- return t.toUpperCase();
559
- case "aaa":
560
- return t;
561
- case "aaaaa":
562
- return t[0];
563
- default:
564
- return t === "am" ? "a.m." : "p.m.";
565
- }
566
- },
567
- // Hour [1-12]
568
- h(r, e) {
569
- return d(r.getHours() % 12 || 12, e.length);
570
- },
571
- // Hour [0-23]
572
- H(r, e) {
573
- return d(r.getHours(), e.length);
574
- },
575
- // Minute
576
- m(r, e) {
577
- return d(r.getMinutes(), e.length);
578
- },
579
- // Second
580
- s(r, e) {
581
- return d(r.getSeconds(), e.length);
582
- },
583
- // Fraction of second
584
- S(r, e) {
585
- const t = e.length, n = r.getMilliseconds(), a = Math.trunc(
586
- n * Math.pow(10, t - 3)
587
- );
588
- return d(a, e.length);
589
- }
590
- }, W = {
591
- midnight: "midnight",
592
- noon: "noon",
593
- morning: "morning",
594
- afternoon: "afternoon",
595
- evening: "evening",
596
- night: "night"
597
- }, ee = {
598
- // Era
599
- G: function(r, e, t) {
600
- const n = r.getFullYear() > 0 ? 1 : 0;
601
- switch (e) {
602
- // AD, BC
603
- case "G":
604
- case "GG":
605
- case "GGG":
606
- return t.era(n, { width: "abbreviated" });
607
- // A, B
608
- case "GGGGG":
609
- return t.era(n, { width: "narrow" });
610
- default:
611
- return t.era(n, { width: "wide" });
612
- }
613
- },
614
- // Year
615
- y: function(r, e, t) {
616
- if (e === "yo") {
617
- const n = r.getFullYear(), a = n > 0 ? n : 1 - n;
618
- return t.ordinalNumber(a, { unit: "year" });
619
- }
620
- return k.y(r, e);
621
- },
622
- // Local week-numbering year
623
- Y: function(r, e, t, n) {
624
- const a = B(r, n), s = a > 0 ? a : 1 - a;
625
- if (e === "YY") {
626
- const o = s % 100;
627
- return d(o, 2);
628
- }
629
- return e === "Yo" ? t.ordinalNumber(s, { unit: "year" }) : d(s, e.length);
630
- },
631
- // ISO week-numbering year
632
- R: function(r, e) {
633
- const t = oe(r);
634
- return d(t, e.length);
635
- },
636
- // Extended year. This is a single number designating the year of this calendar system.
637
- // The main difference between `y` and `u` localizers are B.C. years:
638
- // | Year | `y` | `u` |
639
- // |------|-----|-----|
640
- // | AC 1 | 1 | 1 |
641
- // | BC 1 | 1 | 0 |
642
- // | BC 2 | 2 | -1 |
643
- // Also `yy` always returns the last two digits of a year,
644
- // while `uu` pads single digit years to 2 characters and returns other years unchanged.
645
- u: function(r, e) {
646
- const t = r.getFullYear();
647
- return d(t, e.length);
648
- },
649
- // Quarter
650
- Q: function(r, e, t) {
651
- const n = Math.ceil((r.getMonth() + 1) / 3);
652
- switch (e) {
653
- // 1, 2, 3, 4
654
- case "Q":
655
- return String(n);
656
- // 01, 02, 03, 04
657
- case "QQ":
658
- return d(n, 2);
659
- // 1st, 2nd, 3rd, 4th
660
- case "Qo":
661
- return t.ordinalNumber(n, { unit: "quarter" });
662
- // Q1, Q2, Q3, Q4
663
- case "QQQ":
664
- return t.quarter(n, {
665
- width: "abbreviated",
666
- context: "formatting"
667
- });
668
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
669
- case "QQQQQ":
670
- return t.quarter(n, {
671
- width: "narrow",
672
- context: "formatting"
673
- });
674
- default:
675
- return t.quarter(n, {
676
- width: "wide",
677
- context: "formatting"
678
- });
679
- }
680
- },
681
- // Stand-alone quarter
682
- q: function(r, e, t) {
683
- const n = Math.ceil((r.getMonth() + 1) / 3);
684
- switch (e) {
685
- // 1, 2, 3, 4
686
- case "q":
687
- return String(n);
688
- // 01, 02, 03, 04
689
- case "qq":
690
- return d(n, 2);
691
- // 1st, 2nd, 3rd, 4th
692
- case "qo":
693
- return t.ordinalNumber(n, { unit: "quarter" });
694
- // Q1, Q2, Q3, Q4
695
- case "qqq":
696
- return t.quarter(n, {
697
- width: "abbreviated",
698
- context: "standalone"
699
- });
700
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
701
- case "qqqqq":
702
- return t.quarter(n, {
703
- width: "narrow",
704
- context: "standalone"
705
- });
706
- default:
707
- return t.quarter(n, {
708
- width: "wide",
709
- context: "standalone"
710
- });
711
- }
712
- },
713
- // Month
714
- M: function(r, e, t) {
715
- const n = r.getMonth();
716
- switch (e) {
717
- case "M":
718
- case "MM":
719
- return k.M(r, e);
720
- // 1st, 2nd, ..., 12th
721
- case "Mo":
722
- return t.ordinalNumber(n + 1, { unit: "month" });
723
- // Jan, Feb, ..., Dec
724
- case "MMM":
725
- return t.month(n, {
726
- width: "abbreviated",
727
- context: "formatting"
728
- });
729
- // J, F, ..., D
730
- case "MMMMM":
731
- return t.month(n, {
732
- width: "narrow",
733
- context: "formatting"
734
- });
735
- default:
736
- return t.month(n, { width: "wide", context: "formatting" });
737
- }
738
- },
739
- // Stand-alone month
740
- L: function(r, e, t) {
741
- const n = r.getMonth();
742
- switch (e) {
743
- // 1, 2, ..., 12
744
- case "L":
745
- return String(n + 1);
746
- // 01, 02, ..., 12
747
- case "LL":
748
- return d(n + 1, 2);
749
- // 1st, 2nd, ..., 12th
750
- case "Lo":
751
- return t.ordinalNumber(n + 1, { unit: "month" });
752
- // Jan, Feb, ..., Dec
753
- case "LLL":
754
- return t.month(n, {
755
- width: "abbreviated",
756
- context: "standalone"
757
- });
758
- // J, F, ..., D
759
- case "LLLLL":
760
- return t.month(n, {
761
- width: "narrow",
762
- context: "standalone"
763
- });
764
- default:
765
- return t.month(n, { width: "wide", context: "standalone" });
766
- }
767
- },
768
- // Local week of year
769
- w: function(r, e, t, n) {
770
- const a = ce(r, n);
771
- return e === "wo" ? t.ordinalNumber(a, { unit: "week" }) : d(a, e.length);
772
- },
773
- // ISO week of year
774
- I: function(r, e, t) {
775
- const n = ue(r);
776
- return e === "Io" ? t.ordinalNumber(n, { unit: "week" }) : d(n, e.length);
777
- },
778
- // Day of the month
779
- d: function(r, e, t) {
780
- return e === "do" ? t.ordinalNumber(r.getDate(), { unit: "date" }) : k.d(r, e);
781
- },
782
- // Day of year
783
- D: function(r, e, t) {
784
- const n = rt(r);
785
- return e === "Do" ? t.ordinalNumber(n, { unit: "dayOfYear" }) : d(n, e.length);
786
- },
787
- // Day of week
788
- E: function(r, e, t) {
789
- const n = r.getDay();
790
- switch (e) {
791
- // Tue
792
- case "E":
793
- case "EE":
794
- case "EEE":
795
- return t.day(n, {
796
- width: "abbreviated",
797
- context: "formatting"
798
- });
799
- // T
800
- case "EEEEE":
801
- return t.day(n, {
802
- width: "narrow",
803
- context: "formatting"
804
- });
805
- // Tu
806
- case "EEEEEE":
807
- return t.day(n, {
808
- width: "short",
809
- context: "formatting"
810
- });
811
- default:
812
- return t.day(n, {
813
- width: "wide",
814
- context: "formatting"
815
- });
816
- }
817
- },
818
- // Local day of week
819
- e: function(r, e, t, n) {
820
- const a = r.getDay(), s = (a - n.weekStartsOn + 8) % 7 || 7;
821
- switch (e) {
822
- // Numerical value (Nth day of week with current locale or weekStartsOn)
823
- case "e":
824
- return String(s);
825
- // Padded numerical value
826
- case "ee":
827
- return d(s, 2);
828
- // 1st, 2nd, ..., 7th
829
- case "eo":
830
- return t.ordinalNumber(s, { unit: "day" });
831
- case "eee":
832
- return t.day(a, {
833
- width: "abbreviated",
834
- context: "formatting"
835
- });
836
- // T
837
- case "eeeee":
838
- return t.day(a, {
839
- width: "narrow",
840
- context: "formatting"
841
- });
842
- // Tu
843
- case "eeeeee":
844
- return t.day(a, {
845
- width: "short",
846
- context: "formatting"
847
- });
848
- default:
849
- return t.day(a, {
850
- width: "wide",
851
- context: "formatting"
852
- });
853
- }
854
- },
855
- // Stand-alone local day of week
856
- c: function(r, e, t, n) {
857
- const a = r.getDay(), s = (a - n.weekStartsOn + 8) % 7 || 7;
858
- switch (e) {
859
- // Numerical value (same as in `e`)
860
- case "c":
861
- return String(s);
862
- // Padded numerical value
863
- case "cc":
864
- return d(s, e.length);
865
- // 1st, 2nd, ..., 7th
866
- case "co":
867
- return t.ordinalNumber(s, { unit: "day" });
868
- case "ccc":
869
- return t.day(a, {
870
- width: "abbreviated",
871
- context: "standalone"
872
- });
873
- // T
874
- case "ccccc":
875
- return t.day(a, {
876
- width: "narrow",
877
- context: "standalone"
878
- });
879
- // Tu
880
- case "cccccc":
881
- return t.day(a, {
882
- width: "short",
883
- context: "standalone"
884
- });
885
- default:
886
- return t.day(a, {
887
- width: "wide",
888
- context: "standalone"
889
- });
890
- }
891
- },
892
- // ISO day of week
893
- i: function(r, e, t) {
894
- const n = r.getDay(), a = n === 0 ? 7 : n;
895
- switch (e) {
896
- // 2
897
- case "i":
898
- return String(a);
899
- // 02
900
- case "ii":
901
- return d(a, e.length);
902
- // 2nd
903
- case "io":
904
- return t.ordinalNumber(a, { unit: "day" });
905
- // Tue
906
- case "iii":
907
- return t.day(n, {
908
- width: "abbreviated",
909
- context: "formatting"
910
- });
911
- // T
912
- case "iiiii":
913
- return t.day(n, {
914
- width: "narrow",
915
- context: "formatting"
916
- });
917
- // Tu
918
- case "iiiiii":
919
- return t.day(n, {
920
- width: "short",
921
- context: "formatting"
922
- });
923
- default:
924
- return t.day(n, {
925
- width: "wide",
926
- context: "formatting"
927
- });
928
- }
929
- },
930
- // AM or PM
931
- a: function(r, e, t) {
932
- const a = r.getHours() / 12 >= 1 ? "pm" : "am";
933
- switch (e) {
934
- case "a":
935
- case "aa":
936
- return t.dayPeriod(a, {
937
- width: "abbreviated",
938
- context: "formatting"
939
- });
940
- case "aaa":
941
- return t.dayPeriod(a, {
942
- width: "abbreviated",
943
- context: "formatting"
944
- }).toLowerCase();
945
- case "aaaaa":
946
- return t.dayPeriod(a, {
947
- width: "narrow",
948
- context: "formatting"
949
- });
950
- default:
951
- return t.dayPeriod(a, {
952
- width: "wide",
953
- context: "formatting"
954
- });
955
- }
956
- },
957
- // AM, PM, midnight, noon
958
- b: function(r, e, t) {
959
- const n = r.getHours();
960
- let a;
961
- switch (n === 12 ? a = W.noon : n === 0 ? a = W.midnight : a = n / 12 >= 1 ? "pm" : "am", e) {
962
- case "b":
963
- case "bb":
964
- return t.dayPeriod(a, {
965
- width: "abbreviated",
966
- context: "formatting"
967
- });
968
- case "bbb":
969
- return t.dayPeriod(a, {
970
- width: "abbreviated",
971
- context: "formatting"
972
- }).toLowerCase();
973
- case "bbbbb":
974
- return t.dayPeriod(a, {
975
- width: "narrow",
976
- context: "formatting"
977
- });
978
- default:
979
- return t.dayPeriod(a, {
980
- width: "wide",
981
- context: "formatting"
982
- });
983
- }
984
- },
985
- // in the morning, in the afternoon, in the evening, at night
986
- B: function(r, e, t) {
987
- const n = r.getHours();
988
- let a;
989
- switch (n >= 17 ? a = W.evening : n >= 12 ? a = W.afternoon : n >= 4 ? a = W.morning : a = W.night, e) {
990
- case "B":
991
- case "BB":
992
- case "BBB":
993
- return t.dayPeriod(a, {
994
- width: "abbreviated",
995
- context: "formatting"
996
- });
997
- case "BBBBB":
998
- return t.dayPeriod(a, {
999
- width: "narrow",
1000
- context: "formatting"
1001
- });
1002
- default:
1003
- return t.dayPeriod(a, {
1004
- width: "wide",
1005
- context: "formatting"
1006
- });
1007
- }
1008
- },
1009
- // Hour [1-12]
1010
- h: function(r, e, t) {
1011
- if (e === "ho") {
1012
- let n = r.getHours() % 12;
1013
- return n === 0 && (n = 12), t.ordinalNumber(n, { unit: "hour" });
1014
- }
1015
- return k.h(r, e);
1016
- },
1017
- // Hour [0-23]
1018
- H: function(r, e, t) {
1019
- return e === "Ho" ? t.ordinalNumber(r.getHours(), { unit: "hour" }) : k.H(r, e);
1020
- },
1021
- // Hour [0-11]
1022
- K: function(r, e, t) {
1023
- const n = r.getHours() % 12;
1024
- return e === "Ko" ? t.ordinalNumber(n, { unit: "hour" }) : d(n, e.length);
1025
- },
1026
- // Hour [1-24]
1027
- k: function(r, e, t) {
1028
- let n = r.getHours();
1029
- return n === 0 && (n = 24), e === "ko" ? t.ordinalNumber(n, { unit: "hour" }) : d(n, e.length);
1030
- },
1031
- // Minute
1032
- m: function(r, e, t) {
1033
- return e === "mo" ? t.ordinalNumber(r.getMinutes(), { unit: "minute" }) : k.m(r, e);
1034
- },
1035
- // Second
1036
- s: function(r, e, t) {
1037
- return e === "so" ? t.ordinalNumber(r.getSeconds(), { unit: "second" }) : k.s(r, e);
1038
- },
1039
- // Fraction of second
1040
- S: function(r, e) {
1041
- return k.S(r, e);
1042
- },
1043
- // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1044
- X: function(r, e, t) {
1045
- const n = r.getTimezoneOffset();
1046
- if (n === 0)
1047
- return "Z";
1048
- switch (e) {
1049
- // Hours and optional minutes
1050
- case "X":
1051
- return ne(n);
1052
- // Hours, minutes and optional seconds without `:` delimiter
1053
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1054
- // so this token always has the same output as `XX`
1055
- case "XXXX":
1056
- case "XX":
1057
- return Y(n);
1058
- // Hours and minutes with `:` delimiter
1059
- default:
1060
- return Y(n, ":");
1061
- }
1062
- },
1063
- // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1064
- x: function(r, e, t) {
1065
- const n = r.getTimezoneOffset();
1066
- switch (e) {
1067
- // Hours and optional minutes
1068
- case "x":
1069
- return ne(n);
1070
- // Hours, minutes and optional seconds without `:` delimiter
1071
- // Note: neither ISO-8601 nor JavaScript supports seconds in timezone offsets
1072
- // so this token always has the same output as `xx`
1073
- case "xxxx":
1074
- case "xx":
1075
- return Y(n);
1076
- // Hours and minutes with `:` delimiter
1077
- default:
1078
- return Y(n, ":");
1079
- }
1080
- },
1081
- // Timezone (GMT)
1082
- O: function(r, e, t) {
1083
- const n = r.getTimezoneOffset();
1084
- switch (e) {
1085
- // Short
1086
- case "O":
1087
- case "OO":
1088
- case "OOO":
1089
- return "GMT" + te(n, ":");
1090
- default:
1091
- return "GMT" + Y(n, ":");
1092
- }
1093
- },
1094
- // Timezone (specific non-location)
1095
- z: function(r, e, t) {
1096
- const n = r.getTimezoneOffset();
1097
- switch (e) {
1098
- // Short
1099
- case "z":
1100
- case "zz":
1101
- case "zzz":
1102
- return "GMT" + te(n, ":");
1103
- default:
1104
- return "GMT" + Y(n, ":");
1105
- }
1106
- },
1107
- // Seconds timestamp
1108
- t: function(r, e, t) {
1109
- const n = Math.trunc(+r / 1e3);
1110
- return d(n, e.length);
1111
- },
1112
- // Milliseconds timestamp
1113
- T: function(r, e, t) {
1114
- return d(+r, e.length);
1115
- }
1116
- };
1117
- function te(r, e = "") {
1118
- const t = r > 0 ? "-" : "+", n = Math.abs(r), a = Math.trunc(n / 60), s = n % 60;
1119
- return s === 0 ? t + String(a) : t + String(a) + e + d(s, 2);
1120
- }
1121
- function ne(r, e) {
1122
- return r % 60 === 0 ? (r > 0 ? "-" : "+") + d(Math.abs(r) / 60, 2) : Y(r, e);
1123
- }
1124
- function Y(r, e = "") {
1125
- const t = r > 0 ? "-" : "+", n = Math.abs(r), a = d(Math.trunc(n / 60), 2), s = d(n % 60, 2);
1126
- return t + a + e + s;
1127
- }
1128
- const re = (r, e) => {
1129
- switch (r) {
1130
- case "P":
1131
- return e.date({ width: "short" });
1132
- case "PP":
1133
- return e.date({ width: "medium" });
1134
- case "PPP":
1135
- return e.date({ width: "long" });
1136
- default:
1137
- return e.date({ width: "full" });
1138
- }
1139
- }, de = (r, e) => {
1140
- switch (r) {
1141
- case "p":
1142
- return e.time({ width: "short" });
1143
- case "pp":
1144
- return e.time({ width: "medium" });
1145
- case "ppp":
1146
- return e.time({ width: "long" });
1147
- default:
1148
- return e.time({ width: "full" });
1149
- }
1150
- }, st = (r, e) => {
1151
- const t = r.match(/(P+)(p+)?/) || [], n = t[1], a = t[2];
1152
- if (!a)
1153
- return re(r, e);
1154
- let s;
1155
- switch (n) {
1156
- case "P":
1157
- s = e.dateTime({ width: "short" });
1158
- break;
1159
- case "PP":
1160
- s = e.dateTime({ width: "medium" });
1161
- break;
1162
- case "PPP":
1163
- s = e.dateTime({ width: "long" });
1164
- break;
1165
- default:
1166
- s = e.dateTime({ width: "full" });
1167
- break;
1168
- }
1169
- return s.replace("{{date}}", re(n, e)).replace("{{time}}", de(a, e));
1170
- }, X = {
1171
- p: de,
1172
- P: st
1173
- }, ot = /^D+$/, it = /^Y+$/, ut = ["D", "DD", "YY", "YYYY"];
1174
- function le(r) {
1175
- return ot.test(r);
1176
- }
1177
- function fe(r) {
1178
- return it.test(r);
1179
- }
1180
- function A(r, e, t) {
1181
- const n = ct(r, e, t);
1182
- if (console.warn(n), ut.includes(r)) throw new RangeError(n);
1183
- }
1184
- function ct(r, e, t) {
1185
- const n = r[0] === "Y" ? "years" : "days of the month";
1186
- return `Use \`${r.toLowerCase()}\` instead of \`${r}\` (in \`${e}\`) for formatting ${n} to the input \`${t}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
1187
- }
1188
- const dt = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, lt = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, ft = /^'([^]*?)'?$/, ht = /''/g, mt = /[a-zA-Z]/;
1189
- function G(r, e, t) {
1190
- const n = H(), a = n.locale ?? ie, s = n.firstWeekContainsDate ?? n.locale?.options?.firstWeekContainsDate ?? 1, o = n.weekStartsOn ?? n.locale?.options?.weekStartsOn ?? 0, i = p(r, t?.in);
1191
- if (!Te(i))
1192
- throw new RangeError("Invalid time value");
1193
- let b = e.match(lt).map((m) => {
1194
- const g = m[0];
1195
- if (g === "p" || g === "P") {
1196
- const v = X[g];
1197
- return v(m, a.formatLong);
1198
- }
1199
- return m;
1200
- }).join("").match(dt).map((m) => {
1201
- if (m === "''")
1202
- return { isToken: !1, value: "'" };
1203
- const g = m[0];
1204
- if (g === "'")
1205
- return { isToken: !1, value: wt(m) };
1206
- if (ee[g])
1207
- return { isToken: !0, value: m };
1208
- if (g.match(mt))
1209
- throw new RangeError(
1210
- "Format string contains an unescaped latin alphabet character `" + g + "`"
1211
- );
1212
- return { isToken: !1, value: m };
1213
- });
1214
- a.localize.preprocessor && (b = a.localize.preprocessor(i, b));
1215
- const M = {
1216
- firstWeekContainsDate: s,
1217
- weekStartsOn: o,
1218
- locale: a
1219
- };
1220
- return b.map((m) => {
1221
- if (!m.isToken) return m.value;
1222
- const g = m.value;
1223
- (fe(g) || le(g)) && A(g, e, String(r));
1224
- const v = ee[g[0]];
1225
- return v(i, g, a.localize, M);
1226
- }).join("");
1227
- }
1228
- function wt(r) {
1229
- const e = r.match(ft);
1230
- return e ? e[1].replace(ht, "'") : r;
1231
- }
1232
- function yt() {
1233
- return Object.assign({}, H());
1234
- }
1235
- function bt(r, e) {
1236
- const t = p(r, e?.in).getDay();
1237
- return t === 0 ? 7 : t;
1238
- }
1239
- function ae(r) {
1240
- return Math.trunc(r * 36e5);
1241
- }
1242
- function gt(r, e) {
1243
- const t = pt(e) ? new e(0) : x(e, 0);
1244
- return t.setFullYear(r.getFullYear(), r.getMonth(), r.getDate()), t.setHours(
1245
- r.getHours(),
1246
- r.getMinutes(),
1247
- r.getSeconds(),
1248
- r.getMilliseconds()
1249
- ), t;
1250
- }
1251
- function pt(r) {
1252
- return typeof r == "function" && r.prototype?.constructor === r;
1253
- }
1254
- const xt = 10;
1255
- class he {
1256
- subPriority = 0;
1257
- validate(e, t) {
1258
- return !0;
1259
- }
1260
- }
1261
- class Mt extends he {
1262
- constructor(e, t, n, a, s) {
1263
- super(), this.value = e, this.validateValue = t, this.setValue = n, this.priority = a, s && (this.subPriority = s);
1264
- }
1265
- validate(e, t) {
1266
- return this.validateValue(e, this.value, t);
1267
- }
1268
- set(e, t, n) {
1269
- return this.setValue(e, t, this.value, n);
1270
- }
1271
- }
1272
- class Pt extends he {
1273
- priority = xt;
1274
- subPriority = -1;
1275
- constructor(e, t) {
1276
- super(), this.context = e || ((n) => x(t, n));
1277
- }
1278
- set(e, t) {
1279
- return t.timestampIsSet ? e : x(e, gt(e, this.context));
1280
- }
1281
- }
1282
- class c {
1283
- run(e, t, n, a) {
1284
- const s = this.parse(e, t, n, a);
1285
- return s ? {
1286
- setter: new Mt(
1287
- s.value,
1288
- this.validate,
1289
- this.set,
1290
- this.priority,
1291
- this.subPriority
1292
- ),
1293
- rest: s.rest
1294
- } : null;
1295
- }
1296
- validate(e, t, n) {
1297
- return !0;
1298
- }
1299
- }
1300
- class Tt extends c {
1301
- priority = 140;
1302
- parse(e, t, n) {
1303
- switch (t) {
1304
- // AD, BC
1305
- case "G":
1306
- case "GG":
1307
- case "GGG":
1308
- return n.era(e, { width: "abbreviated" }) || n.era(e, { width: "narrow" });
1309
- // A, B
1310
- case "GGGGG":
1311
- return n.era(e, { width: "narrow" });
1312
- default:
1313
- return n.era(e, { width: "wide" }) || n.era(e, { width: "abbreviated" }) || n.era(e, { width: "narrow" });
1314
- }
1315
- }
1316
- set(e, t, n) {
1317
- return t.era = n, e.setFullYear(n, 0, 1), e.setHours(0, 0, 0, 0), e;
1318
- }
1319
- incompatibleTokens = ["R", "u", "t", "T"];
1320
- }
1321
- const w = {
1322
- month: /^(1[0-2]|0?\d)/,
1323
- // 0 to 12
1324
- date: /^(3[0-1]|[0-2]?\d)/,
1325
- // 0 to 31
1326
- dayOfYear: /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,
1327
- // 0 to 366
1328
- week: /^(5[0-3]|[0-4]?\d)/,
1329
- // 0 to 53
1330
- hour23h: /^(2[0-3]|[0-1]?\d)/,
1331
- // 0 to 23
1332
- hour24h: /^(2[0-4]|[0-1]?\d)/,
1333
- // 0 to 24
1334
- hour11h: /^(1[0-1]|0?\d)/,
1335
- // 0 to 11
1336
- hour12h: /^(1[0-2]|0?\d)/,
1337
- // 0 to 12
1338
- minute: /^[0-5]?\d/,
1339
- // 0 to 59
1340
- second: /^[0-5]?\d/,
1341
- // 0 to 59
1342
- singleDigit: /^\d/,
1343
- // 0 to 9
1344
- twoDigits: /^\d{1,2}/,
1345
- // 0 to 99
1346
- threeDigits: /^\d{1,3}/,
1347
- // 0 to 999
1348
- fourDigits: /^\d{1,4}/,
1349
- // 0 to 9999
1350
- anyDigitsSigned: /^-?\d+/,
1351
- singleDigitSigned: /^-?\d/,
1352
- // 0 to 9, -0 to -9
1353
- twoDigitsSigned: /^-?\d{1,2}/,
1354
- // 0 to 99, -0 to -99
1355
- threeDigitsSigned: /^-?\d{1,3}/,
1356
- // 0 to 999, -0 to -999
1357
- fourDigitsSigned: /^-?\d{1,4}/
1358
- // 0 to 9999, -0 to -9999
1359
- }, T = {
1360
- basicOptionalMinutes: /^([+-])(\d{2})(\d{2})?|Z/,
1361
- basic: /^([+-])(\d{2})(\d{2})|Z/,
1362
- basicOptionalSeconds: /^([+-])(\d{2})(\d{2})((\d{2}))?|Z/,
1363
- extended: /^([+-])(\d{2}):(\d{2})|Z/,
1364
- extendedOptionalSeconds: /^([+-])(\d{2}):(\d{2})(:(\d{2}))?|Z/
1365
- };
1366
- function y(r, e) {
1367
- return r && {
1368
- value: e(r.value),
1369
- rest: r.rest
1370
- };
1371
- }
1372
- function l(r, e) {
1373
- const t = e.match(r);
1374
- return t ? {
1375
- value: parseInt(t[0], 10),
1376
- rest: e.slice(t[0].length)
1377
- } : null;
1378
- }
1379
- function D(r, e) {
1380
- const t = e.match(r);
1381
- if (!t)
1382
- return null;
1383
- if (t[0] === "Z")
1384
- return {
1385
- value: 0,
1386
- rest: e.slice(1)
1387
- };
1388
- const n = t[1] === "+" ? 1 : -1, a = t[2] ? parseInt(t[2], 10) : 0, s = t[3] ? parseInt(t[3], 10) : 0, o = t[5] ? parseInt(t[5], 10) : 0;
1389
- return {
1390
- value: n * (a * 36e5 + s * 6e4 + o * 1e3),
1391
- rest: e.slice(t[0].length)
1392
- };
1393
- }
1394
- function me(r) {
1395
- return l(w.anyDigitsSigned, r);
1396
- }
1397
- function h(r, e) {
1398
- switch (r) {
1399
- case 1:
1400
- return l(w.singleDigit, e);
1401
- case 2:
1402
- return l(w.twoDigits, e);
1403
- case 3:
1404
- return l(w.threeDigits, e);
1405
- case 4:
1406
- return l(w.fourDigits, e);
1407
- default:
1408
- return l(new RegExp("^\\d{1," + r + "}"), e);
1409
- }
1410
- }
1411
- function L(r, e) {
1412
- switch (r) {
1413
- case 1:
1414
- return l(w.singleDigitSigned, e);
1415
- case 2:
1416
- return l(w.twoDigitsSigned, e);
1417
- case 3:
1418
- return l(w.threeDigitsSigned, e);
1419
- case 4:
1420
- return l(w.fourDigitsSigned, e);
1421
- default:
1422
- return l(new RegExp("^-?\\d{1," + r + "}"), e);
1423
- }
1424
- }
1425
- function $(r) {
1426
- switch (r) {
1427
- case "morning":
1428
- return 4;
1429
- case "evening":
1430
- return 17;
1431
- case "pm":
1432
- case "noon":
1433
- case "afternoon":
1434
- return 12;
1435
- default:
1436
- return 0;
1437
- }
1438
- }
1439
- function we(r, e) {
1440
- const t = e > 0, n = t ? e : 1 - e;
1441
- let a;
1442
- if (n <= 50)
1443
- a = r || 100;
1444
- else {
1445
- const s = n + 50, o = Math.trunc(s / 100) * 100, i = r >= s % 100;
1446
- a = r + o - (i ? 100 : 0);
1447
- }
1448
- return t ? a : 1 - a;
1449
- }
1450
- function ye(r) {
1451
- return r % 400 === 0 || r % 4 === 0 && r % 100 !== 0;
1452
- }
1453
- class Dt extends c {
1454
- priority = 130;
1455
- incompatibleTokens = ["Y", "R", "u", "w", "I", "i", "e", "c", "t", "T"];
1456
- parse(e, t, n) {
1457
- const a = (s) => ({
1458
- year: s,
1459
- isTwoDigitYear: t === "yy"
1460
- });
1461
- switch (t) {
1462
- case "y":
1463
- return y(h(4, e), a);
1464
- case "yo":
1465
- return y(
1466
- n.ordinalNumber(e, {
1467
- unit: "year"
1468
- }),
1469
- a
1470
- );
1471
- default:
1472
- return y(h(t.length, e), a);
1473
- }
1474
- }
1475
- validate(e, t) {
1476
- return t.isTwoDigitYear || t.year > 0;
1477
- }
1478
- set(e, t, n) {
1479
- const a = e.getFullYear();
1480
- if (n.isTwoDigitYear) {
1481
- const o = we(
1482
- n.year,
1483
- a
1484
- );
1485
- return e.setFullYear(o, 0, 1), e.setHours(0, 0, 0, 0), e;
1486
- }
1487
- const s = !("era" in t) || t.era === 1 ? n.year : 1 - n.year;
1488
- return e.setFullYear(s, 0, 1), e.setHours(0, 0, 0, 0), e;
1489
- }
1490
- }
1491
- class kt extends c {
1492
- priority = 130;
1493
- parse(e, t, n) {
1494
- const a = (s) => ({
1495
- year: s,
1496
- isTwoDigitYear: t === "YY"
1497
- });
1498
- switch (t) {
1499
- case "Y":
1500
- return y(h(4, e), a);
1501
- case "Yo":
1502
- return y(
1503
- n.ordinalNumber(e, {
1504
- unit: "year"
1505
- }),
1506
- a
1507
- );
1508
- default:
1509
- return y(h(t.length, e), a);
1510
- }
1511
- }
1512
- validate(e, t) {
1513
- return t.isTwoDigitYear || t.year > 0;
1514
- }
1515
- set(e, t, n, a) {
1516
- const s = B(e, a);
1517
- if (n.isTwoDigitYear) {
1518
- const i = we(
1519
- n.year,
1520
- s
1521
- );
1522
- return e.setFullYear(
1523
- i,
1524
- 0,
1525
- a.firstWeekContainsDate
1526
- ), e.setHours(0, 0, 0, 0), O(e, a);
1527
- }
1528
- const o = !("era" in t) || t.era === 1 ? n.year : 1 - n.year;
1529
- return e.setFullYear(o, 0, a.firstWeekContainsDate), e.setHours(0, 0, 0, 0), O(e, a);
1530
- }
1531
- incompatibleTokens = [
1532
- "y",
1533
- "R",
1534
- "u",
1535
- "Q",
1536
- "q",
1537
- "M",
1538
- "L",
1539
- "I",
1540
- "d",
1541
- "D",
1542
- "i",
1543
- "t",
1544
- "T"
1545
- ];
1546
- }
1547
- class Ot extends c {
1548
- priority = 130;
1549
- parse(e, t) {
1550
- return L(t === "R" ? 4 : t.length, e);
1551
- }
1552
- set(e, t, n) {
1553
- const a = x(e, 0);
1554
- return a.setFullYear(n, 0, 4), a.setHours(0, 0, 0, 0), _(a);
1555
- }
1556
- incompatibleTokens = [
1557
- "G",
1558
- "y",
1559
- "Y",
1560
- "u",
1561
- "Q",
1562
- "q",
1563
- "M",
1564
- "L",
1565
- "w",
1566
- "d",
1567
- "D",
1568
- "e",
1569
- "c",
1570
- "t",
1571
- "T"
1572
- ];
1573
- }
1574
- class vt extends c {
1575
- priority = 130;
1576
- parse(e, t) {
1577
- return L(t === "u" ? 4 : t.length, e);
1578
- }
1579
- set(e, t, n) {
1580
- return e.setFullYear(n, 0, 1), e.setHours(0, 0, 0, 0), e;
1581
- }
1582
- incompatibleTokens = ["G", "y", "Y", "R", "w", "I", "i", "e", "c", "t", "T"];
1583
- }
1584
- class Yt extends c {
1585
- priority = 120;
1586
- parse(e, t, n) {
1587
- switch (t) {
1588
- // 1, 2, 3, 4
1589
- case "Q":
1590
- case "QQ":
1591
- return h(t.length, e);
1592
- // 1st, 2nd, 3rd, 4th
1593
- case "Qo":
1594
- return n.ordinalNumber(e, { unit: "quarter" });
1595
- // Q1, Q2, Q3, Q4
1596
- case "QQQ":
1597
- return n.quarter(e, {
1598
- width: "abbreviated",
1599
- context: "formatting"
1600
- }) || n.quarter(e, {
1601
- width: "narrow",
1602
- context: "formatting"
1603
- });
1604
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1605
- case "QQQQQ":
1606
- return n.quarter(e, {
1607
- width: "narrow",
1608
- context: "formatting"
1609
- });
1610
- default:
1611
- return n.quarter(e, {
1612
- width: "wide",
1613
- context: "formatting"
1614
- }) || n.quarter(e, {
1615
- width: "abbreviated",
1616
- context: "formatting"
1617
- }) || n.quarter(e, {
1618
- width: "narrow",
1619
- context: "formatting"
1620
- });
1621
- }
1622
- }
1623
- validate(e, t) {
1624
- return t >= 1 && t <= 4;
1625
- }
1626
- set(e, t, n) {
1627
- return e.setMonth((n - 1) * 3, 1), e.setHours(0, 0, 0, 0), e;
1628
- }
1629
- incompatibleTokens = [
1630
- "Y",
1631
- "R",
1632
- "q",
1633
- "M",
1634
- "L",
1635
- "w",
1636
- "I",
1637
- "d",
1638
- "D",
1639
- "i",
1640
- "e",
1641
- "c",
1642
- "t",
1643
- "T"
1644
- ];
1645
- }
1646
- class Et extends c {
1647
- priority = 120;
1648
- parse(e, t, n) {
1649
- switch (t) {
1650
- // 1, 2, 3, 4
1651
- case "q":
1652
- case "qq":
1653
- return h(t.length, e);
1654
- // 1st, 2nd, 3rd, 4th
1655
- case "qo":
1656
- return n.ordinalNumber(e, { unit: "quarter" });
1657
- // Q1, Q2, Q3, Q4
1658
- case "qqq":
1659
- return n.quarter(e, {
1660
- width: "abbreviated",
1661
- context: "standalone"
1662
- }) || n.quarter(e, {
1663
- width: "narrow",
1664
- context: "standalone"
1665
- });
1666
- // 1, 2, 3, 4 (narrow quarter; could be not numerical)
1667
- case "qqqqq":
1668
- return n.quarter(e, {
1669
- width: "narrow",
1670
- context: "standalone"
1671
- });
1672
- default:
1673
- return n.quarter(e, {
1674
- width: "wide",
1675
- context: "standalone"
1676
- }) || n.quarter(e, {
1677
- width: "abbreviated",
1678
- context: "standalone"
1679
- }) || n.quarter(e, {
1680
- width: "narrow",
1681
- context: "standalone"
1682
- });
1683
- }
1684
- }
1685
- validate(e, t) {
1686
- return t >= 1 && t <= 4;
1687
- }
1688
- set(e, t, n) {
1689
- return e.setMonth((n - 1) * 3, 1), e.setHours(0, 0, 0, 0), e;
1690
- }
1691
- incompatibleTokens = [
1692
- "Y",
1693
- "R",
1694
- "Q",
1695
- "M",
1696
- "L",
1697
- "w",
1698
- "I",
1699
- "d",
1700
- "D",
1701
- "i",
1702
- "e",
1703
- "c",
1704
- "t",
1705
- "T"
1706
- ];
1707
- }
1708
- class Wt extends c {
1709
- incompatibleTokens = [
1710
- "Y",
1711
- "R",
1712
- "q",
1713
- "Q",
1714
- "L",
1715
- "w",
1716
- "I",
1717
- "D",
1718
- "i",
1719
- "e",
1720
- "c",
1721
- "t",
1722
- "T"
1723
- ];
1724
- priority = 110;
1725
- parse(e, t, n) {
1726
- const a = (s) => s - 1;
1727
- switch (t) {
1728
- // 1, 2, ..., 12
1729
- case "M":
1730
- return y(
1731
- l(w.month, e),
1732
- a
1733
- );
1734
- // 01, 02, ..., 12
1735
- case "MM":
1736
- return y(h(2, e), a);
1737
- // 1st, 2nd, ..., 12th
1738
- case "Mo":
1739
- return y(
1740
- n.ordinalNumber(e, {
1741
- unit: "month"
1742
- }),
1743
- a
1744
- );
1745
- // Jan, Feb, ..., Dec
1746
- case "MMM":
1747
- return n.month(e, {
1748
- width: "abbreviated",
1749
- context: "formatting"
1750
- }) || n.month(e, { width: "narrow", context: "formatting" });
1751
- // J, F, ..., D
1752
- case "MMMMM":
1753
- return n.month(e, {
1754
- width: "narrow",
1755
- context: "formatting"
1756
- });
1757
- default:
1758
- return n.month(e, { width: "wide", context: "formatting" }) || n.month(e, {
1759
- width: "abbreviated",
1760
- context: "formatting"
1761
- }) || n.month(e, { width: "narrow", context: "formatting" });
1762
- }
1763
- }
1764
- validate(e, t) {
1765
- return t >= 0 && t <= 11;
1766
- }
1767
- set(e, t, n) {
1768
- return e.setMonth(n, 1), e.setHours(0, 0, 0, 0), e;
1769
- }
1770
- }
1771
- class _t extends c {
1772
- priority = 110;
1773
- parse(e, t, n) {
1774
- const a = (s) => s - 1;
1775
- switch (t) {
1776
- // 1, 2, ..., 12
1777
- case "L":
1778
- return y(
1779
- l(w.month, e),
1780
- a
1781
- );
1782
- // 01, 02, ..., 12
1783
- case "LL":
1784
- return y(h(2, e), a);
1785
- // 1st, 2nd, ..., 12th
1786
- case "Lo":
1787
- return y(
1788
- n.ordinalNumber(e, {
1789
- unit: "month"
1790
- }),
1791
- a
1792
- );
1793
- // Jan, Feb, ..., Dec
1794
- case "LLL":
1795
- return n.month(e, {
1796
- width: "abbreviated",
1797
- context: "standalone"
1798
- }) || n.month(e, { width: "narrow", context: "standalone" });
1799
- // J, F, ..., D
1800
- case "LLLLL":
1801
- return n.month(e, {
1802
- width: "narrow",
1803
- context: "standalone"
1804
- });
1805
- default:
1806
- return n.month(e, { width: "wide", context: "standalone" }) || n.month(e, {
1807
- width: "abbreviated",
1808
- context: "standalone"
1809
- }) || n.month(e, { width: "narrow", context: "standalone" });
1810
- }
1811
- }
1812
- validate(e, t) {
1813
- return t >= 0 && t <= 11;
1814
- }
1815
- set(e, t, n) {
1816
- return e.setMonth(n, 1), e.setHours(0, 0, 0, 0), e;
1817
- }
1818
- incompatibleTokens = [
1819
- "Y",
1820
- "R",
1821
- "q",
1822
- "Q",
1823
- "M",
1824
- "w",
1825
- "I",
1826
- "D",
1827
- "i",
1828
- "e",
1829
- "c",
1830
- "t",
1831
- "T"
1832
- ];
1833
- }
1834
- function Ht(r, e, t) {
1835
- const n = p(r, t?.in), a = ce(n, t) - e;
1836
- return n.setDate(n.getDate() - a * 7), p(n, t?.in);
1837
- }
1838
- class qt extends c {
1839
- priority = 100;
1840
- parse(e, t, n) {
1841
- switch (t) {
1842
- case "w":
1843
- return l(w.week, e);
1844
- case "wo":
1845
- return n.ordinalNumber(e, { unit: "week" });
1846
- default:
1847
- return h(t.length, e);
1848
- }
1849
- }
1850
- validate(e, t) {
1851
- return t >= 1 && t <= 53;
1852
- }
1853
- set(e, t, n, a) {
1854
- return O(Ht(e, n, a), a);
1855
- }
1856
- incompatibleTokens = [
1857
- "y",
1858
- "R",
1859
- "u",
1860
- "q",
1861
- "Q",
1862
- "M",
1863
- "L",
1864
- "I",
1865
- "d",
1866
- "D",
1867
- "i",
1868
- "t",
1869
- "T"
1870
- ];
1871
- }
1872
- function Nt(r, e, t) {
1873
- const n = p(r, t?.in), a = ue(n, t) - e;
1874
- return n.setDate(n.getDate() - a * 7), n;
1875
- }
1876
- class It extends c {
1877
- priority = 100;
1878
- parse(e, t, n) {
1879
- switch (t) {
1880
- case "I":
1881
- return l(w.week, e);
1882
- case "Io":
1883
- return n.ordinalNumber(e, { unit: "week" });
1884
- default:
1885
- return h(t.length, e);
1886
- }
1887
- }
1888
- validate(e, t) {
1889
- return t >= 1 && t <= 53;
1890
- }
1891
- set(e, t, n) {
1892
- return _(Nt(e, n));
1893
- }
1894
- incompatibleTokens = [
1895
- "y",
1896
- "Y",
1897
- "u",
1898
- "q",
1899
- "Q",
1900
- "M",
1901
- "L",
1902
- "w",
1903
- "d",
1904
- "D",
1905
- "e",
1906
- "c",
1907
- "t",
1908
- "T"
1909
- ];
1910
- }
1911
- const Ft = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], Lt = [
1912
- 31,
1913
- 29,
1914
- 31,
1915
- 30,
1916
- 31,
1917
- 30,
1918
- 31,
1919
- 31,
1920
- 30,
1921
- 31,
1922
- 30,
1923
- 31
1924
- ];
1925
- class Ct extends c {
1926
- priority = 90;
1927
- subPriority = 1;
1928
- parse(e, t, n) {
1929
- switch (t) {
1930
- case "d":
1931
- return l(w.date, e);
1932
- case "do":
1933
- return n.ordinalNumber(e, { unit: "date" });
1934
- default:
1935
- return h(t.length, e);
1936
- }
1937
- }
1938
- validate(e, t) {
1939
- const n = e.getFullYear(), a = ye(n), s = e.getMonth();
1940
- return a ? t >= 1 && t <= Lt[s] : t >= 1 && t <= Ft[s];
1941
- }
1942
- set(e, t, n) {
1943
- return e.setDate(n), e.setHours(0, 0, 0, 0), e;
1944
- }
1945
- incompatibleTokens = [
1946
- "Y",
1947
- "R",
1948
- "q",
1949
- "Q",
1950
- "w",
1951
- "I",
1952
- "D",
1953
- "i",
1954
- "e",
1955
- "c",
1956
- "t",
1957
- "T"
1958
- ];
1959
- }
1960
- class Qt extends c {
1961
- priority = 90;
1962
- subpriority = 1;
1963
- parse(e, t, n) {
1964
- switch (t) {
1965
- case "D":
1966
- case "DD":
1967
- return l(w.dayOfYear, e);
1968
- case "Do":
1969
- return n.ordinalNumber(e, { unit: "date" });
1970
- default:
1971
- return h(t.length, e);
1972
- }
1973
- }
1974
- validate(e, t) {
1975
- const n = e.getFullYear();
1976
- return ye(n) ? t >= 1 && t <= 366 : t >= 1 && t <= 365;
1977
- }
1978
- set(e, t, n) {
1979
- return e.setMonth(0, n), e.setHours(0, 0, 0, 0), e;
1980
- }
1981
- incompatibleTokens = [
1982
- "Y",
1983
- "R",
1984
- "q",
1985
- "Q",
1986
- "M",
1987
- "L",
1988
- "w",
1989
- "I",
1990
- "d",
1991
- "E",
1992
- "i",
1993
- "e",
1994
- "c",
1995
- "t",
1996
- "T"
1997
- ];
1998
- }
1999
- function j(r, e, t) {
2000
- const n = H(), a = t?.weekStartsOn ?? t?.locale?.options?.weekStartsOn ?? n.weekStartsOn ?? n.locale?.options?.weekStartsOn ?? 0, s = p(r, t?.in), o = s.getDay(), b = (e % 7 + 7) % 7, M = 7 - a, m = e < 0 || e > 6 ? e - (o + M) % 7 : (b + M) % 7 - (o + M) % 7;
2001
- return se(s, m, t);
2002
- }
2003
- class Rt extends c {
2004
- priority = 90;
2005
- parse(e, t, n) {
2006
- switch (t) {
2007
- // Tue
2008
- case "E":
2009
- case "EE":
2010
- case "EEE":
2011
- return n.day(e, {
2012
- width: "abbreviated",
2013
- context: "formatting"
2014
- }) || n.day(e, { width: "short", context: "formatting" }) || n.day(e, { width: "narrow", context: "formatting" });
2015
- // T
2016
- case "EEEEE":
2017
- return n.day(e, {
2018
- width: "narrow",
2019
- context: "formatting"
2020
- });
2021
- // Tu
2022
- case "EEEEEE":
2023
- return n.day(e, { width: "short", context: "formatting" }) || n.day(e, { width: "narrow", context: "formatting" });
2024
- default:
2025
- return n.day(e, { width: "wide", context: "formatting" }) || n.day(e, {
2026
- width: "abbreviated",
2027
- context: "formatting"
2028
- }) || n.day(e, { width: "short", context: "formatting" }) || n.day(e, { width: "narrow", context: "formatting" });
2029
- }
2030
- }
2031
- validate(e, t) {
2032
- return t >= 0 && t <= 6;
2033
- }
2034
- set(e, t, n, a) {
2035
- return e = j(e, n, a), e.setHours(0, 0, 0, 0), e;
2036
- }
2037
- incompatibleTokens = ["D", "i", "e", "c", "t", "T"];
2038
- }
2039
- class Xt extends c {
2040
- priority = 90;
2041
- parse(e, t, n, a) {
2042
- const s = (o) => {
2043
- const i = Math.floor((o - 1) / 7) * 7;
2044
- return (o + a.weekStartsOn + 6) % 7 + i;
2045
- };
2046
- switch (t) {
2047
- // 3
2048
- case "e":
2049
- case "ee":
2050
- return y(h(t.length, e), s);
2051
- // 3rd
2052
- case "eo":
2053
- return y(
2054
- n.ordinalNumber(e, {
2055
- unit: "day"
2056
- }),
2057
- s
2058
- );
2059
- // Tue
2060
- case "eee":
2061
- return n.day(e, {
2062
- width: "abbreviated",
2063
- context: "formatting"
2064
- }) || n.day(e, { width: "short", context: "formatting" }) || n.day(e, { width: "narrow", context: "formatting" });
2065
- // T
2066
- case "eeeee":
2067
- return n.day(e, {
2068
- width: "narrow",
2069
- context: "formatting"
2070
- });
2071
- // Tu
2072
- case "eeeeee":
2073
- return n.day(e, { width: "short", context: "formatting" }) || n.day(e, { width: "narrow", context: "formatting" });
2074
- default:
2075
- return n.day(e, { width: "wide", context: "formatting" }) || n.day(e, {
2076
- width: "abbreviated",
2077
- context: "formatting"
2078
- }) || n.day(e, { width: "short", context: "formatting" }) || n.day(e, { width: "narrow", context: "formatting" });
2079
- }
2080
- }
2081
- validate(e, t) {
2082
- return t >= 0 && t <= 6;
2083
- }
2084
- set(e, t, n, a) {
2085
- return e = j(e, n, a), e.setHours(0, 0, 0, 0), e;
2086
- }
2087
- incompatibleTokens = [
2088
- "y",
2089
- "R",
2090
- "u",
2091
- "q",
2092
- "Q",
2093
- "M",
2094
- "L",
2095
- "I",
2096
- "d",
2097
- "D",
2098
- "E",
2099
- "i",
2100
- "c",
2101
- "t",
2102
- "T"
2103
- ];
2104
- }
2105
- class At extends c {
2106
- priority = 90;
2107
- parse(e, t, n, a) {
2108
- const s = (o) => {
2109
- const i = Math.floor((o - 1) / 7) * 7;
2110
- return (o + a.weekStartsOn + 6) % 7 + i;
2111
- };
2112
- switch (t) {
2113
- // 3
2114
- case "c":
2115
- case "cc":
2116
- return y(h(t.length, e), s);
2117
- // 3rd
2118
- case "co":
2119
- return y(
2120
- n.ordinalNumber(e, {
2121
- unit: "day"
2122
- }),
2123
- s
2124
- );
2125
- // Tue
2126
- case "ccc":
2127
- return n.day(e, {
2128
- width: "abbreviated",
2129
- context: "standalone"
2130
- }) || n.day(e, { width: "short", context: "standalone" }) || n.day(e, { width: "narrow", context: "standalone" });
2131
- // T
2132
- case "ccccc":
2133
- return n.day(e, {
2134
- width: "narrow",
2135
- context: "standalone"
2136
- });
2137
- // Tu
2138
- case "cccccc":
2139
- return n.day(e, { width: "short", context: "standalone" }) || n.day(e, { width: "narrow", context: "standalone" });
2140
- default:
2141
- return n.day(e, { width: "wide", context: "standalone" }) || n.day(e, {
2142
- width: "abbreviated",
2143
- context: "standalone"
2144
- }) || n.day(e, { width: "short", context: "standalone" }) || n.day(e, { width: "narrow", context: "standalone" });
2145
- }
2146
- }
2147
- validate(e, t) {
2148
- return t >= 0 && t <= 6;
2149
- }
2150
- set(e, t, n, a) {
2151
- return e = j(e, n, a), e.setHours(0, 0, 0, 0), e;
2152
- }
2153
- incompatibleTokens = [
2154
- "y",
2155
- "R",
2156
- "u",
2157
- "q",
2158
- "Q",
2159
- "M",
2160
- "L",
2161
- "I",
2162
- "d",
2163
- "D",
2164
- "E",
2165
- "i",
2166
- "e",
2167
- "t",
2168
- "T"
2169
- ];
2170
- }
2171
- function Bt(r, e, t) {
2172
- const n = p(r, t?.in), a = bt(n, t), s = e - a;
2173
- return se(n, s, t);
2174
- }
2175
- class Gt extends c {
2176
- priority = 90;
2177
- parse(e, t, n) {
2178
- const a = (s) => s === 0 ? 7 : s;
2179
- switch (t) {
2180
- // 2
2181
- case "i":
2182
- case "ii":
2183
- return h(t.length, e);
2184
- // 2nd
2185
- case "io":
2186
- return n.ordinalNumber(e, { unit: "day" });
2187
- // Tue
2188
- case "iii":
2189
- return y(
2190
- n.day(e, {
2191
- width: "abbreviated",
2192
- context: "formatting"
2193
- }) || n.day(e, {
2194
- width: "short",
2195
- context: "formatting"
2196
- }) || n.day(e, {
2197
- width: "narrow",
2198
- context: "formatting"
2199
- }),
2200
- a
2201
- );
2202
- // T
2203
- case "iiiii":
2204
- return y(
2205
- n.day(e, {
2206
- width: "narrow",
2207
- context: "formatting"
2208
- }),
2209
- a
2210
- );
2211
- // Tu
2212
- case "iiiiii":
2213
- return y(
2214
- n.day(e, {
2215
- width: "short",
2216
- context: "formatting"
2217
- }) || n.day(e, {
2218
- width: "narrow",
2219
- context: "formatting"
2220
- }),
2221
- a
2222
- );
2223
- default:
2224
- return y(
2225
- n.day(e, {
2226
- width: "wide",
2227
- context: "formatting"
2228
- }) || n.day(e, {
2229
- width: "abbreviated",
2230
- context: "formatting"
2231
- }) || n.day(e, {
2232
- width: "short",
2233
- context: "formatting"
2234
- }) || n.day(e, {
2235
- width: "narrow",
2236
- context: "formatting"
2237
- }),
2238
- a
2239
- );
2240
- }
2241
- }
2242
- validate(e, t) {
2243
- return t >= 1 && t <= 7;
2244
- }
2245
- set(e, t, n) {
2246
- return e = Bt(e, n), e.setHours(0, 0, 0, 0), e;
2247
- }
2248
- incompatibleTokens = [
2249
- "y",
2250
- "Y",
2251
- "u",
2252
- "q",
2253
- "Q",
2254
- "M",
2255
- "L",
2256
- "w",
2257
- "d",
2258
- "D",
2259
- "E",
2260
- "e",
2261
- "c",
2262
- "t",
2263
- "T"
2264
- ];
2265
- }
2266
- class $t extends c {
2267
- priority = 80;
2268
- parse(e, t, n) {
2269
- switch (t) {
2270
- case "a":
2271
- case "aa":
2272
- case "aaa":
2273
- return n.dayPeriod(e, {
2274
- width: "abbreviated",
2275
- context: "formatting"
2276
- }) || n.dayPeriod(e, {
2277
- width: "narrow",
2278
- context: "formatting"
2279
- });
2280
- case "aaaaa":
2281
- return n.dayPeriod(e, {
2282
- width: "narrow",
2283
- context: "formatting"
2284
- });
2285
- default:
2286
- return n.dayPeriod(e, {
2287
- width: "wide",
2288
- context: "formatting"
2289
- }) || n.dayPeriod(e, {
2290
- width: "abbreviated",
2291
- context: "formatting"
2292
- }) || n.dayPeriod(e, {
2293
- width: "narrow",
2294
- context: "formatting"
2295
- });
2296
- }
2297
- }
2298
- set(e, t, n) {
2299
- return e.setHours($(n), 0, 0, 0), e;
2300
- }
2301
- incompatibleTokens = ["b", "B", "H", "k", "t", "T"];
2302
- }
2303
- class jt extends c {
2304
- priority = 80;
2305
- parse(e, t, n) {
2306
- switch (t) {
2307
- case "b":
2308
- case "bb":
2309
- case "bbb":
2310
- return n.dayPeriod(e, {
2311
- width: "abbreviated",
2312
- context: "formatting"
2313
- }) || n.dayPeriod(e, {
2314
- width: "narrow",
2315
- context: "formatting"
2316
- });
2317
- case "bbbbb":
2318
- return n.dayPeriod(e, {
2319
- width: "narrow",
2320
- context: "formatting"
2321
- });
2322
- default:
2323
- return n.dayPeriod(e, {
2324
- width: "wide",
2325
- context: "formatting"
2326
- }) || n.dayPeriod(e, {
2327
- width: "abbreviated",
2328
- context: "formatting"
2329
- }) || n.dayPeriod(e, {
2330
- width: "narrow",
2331
- context: "formatting"
2332
- });
2333
- }
2334
- }
2335
- set(e, t, n) {
2336
- return e.setHours($(n), 0, 0, 0), e;
2337
- }
2338
- incompatibleTokens = ["a", "B", "H", "k", "t", "T"];
2339
- }
2340
- class Vt extends c {
2341
- priority = 80;
2342
- parse(e, t, n) {
2343
- switch (t) {
2344
- case "B":
2345
- case "BB":
2346
- case "BBB":
2347
- return n.dayPeriod(e, {
2348
- width: "abbreviated",
2349
- context: "formatting"
2350
- }) || n.dayPeriod(e, {
2351
- width: "narrow",
2352
- context: "formatting"
2353
- });
2354
- case "BBBBB":
2355
- return n.dayPeriod(e, {
2356
- width: "narrow",
2357
- context: "formatting"
2358
- });
2359
- default:
2360
- return n.dayPeriod(e, {
2361
- width: "wide",
2362
- context: "formatting"
2363
- }) || n.dayPeriod(e, {
2364
- width: "abbreviated",
2365
- context: "formatting"
2366
- }) || n.dayPeriod(e, {
2367
- width: "narrow",
2368
- context: "formatting"
2369
- });
2370
- }
2371
- }
2372
- set(e, t, n) {
2373
- return e.setHours($(n), 0, 0, 0), e;
2374
- }
2375
- incompatibleTokens = ["a", "b", "t", "T"];
2376
- }
2377
- class zt extends c {
2378
- priority = 70;
2379
- parse(e, t, n) {
2380
- switch (t) {
2381
- case "h":
2382
- return l(w.hour12h, e);
2383
- case "ho":
2384
- return n.ordinalNumber(e, { unit: "hour" });
2385
- default:
2386
- return h(t.length, e);
2387
- }
2388
- }
2389
- validate(e, t) {
2390
- return t >= 1 && t <= 12;
2391
- }
2392
- set(e, t, n) {
2393
- const a = e.getHours() >= 12;
2394
- return a && n < 12 ? e.setHours(n + 12, 0, 0, 0) : !a && n === 12 ? e.setHours(0, 0, 0, 0) : e.setHours(n, 0, 0, 0), e;
2395
- }
2396
- incompatibleTokens = ["H", "K", "k", "t", "T"];
2397
- }
2398
- class Jt extends c {
2399
- priority = 70;
2400
- parse(e, t, n) {
2401
- switch (t) {
2402
- case "H":
2403
- return l(w.hour23h, e);
2404
- case "Ho":
2405
- return n.ordinalNumber(e, { unit: "hour" });
2406
- default:
2407
- return h(t.length, e);
2408
- }
2409
- }
2410
- validate(e, t) {
2411
- return t >= 0 && t <= 23;
2412
- }
2413
- set(e, t, n) {
2414
- return e.setHours(n, 0, 0, 0), e;
2415
- }
2416
- incompatibleTokens = ["a", "b", "h", "K", "k", "t", "T"];
2417
- }
2418
- class Zt extends c {
2419
- priority = 70;
2420
- parse(e, t, n) {
2421
- switch (t) {
2422
- case "K":
2423
- return l(w.hour11h, e);
2424
- case "Ko":
2425
- return n.ordinalNumber(e, { unit: "hour" });
2426
- default:
2427
- return h(t.length, e);
2428
- }
2429
- }
2430
- validate(e, t) {
2431
- return t >= 0 && t <= 11;
2432
- }
2433
- set(e, t, n) {
2434
- return e.getHours() >= 12 && n < 12 ? e.setHours(n + 12, 0, 0, 0) : e.setHours(n, 0, 0, 0), e;
2435
- }
2436
- incompatibleTokens = ["h", "H", "k", "t", "T"];
2437
- }
2438
- class Kt extends c {
2439
- priority = 70;
2440
- parse(e, t, n) {
2441
- switch (t) {
2442
- case "k":
2443
- return l(w.hour24h, e);
2444
- case "ko":
2445
- return n.ordinalNumber(e, { unit: "hour" });
2446
- default:
2447
- return h(t.length, e);
2448
- }
2449
- }
2450
- validate(e, t) {
2451
- return t >= 1 && t <= 24;
2452
- }
2453
- set(e, t, n) {
2454
- const a = n <= 24 ? n % 24 : n;
2455
- return e.setHours(a, 0, 0, 0), e;
2456
- }
2457
- incompatibleTokens = ["a", "b", "h", "H", "K", "t", "T"];
2458
- }
2459
- class Ut extends c {
2460
- priority = 60;
2461
- parse(e, t, n) {
2462
- switch (t) {
2463
- case "m":
2464
- return l(w.minute, e);
2465
- case "mo":
2466
- return n.ordinalNumber(e, { unit: "minute" });
2467
- default:
2468
- return h(t.length, e);
2469
- }
2470
- }
2471
- validate(e, t) {
2472
- return t >= 0 && t <= 59;
2473
- }
2474
- set(e, t, n) {
2475
- return e.setMinutes(n, 0, 0), e;
2476
- }
2477
- incompatibleTokens = ["t", "T"];
2478
- }
2479
- class St extends c {
2480
- priority = 50;
2481
- parse(e, t, n) {
2482
- switch (t) {
2483
- case "s":
2484
- return l(w.second, e);
2485
- case "so":
2486
- return n.ordinalNumber(e, { unit: "second" });
2487
- default:
2488
- return h(t.length, e);
2489
- }
2490
- }
2491
- validate(e, t) {
2492
- return t >= 0 && t <= 59;
2493
- }
2494
- set(e, t, n) {
2495
- return e.setSeconds(n, 0), e;
2496
- }
2497
- incompatibleTokens = ["t", "T"];
2498
- }
2499
- class en extends c {
2500
- priority = 30;
2501
- parse(e, t) {
2502
- const n = (a) => Math.trunc(a * Math.pow(10, -t.length + 3));
2503
- return y(h(t.length, e), n);
2504
- }
2505
- set(e, t, n) {
2506
- return e.setMilliseconds(n), e;
2507
- }
2508
- incompatibleTokens = ["t", "T"];
2509
- }
2510
- class tn extends c {
2511
- priority = 10;
2512
- parse(e, t) {
2513
- switch (t) {
2514
- case "X":
2515
- return D(
2516
- T.basicOptionalMinutes,
2517
- e
2518
- );
2519
- case "XX":
2520
- return D(T.basic, e);
2521
- case "XXXX":
2522
- return D(
2523
- T.basicOptionalSeconds,
2524
- e
2525
- );
2526
- case "XXXXX":
2527
- return D(
2528
- T.extendedOptionalSeconds,
2529
- e
2530
- );
2531
- default:
2532
- return D(T.extended, e);
2533
- }
2534
- }
2535
- set(e, t, n) {
2536
- return t.timestampIsSet ? e : x(
2537
- e,
2538
- e.getTime() - F(e) - n
2539
- );
2540
- }
2541
- incompatibleTokens = ["t", "T", "x"];
2542
- }
2543
- class nn extends c {
2544
- priority = 10;
2545
- parse(e, t) {
2546
- switch (t) {
2547
- case "x":
2548
- return D(
2549
- T.basicOptionalMinutes,
2550
- e
2551
- );
2552
- case "xx":
2553
- return D(T.basic, e);
2554
- case "xxxx":
2555
- return D(
2556
- T.basicOptionalSeconds,
2557
- e
2558
- );
2559
- case "xxxxx":
2560
- return D(
2561
- T.extendedOptionalSeconds,
2562
- e
2563
- );
2564
- default:
2565
- return D(T.extended, e);
2566
- }
2567
- }
2568
- set(e, t, n) {
2569
- return t.timestampIsSet ? e : x(
2570
- e,
2571
- e.getTime() - F(e) - n
2572
- );
2573
- }
2574
- incompatibleTokens = ["t", "T", "X"];
2575
- }
2576
- class rn extends c {
2577
- priority = 40;
2578
- parse(e) {
2579
- return me(e);
2580
- }
2581
- set(e, t, n) {
2582
- return [x(e, n * 1e3), { timestampIsSet: !0 }];
2583
- }
2584
- incompatibleTokens = "*";
2585
- }
2586
- class an extends c {
2587
- priority = 20;
2588
- parse(e) {
2589
- return me(e);
2590
- }
2591
- set(e, t, n) {
2592
- return [x(e, n), { timestampIsSet: !0 }];
2593
- }
2594
- incompatibleTokens = "*";
2595
- }
2596
- const sn = {
2597
- G: new Tt(),
2598
- y: new Dt(),
2599
- Y: new kt(),
2600
- R: new Ot(),
2601
- u: new vt(),
2602
- Q: new Yt(),
2603
- q: new Et(),
2604
- M: new Wt(),
2605
- L: new _t(),
2606
- w: new qt(),
2607
- I: new It(),
2608
- d: new Ct(),
2609
- D: new Qt(),
2610
- E: new Rt(),
2611
- e: new Xt(),
2612
- c: new At(),
2613
- i: new Gt(),
2614
- a: new $t(),
2615
- b: new jt(),
2616
- B: new Vt(),
2617
- h: new zt(),
2618
- H: new Jt(),
2619
- K: new Zt(),
2620
- k: new Kt(),
2621
- m: new Ut(),
2622
- s: new St(),
2623
- S: new en(),
2624
- X: new tn(),
2625
- x: new nn(),
2626
- t: new rn(),
2627
- T: new an()
2628
- }, on = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, un = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, cn = /^'([^]*?)'?$/, dn = /''/g, ln = /\S/, fn = /[a-zA-Z]/;
2629
- function V(r, e, t, n) {
2630
- const a = () => x(t, NaN), s = yt(), o = s.locale ?? ie, i = s.firstWeekContainsDate ?? s.locale?.options?.firstWeekContainsDate ?? 1, b = s.weekStartsOn ?? s.locale?.options?.weekStartsOn ?? 0;
2631
- if (!e)
2632
- return r ? a() : p(t, n?.in);
2633
- const M = {
2634
- firstWeekContainsDate: i,
2635
- weekStartsOn: b,
2636
- locale: o
2637
- }, m = [new Pt(n?.in, t)], g = e.match(un).map((u) => {
2638
- const f = u[0];
2639
- if (f in X) {
2640
- const P = X[f];
2641
- return P(u, o.formatLong);
2642
- }
2643
- return u;
2644
- }).join("").match(on), v = [];
2645
- for (let u of g) {
2646
- fe(u) && A(u, e, r), le(u) && A(u, e, r);
2647
- const f = u[0], P = sn[f];
2648
- if (P) {
2649
- const { incompatibleTokens: J } = P;
2650
- if (Array.isArray(J)) {
2651
- const Z = v.find(
2652
- (K) => J.includes(K.token) || K.token === f
2653
- );
2654
- if (Z)
2655
- throw new RangeError(
2656
- `The format string mustn't contain \`${Z.fullToken}\` and \`${u}\` at the same time`
2657
- );
2658
- } else if (P.incompatibleTokens === "*" && v.length > 0)
2659
- throw new RangeError(
2660
- `The format string mustn't contain \`${u}\` and any other token at the same time`
2661
- );
2662
- v.push({ token: f, fullToken: u });
2663
- const C = P.run(
2664
- r,
2665
- u,
2666
- o.match,
2667
- M
2668
- );
2669
- if (!C)
2670
- return a();
2671
- m.push(C.setter), r = C.rest;
2672
- } else {
2673
- if (f.match(fn))
2674
- throw new RangeError(
2675
- "Format string contains an unescaped latin alphabet character `" + f + "`"
2676
- );
2677
- if (u === "''" ? u = "'" : f === "'" && (u = hn(u)), r.indexOf(u) === 0)
2678
- r = r.slice(u.length);
2679
- else
2680
- return a();
2681
- }
2682
- }
2683
- if (r.length > 0 && ln.test(r))
2684
- return a();
2685
- const be = m.map((u) => u.priority).sort((u, f) => f - u).filter((u, f, P) => P.indexOf(u) === f).map(
2686
- (u) => m.filter((f) => f.priority === u).sort((f, P) => P.subPriority - f.subPriority)
2687
- ).map((u) => u[0]);
2688
- let E = p(t, n?.in);
2689
- if (isNaN(+E)) return a();
2690
- const z = {};
2691
- for (const u of be) {
2692
- if (!u.validate(E, M))
2693
- return a();
2694
- const f = u.set(E, z, M);
2695
- Array.isArray(f) ? (E = f[0], Object.assign(z, f[1])) : E = f;
2696
- }
2697
- return E;
2698
- }
2699
- function hn(r) {
2700
- return r.match(cn)[1].replace(dn, "'");
2701
- }
2702
- function mn(r) {
2703
- return Math.trunc(r * 6e4);
2704
- }
2705
- function wn(r) {
2706
- return r * 1e3;
2707
- }
2708
- function gn(r) {
2709
- if (r)
2710
- return V(r, "HH:mm:ss.SSS", /* @__PURE__ */ new Date());
2711
- }
2712
- function pn(r) {
2713
- if (r)
2714
- return G(r, "HH:mm:ss.SSS");
2715
- }
2716
- function xn(r) {
2717
- if (r && typeof r == "string")
2718
- return V(r, "yyyy-MM-dd", /* @__PURE__ */ new Date());
2719
- }
2720
- function Mn(r) {
2721
- if (r)
2722
- return G(r, "yyyy-MM-dd");
2723
- }
2724
- function Pn(r) {
2725
- if (r)
2726
- return V(r, "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", /* @__PURE__ */ new Date());
2727
- }
2728
- function Tn(r) {
2729
- if (r)
2730
- return G(r, "yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
2731
- }
2732
- const I = (r) => Number.parseInt(r ?? "0");
2733
- function yn(r) {
2734
- const e = r.match(/^(-)?(\d+)?\.?(\d{2}):(\d{2}):(\d{2})\.?(\d{3})?$/);
2735
- return {
2736
- sign: e?.[1],
2737
- values: {
2738
- days: I(e?.[2]),
2739
- hours: I(e?.[3]),
2740
- minutes: I(e?.[4]),
2741
- seconds: I(e?.[5]),
2742
- milliseconds: I(e?.[6])
2743
- }
2744
- };
2745
- }
2746
- function Dn(r) {
2747
- if (!r)
1
+ export * from "@leancodepl/api-date";
2
+ import { parse as d, format as m, hoursToMilliseconds as f, minutesToMilliseconds as p, secondsToMilliseconds as l } from "date-fns";
3
+ import { parseApiTimeSpan as y } from "@leancodepl/api-date-utils";
4
+ function A(n) {
5
+ if (n)
6
+ return d(n, "HH:mm:ss.SSS", /* @__PURE__ */ new Date());
7
+ }
8
+ function h(n) {
9
+ if (n)
10
+ return m(n, "HH:mm:ss.SSS");
11
+ }
12
+ function v(n) {
13
+ if (n && typeof n == "string")
14
+ return d(n, "yyyy-MM-dd", /* @__PURE__ */ new Date());
15
+ }
16
+ function D(n) {
17
+ if (n)
18
+ return m(n, "yyyy-MM-dd");
19
+ }
20
+ function g(n) {
21
+ if (n)
22
+ return d(n, "yyyy-MM-dd'T'HH:mm:ss.SSSXXX", /* @__PURE__ */ new Date());
23
+ }
24
+ function H(n) {
25
+ if (n)
26
+ return m(n, "yyyy-MM-dd'T'HH:mm:ss.SSSXXX");
27
+ }
28
+ function X(n) {
29
+ if (!n)
2748
30
  return;
2749
- const e = yn(r), t = e.values, n = ae(t.days * 24), a = ae(t.hours), s = mn(t.minutes), o = wn(t.seconds), i = n + a + s + o + t.milliseconds;
2750
- return (e.sign === "-" ? -1 : 1) * i;
31
+ const o = y(n), s = o.values, t = f(s.days * 24), i = f(s.hours), r = p(s.minutes), e = l(s.seconds), u = t + i + r + e + s.milliseconds;
32
+ return (o.sign === "-" ? -1 : 1) * u;
2751
33
  }
2752
- function R(r) {
2753
- return (r?.toFixed(0) ?? "0").padStart(2, "0");
34
+ function a(n) {
35
+ return (n?.toFixed(0) ?? "0").padStart(2, "0");
2754
36
  }
2755
- function bn(r) {
2756
- const e = r % 1e3, t = Math.floor(r / 1e3 % 60), n = Math.floor(r / (1e3 * 60) % 60), a = Math.floor(r / (1e3 * 60 * 60) % 24), s = Math.floor(r / (1e3 * 60 * 60 * 24));
2757
- return { milliseconds: e, seconds: t, minutes: n, hours: a, days: s };
37
+ function M(n) {
38
+ const o = n % 1e3, s = Math.floor(n / 1e3 % 60), t = Math.floor(n / (1e3 * 60) % 60), i = Math.floor(n / (1e3 * 60 * 60) % 24), r = Math.floor(n / (1e3 * 60 * 60 * 24));
39
+ return { milliseconds: o, seconds: s, minutes: t, hours: i, days: r };
2758
40
  }
2759
- function kn(r) {
2760
- let e = "";
2761
- if (!r)
41
+ function $(n) {
42
+ let o = "";
43
+ if (!n)
2762
44
  return;
2763
- const t = r < 0, n = Math.abs(r), { milliseconds: a, seconds: s, minutes: o, hours: i, days: b } = bn(n);
2764
- return t && (e += "-"), b > 0 && (e += `${b}.`), e += `${R(i)}:${R(o)}:${R(s)}`, a > 0 && (e += `.${a}`), e;
45
+ const s = n < 0, t = Math.abs(n), { milliseconds: i, seconds: r, minutes: e, hours: u, days: c } = M(t);
46
+ return s && (o += "-"), c > 0 && (o += `${c}.`), o += `${a(u)}:${a(e)}:${a(r)}`, i > 0 && (o += `.${i}`), o;
2765
47
  }
2766
48
  export {
2767
- xn as fromApiDate,
2768
- Pn as fromApiDateTimeOffset,
2769
- gn as fromApiTime,
2770
- Dn as fromApiTimeSpan,
2771
- Mn as toApiDate,
2772
- Tn as toApiDateTimeOffset,
2773
- pn as toApiTime,
2774
- kn as toApiTimeSpan
49
+ v as fromApiDate,
50
+ g as fromApiDateTimeOffset,
51
+ A as fromApiTime,
52
+ X as fromApiTimeSpan,
53
+ D as toApiDate,
54
+ H as toApiDateTimeOffset,
55
+ h as toApiTime,
56
+ $ as toApiTimeSpan
2775
57
  };