forked from electron/electronjs.org-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrowser-date-formatter.js
1 lines (1 loc) · 5.89 KB
/
browser-date-formatter.js
1
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.browserDateFormatter=e()}}(function(){var e;return function e(t,n,r){function a(u,i){if(!n[u]){if(!t[u]){var f="function"==typeof require&&require;if(!i&&f)return f(u,!0);if(o)return o(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var d=n[u]={exports:{}};t[u][0].call(d.exports,function(e){var n=t[u][1][e];return a(n?n:e)},d,d.exports,e,t,n,r)}return n[u].exports}for(var o="function"==typeof require&&require,u=0;u<r.length;u++)a(r[u]);return a}({1:[function(e,t,n){var r=e("domready"),a=e("prettydate").strftime,o=e("relative-date");t.exports=function(){u(),r(u),setInterval(u,5e3)};var u=function(){var e=document.querySelectorAll("[data-date]");Array.prototype.forEach.call(e,function(e){var t;if(e.dataset.date.match(/^\d{4}-\d{2}-\d{2}$/)){var n=e.dataset.date.split("-");t=new Date(n[0],n[1]-1,n[2])}else t=new Date(e.dataset.date);if(!t.getFullYear())return console.error("Invalid date",e.dataset.date);var r=e.dataset.format||"relative",u="relative"===r?o(t):a(t,r);e.textContent=u})}},{domready:2,prettydate:3,"relative-date":5}],2:[function(t,n,r){!function(t,r){"undefined"!=typeof n?n.exports=r():"function"==typeof e&&"object"==typeof e.amd?e(r):this[t]=r()}("domready",function(){var e,t=[],n=document,r=n.documentElement.doScroll,a="DOMContentLoaded",o=(r?/^loaded|^c/:/^loaded|^i|^c/).test(n.readyState);return o||n.addEventListener(a,e=function(){for(n.removeEventListener(a,e),o=1;e=t.shift();)e()}),function(e){o?setTimeout(e,0):t.push(e)}})},{}],3:[function(e,t,n){n.strftime=strftime=e("./strftime")},{"./strftime":4}],4:[function(e,t,n){function r(e,t,n){for("undefined"==typeof n&&(n=10),t=t.toString();parseInt(e,10)<n&&n>1;n/=10)e=t+e;return e.toString()}function a(e,t,n){var a;if(!e)return"";if(t||(t=""),n||(n="en-US"),n=n.replace(/_/g,"-"),!f[n]){console.warn("selected locale "+n+" not found, trying alternatives");var o=n.replace(/-[a-zA-Z]+$/,"");n=o in f?o:"en",console.info("falling back to "+n)}a=f[n];var c=function(e,t){var n=i[t];return"locale"===n?a[t]:n},d=function(n,o){var i=u[o];return"string"==typeof i?e[i]():"function"==typeof i?i.call(e,e,a):i instanceof Array&&"string"==typeof i[0]?r(e[i[0]](),i[1]):(console.warn("unrecognised replacement type, please file a bug (format: "+t+")"),o)};for(t=t.replace(/%%/g,"%\b");t.match(/%[cDFhnrRtTxX]/);)t=t.replace(/%([cDFhnrRtTxX])/g,c);var l=t.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ])/g,d);return l=l.replace("%\b","%%"),c=d=void 0,l}function o(e,t,n){n||(n="en"),f[e]=t;for(k in f[n])k in t||(f[e][k]=f[n][k])}var u={a:function(e,t){return t.a[e.getDay()]},A:function(e,t){return t.A[e.getDay()]},b:function(e,t){return t.b[e.getMonth()]},B:function(e,t){return t.B[e.getMonth()]},C:function(e){return r(parseInt(e.getFullYear()/100,10),0)},d:["getDate","0"],e:["getDate"," "],g:function(e){return r(parseInt(u.G(e)%100,10),0)},G:function(e){var t=e.getFullYear(),n=parseInt(u.V(e),10),r=parseInt(u.W(e),10);return r>n?t++:0===r&&n>=52&&t--,t},H:["getHours","0"],I:function(e){var t=e.getHours()%12;return r(0===t?12:t,0)},j:function(e){var t=new Date(""+e.getFullYear()+"/1/1 GMT"),n=new Date(""+e.getFullYear()+"/"+(e.getMonth()+1)+"/"+e.getDate()+" GMT"),a=n-t,o=parseInt(a/6e4/60/24,10)+1;return r(o,0,100)},k:["getHours"," "],l:function(e){var t=e.getHours()%12;return r(0===t?12:t," ")},m:function(e){return r(e.getMonth()+1,0)},M:["getMinutes","0"],p:function(e,t){return t.p[e.getHours()>=12?1:0]},P:function(e,t){return t.P[e.getHours()>=12?1:0]},s:function(e,t){return parseInt(e.getTime()/1e3,10)},S:["getSeconds","0"],u:function(e){var t=e.getDay();return 0===t?7:t},U:function(e){var t=parseInt(u.j(e),10),n=6-e.getDay(),a=parseInt((t+n)/7,10);return r(a,0)},V:function(e){var t=parseInt(u.W(e),10),n=new Date(""+e.getFullYear()+"/1/1").getDay(),a=t+(n>4||n<=1?0:1);return 53===a&&new Date(""+e.getFullYear()+"/12/31").getDay()<4?a=1:0===a&&(a=u.V(new Date(""+(e.getFullYear()-1)+"/12/31"))),r(a,0)},w:"getDay",W:function(e){var t=parseInt(u.j(e),10),n=7-u.u(e),a=parseInt((t+n)/7,10);return r(a,0,10)},y:function(e){return r(e.getFullYear()%100,0)},Y:"getFullYear",z:function(e){var t=e.getTimezoneOffset(),n=r(parseInt(Math.abs(t/60),10),0),a=r(Math.abs(t%60),0);return(t>0?"-":"+")+n+a},Z:function(e){var t=e.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/,"$2").replace(/[a-z ]/g,"");return t.length>4&&(t=u.z(e)),t},"%":function(e){return"%"}},i={c:"locale",D:"%m/%d/%y",F:"%Y-%m-%d",h:"%b",n:"\n",r:"%I:%M:%S %p",R:"%H:%M",t:"\t",T:"%H:%M:%S",x:"locale",X:"locale"},f={};f.en={a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a %d %b %Y %T %Z",p:["AM","PM"],P:["am","pm"],r:"%I:%M:%S %p",x:"%d/%m/%y",X:"%T"},o("en-US",{c:"%a %d %b %Y %I:%M:%S %p %Z",x:"%m/%d/%Y",X:"%I:%M:%S %p"}),o("en-GB",{r:"%l:%M:%S %P %Z"}),o("en-AU",{}),a.addLocale=o,t.exports=a},{}],5:[function(e,t,n){var r=function(e){function t(t,n){!n&&(n=(new Date).getTime()),n instanceof Date&&(n=n.getTime()),t instanceof Date&&(t=t.getTime());var r,a,o,u=n-t;for(a=-1,o=c.length;++a<o;)if(r=c[a],u<r[0])return r[2]==e?r[1]:Math.round(u/r[2])+" "+r[1]}var n=1e3,r=60*n,a=60*r,o=24*a,u=7*o,i=365*o,f=i/12,c=[[.7*r,"just now"],[1.5*r,"a minute ago"],[60*r,"minutes ago",r],[1.5*a,"an hour ago"],[o,"hours ago",a],[2*o,"yesterday"],[7*o,"days ago",o],[1.5*u,"a week ago"],[f,"weeks ago",u],[1.5*f,"a month ago"],[i,"months ago",f],[1.5*i,"a year ago"],[Number.MAX_VALUE,"years ago",i]];return t}();"undefined"!=typeof t&&t.exports&&(t.exports=r)},{}]},{},[1])(1)});