@vestcards/shared 1.0.1 → 1.0.2
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.cjs +1 -1
- package/dist/date.d.ts +2 -0
- package/dist/date.js +47 -35
- package/package.json +1 -1
package/dist/date.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("date-fns/locale"),o=require("date-fns"),s=require("date-fns-tz"),a=m.ptBR,u="America/Sao_Paulo";function n(e){return e instanceof Date?e:typeof e=="number"?new Date(e):typeof e=="string"?o.parseISO(e):e}function T(e,t=new Date,r){return o.formatDistance(n(e),n(t),{locale:a,...r})}function d(e,t){return o.formatDistanceToNow(n(e),{locale:a,...t})}function w(e,t,r){return o.format(n(e),t,{locale:a,...r})}function p(e,t=new Date,r){return o.formatRelative(n(e),n(t),{locale:a,...r})}function R(e,t,r=u){const c=s.toZonedTime(n(e),r);return o.format(c,t,{locale:a})}const y=e=>{const t=new Date,r=o.differenceInMinutes(e,t);if(r<1)return"<1m";if(r<10)return`<${Math.ceil(r/10)*10}m`;if(o.differenceInHours(e,t)<1)return"<1h";const i=o.differenceInDays(e,t);if(i<1)return"<1d";if(i<7)return`${i}d`;const f=o.differenceInMonths(e,t);return f<1?`${Math.ceil(i/30)}M`:f<12?`${f}M`:`${o.differenceInYears(e,t)}y`};function b(e,t=new Date,r="às",c=u){const i=s.toZonedTime(n(e),c),f=s.toZonedTime(n(t),c),l=o.formatRelative(i,f,{locale:a}).replace(/às/g,r);return`${l.charAt(0).toUpperCase()}${l.slice(1)}`}function O(e,t){const r=s.toZonedTime(n(e),u);return o.formatDistanceToNow(r,{locale:m.ptBR,...t})}exports.DEFAULT_LOCALE=a;exports.DEFAULT_TZ=u;exports.format=w;exports.formatDateTZ=R;exports.formatDistance=T;exports.formatDistanceToNow=d;exports.formatRelative=p;exports.formatRelativeDate=b;exports.formatRelativeDateToNow=O;exports.formatRelativeReviewDate=y;exports.toDate=n;Object.keys(o).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>o[e]})});
|
package/dist/date.d.ts
CHANGED
|
@@ -45,6 +45,8 @@ export declare function formatRelativeDate(date: DateValue, baseDate?: DateValue
|
|
|
45
45
|
*/
|
|
46
46
|
export declare function formatRelativeDateToNow(date: DateValue, options?: Parameters<typeof formatDistanceToNow_2>[1]): string;
|
|
47
47
|
|
|
48
|
+
export declare const formatRelativeReviewDate: (date: Date) => string;
|
|
49
|
+
|
|
48
50
|
export declare function toDate(value: DateValue): Date;
|
|
49
51
|
|
|
50
52
|
|
package/dist/date.js
CHANGED
|
@@ -1,60 +1,72 @@
|
|
|
1
|
-
import { ptBR as
|
|
2
|
-
import { parseISO as
|
|
1
|
+
import { ptBR as u } from "date-fns/locale";
|
|
2
|
+
import { parseISO as $, format as l, formatDistance as h, formatDistanceToNow as D, formatRelative as p, differenceInMinutes as T, differenceInHours as d, differenceInDays as R, differenceInMonths as y, differenceInYears as b } from "date-fns";
|
|
3
3
|
export * from "date-fns";
|
|
4
4
|
import { toZonedTime as c } from "date-fns-tz";
|
|
5
|
-
const a =
|
|
6
|
-
function
|
|
7
|
-
return t instanceof Date ? t : typeof t == "number" ? new Date(t) : typeof t == "string" ?
|
|
5
|
+
const a = u, s = "America/Sao_Paulo";
|
|
6
|
+
function n(t) {
|
|
7
|
+
return t instanceof Date ? t : typeof t == "number" ? new Date(t) : typeof t == "string" ? $(t) : t;
|
|
8
8
|
}
|
|
9
|
-
function A(t,
|
|
10
|
-
return
|
|
9
|
+
function A(t, e = /* @__PURE__ */ new Date(), r) {
|
|
10
|
+
return h(n(t), n(e), {
|
|
11
11
|
locale: a,
|
|
12
|
-
...
|
|
12
|
+
...r
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
return
|
|
15
|
+
function j(t, e) {
|
|
16
|
+
return D(n(t), {
|
|
17
17
|
locale: a,
|
|
18
|
-
...
|
|
18
|
+
...e
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
return
|
|
21
|
+
function L(t, e, r) {
|
|
22
|
+
return l(n(t), e, {
|
|
23
23
|
locale: a,
|
|
24
|
-
...
|
|
24
|
+
...r
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
function
|
|
28
|
-
return
|
|
27
|
+
function N(t, e = /* @__PURE__ */ new Date(), r) {
|
|
28
|
+
return p(n(t), n(e), {
|
|
29
29
|
locale: a,
|
|
30
|
-
...
|
|
30
|
+
...r
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
const
|
|
35
|
-
return
|
|
33
|
+
function v(t, e, r = s) {
|
|
34
|
+
const f = c(n(t), r);
|
|
35
|
+
return l(f, e, {
|
|
36
36
|
locale: a
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
const
|
|
39
|
+
const E = (t) => {
|
|
40
|
+
const e = /* @__PURE__ */ new Date(), r = T(t, e);
|
|
41
|
+
if (r < 1) return "<1m";
|
|
42
|
+
if (r < 10) return `<${Math.ceil(r / 10) * 10}m`;
|
|
43
|
+
if (d(t, e) < 1) return "<1h";
|
|
44
|
+
const o = R(t, e);
|
|
45
|
+
if (o < 1) return "<1d";
|
|
46
|
+
if (o < 7) return `${o}d`;
|
|
47
|
+
const i = y(t, e);
|
|
48
|
+
return i < 1 ? `${Math.ceil(o / 30)}M` : i < 12 ? `${i}M` : `${b(t, e)}y`;
|
|
49
|
+
};
|
|
50
|
+
function S(t, e = /* @__PURE__ */ new Date(), r = "às", f = s) {
|
|
51
|
+
const o = c(n(t), f), i = c(n(e), f), m = p(o, i, {
|
|
41
52
|
locale: a
|
|
42
|
-
}).replace(/às/g,
|
|
43
|
-
return `${
|
|
53
|
+
}).replace(/às/g, r);
|
|
54
|
+
return `${m.charAt(0).toUpperCase()}${m.slice(1)}`;
|
|
44
55
|
}
|
|
45
|
-
function
|
|
46
|
-
const
|
|
47
|
-
return
|
|
56
|
+
function U(t, e) {
|
|
57
|
+
const r = c(n(t), s);
|
|
58
|
+
return D(r, { locale: u, ...e });
|
|
48
59
|
}
|
|
49
60
|
export {
|
|
50
61
|
a as DEFAULT_LOCALE,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
62
|
+
s as DEFAULT_TZ,
|
|
63
|
+
L as format,
|
|
64
|
+
v as formatDateTZ,
|
|
54
65
|
A as formatDistance,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
66
|
+
j as formatDistanceToNow,
|
|
67
|
+
N as formatRelative,
|
|
68
|
+
S as formatRelativeDate,
|
|
69
|
+
U as formatRelativeDateToNow,
|
|
70
|
+
E as formatRelativeReviewDate,
|
|
71
|
+
n as toDate
|
|
60
72
|
};
|