UNPKG

short-time-ago

Version:

A small, no dependencies, Typescript utility to describe time differences in a human readable format (for example, '1 minute ago')

3 lines (2 loc) 376 B
function e(e,t){for(var r=(t||new Date).getTime()-e.getTime(),n=Math.abs(r),a=0,o=[["year",31536e6],["month",26352e5],["day",864e5],["hour",36e5],["minute",6e4],["second",1e3]];a<o.length;a++){var i=o[a],u=i[0],h=Math.floor(n/i[1]);if(h>0){var f=h+" "+u+(h>1?"s":"");return r>0?f+" ago":"in "+f}}return"just now"}export{e as timeAgo}; //# sourceMappingURL=index.module.js.map