@alessiofrittoli/date-utils
Version:
Lightweight TypeScript date utility functions library
2 lines (1 loc) • 771 B
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true});var T=(e,r=!1)=>{let t=e<0;t&&(e=e*-1);let o=31536e3,a=2592e3,c=604800,n=86400,s=3600,u=Math.floor(e/o),m=Math.floor(e%o/a),l=r?null:Math.floor(e%o%a/c),d=Math.floor(r?e%o%a/n:e%o%a%c/n),i=Math.floor(e%o%n/s),f=Math.floor(e%o%n%s/60),h=Math.floor(e%o%n%s%60),k=Math.floor(e%o%n%s%60*1e3%1e3),S=Math.floor(e%o%n%s%60*1e6%1e3);return t?{years:u*-1,months:m*-1,weeks:l!==null?l*-1:null,days:d*-1,hours:i*-1,minutes:f*-1,seconds:h*-1,milliseconds:k*-1,microseconds:S*-1}:{years:u,months:m,weeks:l,days:d,hours:i,minutes:f,seconds:h,milliseconds:k,microseconds:S}},y= exports.b =(e=new Date,r,t={day:"numeric",month:"long",year:"numeric"})=>new Date(e).toLocaleString(r,t);exports.a = T; exports.b = y;