f7cloud_client/apps/photos/js/NcDateTime-DshRFtUU-DhtBMvqa.chunk.mjs
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

3 lines
2.2 KiB
JavaScript

import{q as m,b as p,k as d,af as g,y,w as b,o as D,z as S}from"./vue.runtime.esm-Ct3_M7aQ.chunk.mjs";import{r as I,aI as F,a as f,n as x}from"./index-BMeBqg0T.chunk.mjs";I(F);const N={long:f("a few seconds ago"),short:f("seconds ago"),narrow:f("sec. ago")};function _(e=Date.now(),r={}){const s=p(Date.now());let a;const c=p({format:{timeStyle:"medium",dateStyle:"short"},relativeTime:"long",ignoreSeconds:!1,...d(r)}),t=m(()=>({...d(r),...c.value})),v=m(()=>new Date(d(e))),h=m(()=>new Intl.DateTimeFormat(g(),t.value.format).format(v.value)),T=m(()=>{if(t.value.relativeTime!==!1){const o=new Intl.RelativeTimeFormat(y(),{numeric:"auto",style:t.value.relativeTime}),i=(v.value.getTime()-s.value)/1e3;if(Math.abs(i)<59.5)return t.value.ignoreSeconds?N[t.value.relativeTime]:o.format(Math.round(i),"second");const l=i/60;if(Math.abs(l)<=59)return o.format(Math.round(l),"minute");const u=l/60;if(Math.abs(u)<23.5)return o.format(Math.round(u),"hour");const n=u/24;if(Math.abs(n)<6.5)return o.format(Math.round(n),"day");if(Math.abs(n)<27.5){const M=n/7;return o.format(Math.round(M),"week")}const w=n/30;return Math.abs(w)<11.5?o.format(Math.round(w),"month"):o.format(Math.round(n/365),"year")}return h.value});return b([t],()=>{window.clearInterval(a),a=void 0,t.value.relativeTime&&(a=window.setInterval(()=>{s.value=Date.now()},1e3))}),D(()=>{t.value.relativeTime!==!1&&(a=window.setInterval(()=>{s.value=Date.now()},1e3))}),S(()=>{window.clearInterval(a)}),{formattedTime:T,formattedFullTime:h,options:c}}const k={name:"NcDateTime",props:{timestamp:{type:[Date,Number],required:!0},format:{type:Object,default:()=>({timeStyle:"medium",dateStyle:"short"})},relativeTime:{type:[Boolean,String],default:"long",validator:e=>e===!1||["long","short","narrow"].includes(e)},ignoreSeconds:{type:Boolean,default:!1}},setup(e){const r=m(()=>e.timestamp),{formattedTime:s,formattedFullTime:a}=_(r,e);return{formattedTime:s,formattedFullTime:a}}};var q=function(){var e=this,r=e._self._c;return r("span",{staticClass:"nc-datetime",attrs:{"data-timestamp":e.timestamp,title:e.formattedFullTime},domProps:{textContent:e._s(e.formattedTime)}})},C=[],z=x(k,q,C,!1,null,null);const j=z.exports;export{j as N};
//# sourceMappingURL=NcDateTime-DshRFtUU-DhtBMvqa.chunk.mjs.map