Created
April 17, 2023 09:52
-
-
Save mrdotb/c00411486718cf3ad699295d4bbdf311 to your computer and use it in GitHub Desktop.
timeago.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @license MIT | |
* timeago.js 4.0.2 | |
* https://github.com/mrdotb/timeago.js | |
* Copyright (c) 2016 Hust.cc | |
*/ | |
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).timeago={})}(this,function(e){"use strict";function t(e,t){n[e]=t}function r(e){return n[e]||n.en_US}var n={},a=[60,60,24,7,365/7/12,12];function o(e){return e instanceof Date?e:!isNaN(e)||/^\d+$/.test(e)?new Date(parseInt(e)):(e=(e||"").trim().replace(/\.\d+/,"").replace(/-/,"/").replace(/-/,"/").replace(/(\d)T(\d)/,"$1 $2").replace(/Z/," UTC").replace(/([+-]\d\d):?(\d\d)/," $1$2"),new Date(e))}function s(e,t){for(var n=e<0?1:0,r=e=Math.abs(e),o=0;e>=a[o]&&o<a.length;o++)e/=a[o];return(0===(o*=2)?9:1)<(e=Math.floor(e))&&(o+=1),t(e,o,r)[n].replace("%s",e.toString())}function u(e,t){return(+(t?o(t):new Date)-+o(e))/1e3}var c="timeago-id";function f(e){return parseInt(e.getAttribute(c))}var d={},g=function(e){clearTimeout(e),delete d[e]};function l(e,t,n,r){g(f(e));var o=r.relativeDate,i=r.minInterval,o=u(t,o),o=(e.innerText=s(o,n),setTimeout(function(){l(e,t,n,r)},Math.min(1e3*Math.max(function(e){for(var t=1,n=0,r=Math.abs(e);e>=a[n]&&n<a.length;n++)e/=a[n],t*=a[n];return r=(r%=t)?t-r:t,Math.ceil(r)}(o),i||1),2147483647)));d[o]=0,e.setAttribute(c,o)}t("en_short",function(e,t){return[["just now","right now"],["%ss ago","in %ss"],["1m ago","in 1m"],["%sm ago","in %sm"],["1h ago","in 1h"],["%sh ago","in %sh"],["1d ago","in 1d"],["%sd ago","in %sd"],["1w ago","in 1w"],["%sw ago","in %sw"],["1mo ago","in 1mo"],["%smo ago","in %smo"],["1yr ago","in 1yr"],["%syr ago","in %syr"]][t]}),e.cancel=function(e){e?g(f(e)):Object.keys(d).forEach(g)},e.format=function(e,t,n){return s(u(e,n&&n.relativeDate),r(t))},e.register=t,e.render=function(e,t,n){return(e=e.length?e:[e]).forEach(function(e){l(e,e.getAttribute("datetime"),r(t),n||{})}),e},Object.defineProperty(e,"__esModule",{value:!0})}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment