@caipira/tamandua 0.0.57 → 0.0.58
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/date.js +74 -66
- package/dist/types/services/date.d.ts +3 -3
- package/package.json +1 -1
package/dist/date.js
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as
|
|
3
|
-
import { b as
|
|
1
|
+
import { c as O, t as D, m as X, n as N, s as H, e as P, g as C, a as U, b as T, d as j } from "./format-BZx-8XXc.js";
|
|
2
|
+
import { f as Se } from "./format-BZx-8XXc.js";
|
|
3
|
+
import { b as $e, g as Ae, c as Le, a as ze, s as Ze } from "./subMonths-XOke808J.js";
|
|
4
4
|
function we(e, t, n) {
|
|
5
|
+
return O(n?.in || e, +D(e) + t);
|
|
6
|
+
}
|
|
7
|
+
function xe(e, t, n) {
|
|
5
8
|
const r = D(e, n?.in);
|
|
6
9
|
return r.setTime(r.getTime() + t * X), r;
|
|
7
10
|
}
|
|
8
|
-
function
|
|
11
|
+
function h(e, t) {
|
|
9
12
|
const n = +D(e) - +D(t);
|
|
10
13
|
return n < 0 ? -1 : n > 0 ? 1 : n;
|
|
11
14
|
}
|
|
12
|
-
function
|
|
13
|
-
return
|
|
15
|
+
function E(e) {
|
|
16
|
+
return O(e, Date.now());
|
|
14
17
|
}
|
|
15
18
|
function R(e, t, n) {
|
|
16
19
|
const [r, s] = N(
|
|
@@ -18,7 +21,7 @@ function R(e, t, n) {
|
|
|
18
21
|
e,
|
|
19
22
|
t
|
|
20
23
|
);
|
|
21
|
-
return +
|
|
24
|
+
return +H(r) == +H(s);
|
|
22
25
|
}
|
|
23
26
|
function G(e, t, n) {
|
|
24
27
|
const [r, s] = N(
|
|
@@ -55,14 +58,14 @@ function Q(e, t, n) {
|
|
|
55
58
|
e,
|
|
56
59
|
e,
|
|
57
60
|
t
|
|
58
|
-
), i =
|
|
61
|
+
), i = h(s, a), o = Math.abs(
|
|
59
62
|
G(s, a)
|
|
60
63
|
);
|
|
61
64
|
if (o < 1)
|
|
62
65
|
return 0;
|
|
63
66
|
s.getMonth() === 1 && s.getDate() > 27 && s.setDate(30), s.setMonth(s.getMonth() - i * o);
|
|
64
|
-
let u =
|
|
65
|
-
K(r) && o === 1 &&
|
|
67
|
+
let u = h(s, a) === -i;
|
|
68
|
+
K(r) && o === 1 && h(r, a) === 1 && (u = !1);
|
|
66
69
|
const l = i * (o - +u);
|
|
67
70
|
return l === 0 ? 0 : l;
|
|
68
71
|
}
|
|
@@ -71,7 +74,7 @@ function ee(e, t, n) {
|
|
|
71
74
|
return q(n?.roundingMethod)(r);
|
|
72
75
|
}
|
|
73
76
|
function te(e, t, n) {
|
|
74
|
-
const r = j(), s = n?.locale ?? r.locale ?? P, a = 2520, i =
|
|
77
|
+
const r = j(), s = n?.locale ?? r.locale ?? P, a = 2520, i = h(e, t);
|
|
75
78
|
if (isNaN(i))
|
|
76
79
|
throw new RangeError("Invalid time value");
|
|
77
80
|
const o = Object.assign({}, n, {
|
|
@@ -80,7 +83,7 @@ function te(e, t, n) {
|
|
|
80
83
|
}), [u, l] = N(
|
|
81
84
|
n?.in,
|
|
82
85
|
...i > 0 ? [t, e] : [e, t]
|
|
83
|
-
), m = ee(l, u), W = (
|
|
86
|
+
), m = ee(l, u), W = (C(l) - C(u)) / 1e3, f = Math.round((m - W) / 60);
|
|
84
87
|
let M;
|
|
85
88
|
if (f < 2)
|
|
86
89
|
return n?.includeSeconds ? m < 5 ? s.formatDistance("lessThanXSeconds", 5, o) : m < 10 ? s.formatDistance("lessThanXSeconds", 10, o) : m < 20 ? s.formatDistance("lessThanXSeconds", 20, o) : m < 40 ? s.formatDistance("halfAMinute", 0, o) : m < 60 ? s.formatDistance("lessThanXMinutes", 1, o) : s.formatDistance("xMinutes", 1, o) : f === 0 ? s.formatDistance("lessThanXMinutes", 1, o) : s.formatDistance("xMinutes", f, o);
|
|
@@ -88,36 +91,36 @@ function te(e, t, n) {
|
|
|
88
91
|
return s.formatDistance("xMinutes", f, o);
|
|
89
92
|
if (f < 90)
|
|
90
93
|
return s.formatDistance("aboutXHours", 1, o);
|
|
91
|
-
if (f <
|
|
94
|
+
if (f < U) {
|
|
92
95
|
const d = Math.round(f / 60);
|
|
93
96
|
return s.formatDistance("aboutXHours", d, o);
|
|
94
97
|
} else {
|
|
95
98
|
if (f < a)
|
|
96
99
|
return s.formatDistance("xDays", 1, o);
|
|
97
|
-
if (f <
|
|
98
|
-
const d = Math.round(f /
|
|
100
|
+
if (f < T) {
|
|
101
|
+
const d = Math.round(f / U);
|
|
99
102
|
return s.formatDistance("xDays", d, o);
|
|
100
|
-
} else if (f <
|
|
101
|
-
return M = Math.round(f /
|
|
103
|
+
} else if (f < T * 2)
|
|
104
|
+
return M = Math.round(f / T), s.formatDistance("aboutXMonths", M, o);
|
|
102
105
|
}
|
|
103
106
|
if (M = Q(l, u), M < 12) {
|
|
104
|
-
const d = Math.round(f /
|
|
107
|
+
const d = Math.round(f / T);
|
|
105
108
|
return s.formatDistance("xMonths", d, o);
|
|
106
109
|
} else {
|
|
107
110
|
const d = M % 12, Y = Math.trunc(M / 12);
|
|
108
111
|
return d < 3 ? s.formatDistance("aboutXYears", Y, o) : d < 9 ? s.formatDistance("overXYears", Y, o) : s.formatDistance("almostXYears", Y + 1, o);
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
|
-
function
|
|
112
|
-
return te(e,
|
|
114
|
+
function Oe(e, t) {
|
|
115
|
+
return te(e, E(e), t);
|
|
113
116
|
}
|
|
114
|
-
function
|
|
117
|
+
function ye(e) {
|
|
115
118
|
return Math.trunc(+D(e) / 1e3);
|
|
116
119
|
}
|
|
117
|
-
function
|
|
120
|
+
function He(e, t) {
|
|
118
121
|
return R(
|
|
119
|
-
|
|
120
|
-
|
|
122
|
+
O(t?.in || e, e),
|
|
123
|
+
E(t?.in || e)
|
|
121
124
|
);
|
|
122
125
|
}
|
|
123
126
|
function ne(e, t) {
|
|
@@ -157,7 +160,7 @@ function ae(e, t) {
|
|
|
157
160
|
parseInt(r[6], 10)
|
|
158
161
|
];
|
|
159
162
|
}
|
|
160
|
-
const g = {},
|
|
163
|
+
const g = {}, _ = new Intl.DateTimeFormat("en-US", {
|
|
161
164
|
hourCycle: "h23",
|
|
162
165
|
timeZone: "America/New_York",
|
|
163
166
|
year: "numeric",
|
|
@@ -166,7 +169,7 @@ const g = {}, C = new Intl.DateTimeFormat("en-US", {
|
|
|
166
169
|
hour: "2-digit",
|
|
167
170
|
minute: "2-digit",
|
|
168
171
|
second: "2-digit"
|
|
169
|
-
}).format(/* @__PURE__ */ new Date("2014-06-25T04:00:00.123Z")), oe =
|
|
172
|
+
}).format(/* @__PURE__ */ new Date("2014-06-25T04:00:00.123Z")), oe = _ === "06/25/2014, 00:00:00" || _ === "06/25/2014 00:00:00";
|
|
170
173
|
function ie(e) {
|
|
171
174
|
return g[e] || (g[e] = oe ? new Intl.DateTimeFormat("en-US", {
|
|
172
175
|
hourCycle: "h23",
|
|
@@ -188,17 +191,17 @@ function ie(e) {
|
|
|
188
191
|
second: "2-digit"
|
|
189
192
|
})), g[e];
|
|
190
193
|
}
|
|
191
|
-
function
|
|
194
|
+
function k(e, t, n, r, s, a, i) {
|
|
192
195
|
const o = /* @__PURE__ */ new Date(0);
|
|
193
196
|
return o.setUTCFullYear(e, t, n), o.setUTCHours(r, s, a, i), o;
|
|
194
197
|
}
|
|
195
|
-
const
|
|
198
|
+
const F = 36e5, ue = 6e4, I = {
|
|
196
199
|
timezone: /([Z+-].*)$/,
|
|
197
200
|
timezoneZ: /^(Z)$/,
|
|
198
201
|
timezoneHH: /^([+-]\d{2})$/,
|
|
199
202
|
timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/
|
|
200
203
|
};
|
|
201
|
-
function
|
|
204
|
+
function y(e, t, n) {
|
|
202
205
|
if (!e)
|
|
203
206
|
return 0;
|
|
204
207
|
let r = I.timezoneZ.exec(e);
|
|
@@ -206,11 +209,11 @@ function k(e, t, n) {
|
|
|
206
209
|
return 0;
|
|
207
210
|
let s, a;
|
|
208
211
|
if (r = I.timezoneHH.exec(e), r)
|
|
209
|
-
return s = parseInt(r[1], 10),
|
|
212
|
+
return s = parseInt(r[1], 10), S(s) ? -(s * F) : NaN;
|
|
210
213
|
if (r = I.timezoneHHMM.exec(e), r) {
|
|
211
214
|
s = parseInt(r[2], 10);
|
|
212
215
|
const i = parseInt(r[3], 10);
|
|
213
|
-
return
|
|
216
|
+
return S(s, i) ? (a = Math.abs(s) * F + i * ue, r[1] === "+" ? -a : a) : NaN;
|
|
214
217
|
}
|
|
215
218
|
if (le(e)) {
|
|
216
219
|
t = new Date(t || Date.now());
|
|
@@ -220,10 +223,10 @@ function k(e, t, n) {
|
|
|
220
223
|
return NaN;
|
|
221
224
|
}
|
|
222
225
|
function ce(e) {
|
|
223
|
-
return
|
|
226
|
+
return k(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds());
|
|
224
227
|
}
|
|
225
228
|
function x(e, t) {
|
|
226
|
-
const n = ne(e, t), r =
|
|
229
|
+
const n = ne(e, t), r = k(n[0], n[1] - 1, n[2], n[3] % 24, n[4], n[5], 0).getTime();
|
|
227
230
|
let s = e.getTime();
|
|
228
231
|
const a = s % 1e3;
|
|
229
232
|
return s -= a >= 0 ? a : 1e3 + a, r - s;
|
|
@@ -237,24 +240,24 @@ function fe(e, t, n) {
|
|
|
237
240
|
const i = x(new Date(s), n);
|
|
238
241
|
return a === i ? a : Math.max(a, i);
|
|
239
242
|
}
|
|
240
|
-
function
|
|
243
|
+
function S(e, t) {
|
|
241
244
|
return -23 <= e && e <= 23 && (t == null || 0 <= t && t <= 59);
|
|
242
245
|
}
|
|
243
|
-
const
|
|
246
|
+
const b = {};
|
|
244
247
|
function le(e) {
|
|
245
|
-
if (
|
|
248
|
+
if (b[e])
|
|
246
249
|
return !0;
|
|
247
250
|
try {
|
|
248
|
-
return new Intl.DateTimeFormat(void 0, { timeZone: e }),
|
|
251
|
+
return new Intl.DateTimeFormat(void 0, { timeZone: e }), b[e] = !0, !0;
|
|
249
252
|
} catch {
|
|
250
253
|
return !1;
|
|
251
254
|
}
|
|
252
255
|
}
|
|
253
|
-
function
|
|
256
|
+
function $(e) {
|
|
254
257
|
const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()));
|
|
255
258
|
return t.setUTCFullYear(e.getFullYear()), +e - +t;
|
|
256
259
|
}
|
|
257
|
-
const De = /(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/, p = 36e5,
|
|
260
|
+
const De = /(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/, p = 36e5, A = 6e4, de = 2, c = {
|
|
258
261
|
dateTimePattern: /^([0-9W+-]+)(T| )(.*)/,
|
|
259
262
|
datePattern: /^([0-9W+-]+)(.*)/,
|
|
260
263
|
plainTime: /:/,
|
|
@@ -303,7 +306,7 @@ function me(e, t = {}) {
|
|
|
303
306
|
return new Date(e);
|
|
304
307
|
if (Object.prototype.toString.call(e) !== "[object String]")
|
|
305
308
|
return /* @__PURE__ */ new Date(NaN);
|
|
306
|
-
const r = Me(e), { year: s, restDateString: a } =
|
|
309
|
+
const r = Me(e), { year: s, restDateString: a } = Te(r.date, n), i = he(a, s);
|
|
307
310
|
if (i === null || isNaN(i.getTime()))
|
|
308
311
|
return /* @__PURE__ */ new Date(NaN);
|
|
309
312
|
if (i) {
|
|
@@ -312,10 +315,10 @@ function me(e, t = {}) {
|
|
|
312
315
|
if (r.time && (u = Ne(r.time), u === null || isNaN(u)))
|
|
313
316
|
return /* @__PURE__ */ new Date(NaN);
|
|
314
317
|
if (r.timeZone || t.timeZone) {
|
|
315
|
-
if (l =
|
|
318
|
+
if (l = y(r.timeZone || t.timeZone, new Date(o + u)), isNaN(l))
|
|
316
319
|
return /* @__PURE__ */ new Date(NaN);
|
|
317
320
|
} else
|
|
318
|
-
l =
|
|
321
|
+
l = $(new Date(o + u)), l = $(new Date(o + u + l));
|
|
319
322
|
return new Date(o + u + l);
|
|
320
323
|
} else
|
|
321
324
|
return /* @__PURE__ */ new Date(NaN);
|
|
@@ -329,7 +332,7 @@ function Me(e) {
|
|
|
329
332
|
}
|
|
330
333
|
return t;
|
|
331
334
|
}
|
|
332
|
-
function
|
|
335
|
+
function Te(e, t) {
|
|
333
336
|
if (e) {
|
|
334
337
|
const n = c.YYY[t], r = c.YYYYY[t];
|
|
335
338
|
let s = c.YYYY.exec(e) || r.exec(e);
|
|
@@ -352,7 +355,7 @@ function he(e, t) {
|
|
|
352
355
|
year: null
|
|
353
356
|
};
|
|
354
357
|
}
|
|
355
|
-
function
|
|
358
|
+
function he(e, t) {
|
|
356
359
|
if (t === null)
|
|
357
360
|
return null;
|
|
358
361
|
let n, r, s;
|
|
@@ -360,7 +363,7 @@ function Te(e, t) {
|
|
|
360
363
|
return n = /* @__PURE__ */ new Date(0), n.setUTCFullYear(t), n;
|
|
361
364
|
let a = c.MM.exec(e);
|
|
362
365
|
if (a)
|
|
363
|
-
return n = /* @__PURE__ */ new Date(0), r = parseInt(a[1], 10) - 1,
|
|
366
|
+
return n = /* @__PURE__ */ new Date(0), r = parseInt(a[1], 10) - 1, z(t, r) ? (n.setUTCFullYear(t, r), n) : /* @__PURE__ */ new Date(NaN);
|
|
364
367
|
if (a = c.DDD.exec(e), a) {
|
|
365
368
|
n = /* @__PURE__ */ new Date(0);
|
|
366
369
|
const i = parseInt(a[1], 10);
|
|
@@ -369,14 +372,14 @@ function Te(e, t) {
|
|
|
369
372
|
if (a = c.MMDD.exec(e), a) {
|
|
370
373
|
n = /* @__PURE__ */ new Date(0), r = parseInt(a[1], 10) - 1;
|
|
371
374
|
const i = parseInt(a[2], 10);
|
|
372
|
-
return
|
|
375
|
+
return z(t, r, i) ? (n.setUTCFullYear(t, r, i), n) : /* @__PURE__ */ new Date(NaN);
|
|
373
376
|
}
|
|
374
377
|
if (a = c.Www.exec(e), a)
|
|
375
|
-
return s = parseInt(a[1], 10) - 1,
|
|
378
|
+
return s = parseInt(a[1], 10) - 1, Z(s) ? L(t, s) : /* @__PURE__ */ new Date(NaN);
|
|
376
379
|
if (a = c.WwwD.exec(e), a) {
|
|
377
380
|
s = parseInt(a[1], 10) - 1;
|
|
378
381
|
const i = parseInt(a[2], 10) - 1;
|
|
379
|
-
return
|
|
382
|
+
return Z(s, i) ? L(t, s, i) : /* @__PURE__ */ new Date(NaN);
|
|
380
383
|
}
|
|
381
384
|
return null;
|
|
382
385
|
}
|
|
@@ -385,15 +388,15 @@ function Ne(e) {
|
|
|
385
388
|
if (r)
|
|
386
389
|
return t = parseFloat(r[1].replace(",", ".")), w(t) ? t % 24 * p : NaN;
|
|
387
390
|
if (r = c.HHMM.exec(e), r)
|
|
388
|
-
return t = parseInt(r[1], 10), n = parseFloat(r[2].replace(",", ".")), w(t, n) ? t % 24 * p + n *
|
|
391
|
+
return t = parseInt(r[1], 10), n = parseFloat(r[2].replace(",", ".")), w(t, n) ? t % 24 * p + n * A : NaN;
|
|
389
392
|
if (r = c.HHMMSS.exec(e), r) {
|
|
390
393
|
t = parseInt(r[1], 10), n = parseInt(r[2], 10);
|
|
391
394
|
const s = parseFloat(r[3].replace(",", "."));
|
|
392
|
-
return w(t, n, s) ? t % 24 * p + n *
|
|
395
|
+
return w(t, n, s) ? t % 24 * p + n * A + s * 1e3 : NaN;
|
|
393
396
|
}
|
|
394
397
|
return null;
|
|
395
398
|
}
|
|
396
|
-
function
|
|
399
|
+
function L(e, t, n) {
|
|
397
400
|
t = t || 0, n = n || 0;
|
|
398
401
|
const r = /* @__PURE__ */ new Date(0);
|
|
399
402
|
r.setUTCFullYear(e, 0, 4);
|
|
@@ -404,7 +407,7 @@ const Ye = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], ge = [31, 29, 31, 3
|
|
|
404
407
|
function v(e) {
|
|
405
408
|
return e % 400 === 0 || e % 4 === 0 && e % 100 !== 0;
|
|
406
409
|
}
|
|
407
|
-
function
|
|
410
|
+
function z(e, t, n) {
|
|
408
411
|
if (t < 0 || t > 11)
|
|
409
412
|
return !1;
|
|
410
413
|
if (n != null) {
|
|
@@ -422,28 +425,33 @@ function Ie(e, t) {
|
|
|
422
425
|
const n = v(e);
|
|
423
426
|
return !(n && t > 366 || !n && t > 365);
|
|
424
427
|
}
|
|
425
|
-
function
|
|
428
|
+
function Z(e, t) {
|
|
426
429
|
return !(e < 0 || e > 52 || t != null && (t < 0 || t > 6));
|
|
427
430
|
}
|
|
428
431
|
function w(e, t, n) {
|
|
429
432
|
return !(e < 0 || e >= 25 || t != null && (t < 0 || t >= 60) || n != null && (n < 0 || n >= 60));
|
|
430
433
|
}
|
|
431
|
-
function
|
|
434
|
+
function Ce(e, t, n) {
|
|
432
435
|
e = me(e, n);
|
|
433
|
-
const r =
|
|
436
|
+
const r = y(t, e, !0), s = new Date(e.getTime() - r), a = /* @__PURE__ */ new Date(0);
|
|
434
437
|
return a.setFullYear(s.getUTCFullYear(), s.getUTCMonth(), s.getUTCDate()), a.setHours(s.getUTCHours(), s.getUTCMinutes(), s.getUTCSeconds(), s.getUTCMilliseconds()), a;
|
|
435
438
|
}
|
|
439
|
+
function Ue(e, t) {
|
|
440
|
+
return -y(e, t);
|
|
441
|
+
}
|
|
436
442
|
export {
|
|
437
|
-
we as
|
|
438
|
-
|
|
439
|
-
|
|
443
|
+
we as addMilliseconds,
|
|
444
|
+
xe as addMinutes,
|
|
445
|
+
$e as addMonths,
|
|
446
|
+
Se as format,
|
|
440
447
|
te as formatDistance,
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
ye as
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
448
|
+
Oe as formatDistanceToNow,
|
|
449
|
+
Ae as getDaysInMonth,
|
|
450
|
+
Ue as getTimezoneOffset,
|
|
451
|
+
ye as getUnixTime,
|
|
452
|
+
He as isToday,
|
|
453
|
+
Le as setDate,
|
|
454
|
+
ze as setYear,
|
|
455
|
+
Ze as subMonths,
|
|
456
|
+
Ce as toZonedTime
|
|
449
457
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { format, isToday, setDate, setYear, addMonths, subMonths, addMinutes, getUnixTime, formatDistance, getDaysInMonth, formatDistanceToNow } from 'date-fns';
|
|
2
|
-
import { toZonedTime } from 'date-fns-tz';
|
|
1
|
+
import { format, isToday, setDate, setYear, addMonths, subMonths, addMinutes, getUnixTime, formatDistance, getDaysInMonth, addMilliseconds, formatDistanceToNow } from 'date-fns';
|
|
2
|
+
import { toZonedTime, getTimezoneOffset } from 'date-fns-tz';
|
|
3
3
|
|
|
4
|
-
export { format, isToday, setDate, setYear, addMonths, subMonths, addMinutes, toZonedTime, getUnixTime, formatDistance, getDaysInMonth, formatDistanceToNow, };
|
|
4
|
+
export { format, isToday, setDate, setYear, addMonths, subMonths, addMinutes, toZonedTime, getUnixTime, formatDistance, getDaysInMonth, addMilliseconds, getTimezoneOffset, formatDistanceToNow, };
|