@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 CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("date-fns/locale"),r=require("date-fns"),i=require("date-fns-tz"),n=l.ptBR,f="America/Sao_Paulo";function a(t){return t instanceof Date?t:typeof t=="number"?new Date(t):typeof t=="string"?r.parseISO(t):t}function D(t,e=new Date,o){return r.formatDistance(a(t),a(e),{locale:n,...o})}function T(t,e){return r.formatDistanceToNow(a(t),{locale:n,...e})}function p(t,e,o){return r.format(a(t),e,{locale:n,...o})}function d(t,e=new Date,o){return r.formatRelative(a(t),a(e),{locale:n,...o})}function b(t,e,o=f){const c=i.toZonedTime(a(t),o);return r.format(c,e,{locale:n})}function w(t,e=new Date,o="às",c=f){const m=i.toZonedTime(a(t),c),u=i.toZonedTime(a(e),c),s=r.formatRelative(m,u,{locale:n}).replace(/às/g,o);return`${s.charAt(0).toUpperCase()}${s.slice(1)}`}function O(t,e){const o=i.toZonedTime(a(t),f);return r.formatDistanceToNow(o,{locale:l.ptBR,...e})}exports.DEFAULT_LOCALE=n;exports.DEFAULT_TZ=f;exports.format=p;exports.formatDateTZ=b;exports.formatDistance=D;exports.formatDistanceToNow=T;exports.formatRelative=d;exports.formatRelativeDate=w;exports.formatRelativeDateToNow=O;exports.toDate=a;Object.keys(r).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>r[t]})});
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 s } from "date-fns/locale";
2
- import { parseISO as w, format as m, formatDistance as T, formatDistanceToNow as l, formatRelative as D } from "date-fns";
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 = s, f = "America/Sao_Paulo";
6
- function r(t) {
7
- return t instanceof Date ? t : typeof t == "number" ? new Date(t) : typeof t == "string" ? w(t) : t;
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, o = /* @__PURE__ */ new Date(), e) {
10
- return T(r(t), r(o), {
9
+ function A(t, e = /* @__PURE__ */ new Date(), r) {
10
+ return h(n(t), n(e), {
11
11
  locale: a,
12
- ...e
12
+ ...r
13
13
  });
14
14
  }
15
- function d(t, o) {
16
- return l(r(t), {
15
+ function j(t, e) {
16
+ return D(n(t), {
17
17
  locale: a,
18
- ...o
18
+ ...e
19
19
  });
20
20
  }
21
- function j(t, o, e) {
22
- return m(r(t), o, {
21
+ function L(t, e, r) {
22
+ return l(n(t), e, {
23
23
  locale: a,
24
- ...e
24
+ ...r
25
25
  });
26
26
  }
27
- function L(t, o = /* @__PURE__ */ new Date(), e) {
28
- return D(r(t), r(o), {
27
+ function N(t, e = /* @__PURE__ */ new Date(), r) {
28
+ return p(n(t), n(e), {
29
29
  locale: a,
30
- ...e
30
+ ...r
31
31
  });
32
32
  }
33
- function N(t, o, e = f) {
34
- const n = c(r(t), e);
35
- return m(n, o, {
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
- function E(t, o = /* @__PURE__ */ new Date(), e = "às", n = f) {
40
- const u = c(r(t), n), p = c(r(o), n), i = D(u, p, {
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, e);
43
- return `${i.charAt(0).toUpperCase()}${i.slice(1)}`;
53
+ }).replace(/às/g, r);
54
+ return `${m.charAt(0).toUpperCase()}${m.slice(1)}`;
44
55
  }
45
- function S(t, o) {
46
- const e = c(r(t), f);
47
- return l(e, { locale: s, ...o });
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
- f as DEFAULT_TZ,
52
- j as format,
53
- N as formatDateTZ,
62
+ s as DEFAULT_TZ,
63
+ L as format,
64
+ v as formatDateTZ,
54
65
  A as formatDistance,
55
- d as formatDistanceToNow,
56
- L as formatRelative,
57
- E as formatRelativeDate,
58
- S as formatRelativeDateToNow,
59
- r as toDate
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vestcards/shared",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {