UNPKG

epoch-timeago

Version:

Convert Unix time to a relative time string e.g., "4 hours ago".

2 lines (1 loc) 954 B
(function(a,b){if("function"==typeof define&&define.amd)define(["exports"],b);else if("undefined"!=typeof exports)b(exports);else{var c={exports:{}};b(c.exports),a.index=c.exports}})(this,function(a){"use strict";function b(a,b){if(a!==b)throw new TypeError("Cannot instantiate an arrow function")}Object.defineProperty(a,"__esModule",{value:!0}),a.default=void 0;var c=void 0,d=[3154e7,2628e6,6048e5,864e5,36e5,6e4,-Infinity],e=function(a,d){var e=this;return b(this,c),function(c,f){return b(this,e),f>=2*c?"".concat(Math.floor(f/c)," ").concat(a,"s ago"):d}.bind(this)}.bind(void 0),f=[e("year","1 year ago"),e("month","1 month ago"),e("week","1 week ago"),e("day","1 day ago"),e("hour","an hour ago"),e("minute","a minute ago"),function(){return b(this,c),"just now"}.bind(void 0)],g=function(a){var e=this;b(this,c);var g=Date.now()-a,h=d.findIndex(function(a){return b(this,e),g>=a}.bind(this)),i=f[h](d[h],g);return i}.bind(void 0);a.default=g});