@prismicio/editor-support
Advanced tools
Comparing version 0.4.60 to 0.4.61
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(t){return!isNaN(t.getTime())}function F(t){const e=new Date(t);return c(e)?e:void 0}function M(t){const e=D(t),n=s(t);return e>0?t.toLocaleDateString("en-US",{day:"numeric",month:"short",year:"numeric"}):n>0?m({date:t}):"Just now"}function S(t,e="en-US"){const n=new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"}),o=new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}),i=n.format(t),r=o.format(t).toLocaleLowerCase();return`${i} ${r}`}function m(t){const{date:e,lang:n="en-US",style:o="short"}=t,i=e.getTime(),r=Math.round((i-Date.now())/1e3),h=f(e),u=[60,3600,86400,86400*7,86400*h,86400*365,1/0],l=["second","minute","hour","day","week","month","year"],a=u.findIndex(y=>y>Math.abs(r)),d=a?u[a-1]??1:1;return new Intl.RelativeTimeFormat(n,{numeric:"auto",style:o}).format(Math.floor(r/d),l[a]??"second")}function f(t){return new Date(t.getFullYear(),t.getMonth()+1,0).getDate()}function s(t){const n=new Date().getTime()-t.getTime();return Math.floor(n/(60*1e3))}function g(t){const e=s(t);return Math.floor(e/60)}function D(t){const e=g(t);return Math.floor(e/24)}function w(t){const e=new Date,n=e.getFullYear()-t.getFullYear(),o=e.getMonth()-t.getMonth();return n*12+o}exports.dateFromISOString=F;exports.getDateDiffString=M;exports.getDaysFrom=D;exports.getHoursFrom=g;exports.getMinutesFrom=s;exports.getMonthsFrom=w;exports.getNumberOfDaysInMonth=f;exports.getRelativeTimeString=m;exports.isValidDate=c;exports.prettyPrintDate=S; | ||
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function c(t){return!isNaN(t.getTime())}function M(t){const e=new Date(t);return c(e)?e:void 0}function y(t){const e=l(t),n=s(t);return e>0?t.toLocaleDateString("en-US",{day:"numeric",month:"short",year:"numeric"}):n>0?m({date:t}):"Just now"}function F(t,e="en-US"){const n=new Intl.DateTimeFormat(e,{year:"numeric",month:"short",day:"numeric"}),r=new Intl.DateTimeFormat(e,{hour:"2-digit",minute:"2-digit"}),i=n.format(t),o=r.format(t).toLocaleLowerCase();return`${i} ${o}`}function w(t){const e=t.getUTCFullYear().toString().padStart(4,"0"),n=(t.getUTCMonth()+1).toString().padStart(2,"0"),r=t.getUTCDate().toString().padStart(2,"0");return`${e}-${n}-${r}`}function m(t){const{date:e,lang:n="en-US",style:r="short"}=t,i=e.getTime(),o=Math.round((i-Date.now())/1e3),D=g(e),u=[60,3600,86400,86400*7,86400*D,86400*365,1/0],S=["second","minute","hour","day","week","month","year"],a=u.findIndex(d=>d>Math.abs(o)),h=a?u[a-1]??1:1;return new Intl.RelativeTimeFormat(n,{numeric:"auto",style:r}).format(Math.floor(o/h),S[a]??"second")}function g(t){return new Date(t.getFullYear(),t.getMonth()+1,0).getDate()}function s(t){const n=new Date().getTime()-t.getTime();return Math.floor(n/(60*1e3))}function f(t){const e=s(t);return Math.floor(e/60)}function l(t){const e=f(t);return Math.floor(e/24)}function I(t){const e=new Date,n=e.getFullYear()-t.getFullYear(),r=e.getMonth()-t.getMonth();return n*12+r}exports.dateFromISOString=M;exports.getDateDiffString=y;exports.getDaysFrom=l;exports.getHoursFrom=f;exports.getMinutesFrom=s;exports.getMonthsFrom=I;exports.getNumberOfDaysInMonth=g;exports.getRelativeTimeString=m;exports.getSimpleISOString=w;exports.isValidDate=c;exports.prettyPrintDate=F; |
@@ -20,2 +20,6 @@ /** | ||
export declare function prettyPrintDate(date: Date, locale?: string): string; | ||
/**\ | ||
* Example output: "2024-12-22" | ||
*/ | ||
export declare function getSimpleISOString(date: Date): string; | ||
interface GetRelativeTimeStringArgs { | ||
@@ -22,0 +26,0 @@ date: Date; |
function h(t) { | ||
return !isNaN(t.getTime()); | ||
} | ||
function w(t) { | ||
function y(t) { | ||
const n = new Date(t); | ||
@@ -9,3 +9,3 @@ return h(n) ? n : void 0; | ||
function F(t) { | ||
const n = y(t), e = u(t); | ||
const n = S(t), e = u(t); | ||
return n > 0 ? t.toLocaleDateString("en-US", { | ||
@@ -17,3 +17,3 @@ day: "numeric", | ||
} | ||
function I(t, n = "en-US") { | ||
function w(t, n = "en-US") { | ||
const e = new Intl.DateTimeFormat(n, { | ||
@@ -29,2 +29,6 @@ year: "numeric", | ||
} | ||
function T(t) { | ||
const n = t.getUTCFullYear().toString().padStart(4, "0"), e = (t.getUTCMonth() + 1).toString().padStart(2, "0"), o = t.getUTCDate().toString().padStart(2, "0"); | ||
return `${n}-${e}-${o}`; | ||
} | ||
function l(t) { | ||
@@ -71,7 +75,7 @@ const { date: n, lang: e = "en-US", style: o = "short" } = t, i = n.getTime(), r = Math.round((i - Date.now()) / 1e3), c = D(n), s = [ | ||
} | ||
function y(t) { | ||
function S(t) { | ||
const n = d(t); | ||
return Math.floor(n / 24); | ||
} | ||
function S(t) { | ||
function I(t) { | ||
const n = /* @__PURE__ */ new Date(), e = n.getFullYear() - t.getFullYear(), o = n.getMonth() - t.getMonth(); | ||
@@ -81,12 +85,13 @@ return e * 12 + o; | ||
export { | ||
w as dateFromISOString, | ||
y as dateFromISOString, | ||
F as getDateDiffString, | ||
y as getDaysFrom, | ||
S as getDaysFrom, | ||
d as getHoursFrom, | ||
u as getMinutesFrom, | ||
S as getMonthsFrom, | ||
I as getMonthsFrom, | ||
D as getNumberOfDaysInMonth, | ||
l as getRelativeTimeString, | ||
T as getSimpleISOString, | ||
h as isValidDate, | ||
I as prettyPrintDate | ||
w as prettyPrintDate | ||
}; |
@@ -68,3 +68,3 @@ { | ||
}, | ||
"version": "0.4.60" | ||
"version": "0.4.61" | ||
} |
80750
1888