1// [email protected] downloaded from https://ga.jspm.io/npm:[email protected]/app/assets/javascripts/local-time.es2017-esm.js 2 3const a={config:{},run(){this.getController().processElements()},process(...a){for(const s of a)this.getController().processElement(s);return a.length},getController(){return this.controller?this.controller:this.controller=new a.Controller}};a.config.useFormat24=!1,a.config.i18n={en:{date:{dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbrDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbrMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],yesterday:"yesterday",today:"today",tomorrow:"tomorrow",on:"on {date}",formats:{default:"%b %e, %Y",thisYear:"%b %e"}},time:{am:"am",pm:"pm",singular:"a {time}",singularAn:"an {time}",elapsed:"{time} ago",second:"second",seconds:"seconds",minute:"minute",minutes:"minutes",hour:"hour",hours:"hours",formats:{default:"%l:%M%P",default_24h:"%H:%M"}},datetime:{at:"{date} at {time}",formats:{default:"%B %e, %Y at %l:%M%P %Z",default_24h:"%B %e, %Y at %H:%M %Z"}}}},a.config.locale="en",a.config.defaultLocale="en",a.config.timerInterval=6e4;const s=!isNaN(Date.parse("2011-01-01T12:00:00-05:00"));a.parseDate=a=>(a=a.toString(),s||(a=function(a){const s=a.match(n);if(s){let a;const[n,i,o,c,u,l,d,m]=s;return"Z"!==m&&(a=m.replace(":","")),`${i}/${o}/${c} ${u}:${l}:${d} GMT${[a]}`}}(a)),new Date(Date.parse(a)));const n=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|[-+]?[\d:]+)$/;a.elementMatchesSelector=(()=>{const a=document.documentElement,s=a.matches||a.matchesSelector||a.webkitMatchesSelector||a.mozMatchesSelector||a.msMatchesSelector;return(a,n)=>{if(a?.nodeType===Node.ELEMENT_NODE)return s.call(a,n)}})();const{config:i}=a,{i18n:o}=i;a.getI18nValue=(s="",n={locale:i.locale})=>{const{locale:c}=n,u=function(a,s){let n=a;for(var i of Array.from(s.split("."))){if(!n[i])return null;n=n[i]}return n}(o[c],s);return u||(c!==i.defaultLocale?a.getI18nValue(s,{locale:i.defaultLocale}):void 0)},a.translate=(s,n={},i)=>{let o=a.getI18nValue(s,i);for(const a in n){const s=n[a];o=o.replace(`{${a}}`,s)}return o};const{getI18nValue:c,translate:u}=a,l="function"==typeof Intl?.DateTimeFormat,d={"Central European Standard Time":"CET","Central European Summer Time":"CEST","China Standard Time":"CST","Israel Daylight Time":"IDT","Israel Standard Time":"IST","Moscow Standard Time":"MSK","Peru Standard Time":"PET","Philippine Standard Time":"PHT","Singapore Standard Time":"SGT","Western Indonesia Time":"WIB"};a.knownEdgeCaseTimeZones=d,a.strftime=(()=>{const t=(a,s)=>{const n=a.getDay(),i=a.getDate(),o=a.getMonth(),m=a.getFullYear(),h=a.getHours(),g=a.getMinutes(),f=a.getSeconds();return s.replace(/%(-?)([%aAbBcdeHIlmMpPSwyYZ])/g,((s,p,y)=>{switch(y){case"%":return"%";case"a":return c("date.abbrDayNames")[n];case"A":return c("date.dayNames")[n];case"b":return c("date.abbrMonthNames")[o];case"B":return c("date.monthNames")[o];case"c":return a.toString();case"d":return e(i,p);case"e":return i;case"H":return e(h,p);case"I":return e(t(a,"%l"),p);case"l":return 0===h||12===h?12:(h+12)%12;case"m":return e(o+1,p);case"M":return e(g,p);case"p":return u("time."+(h>11?"pm":"am")).toUpperCase();case"P":return u("time."+(h>11?"pm":"am"));case"S":return e(f,p);case"w":return n;case"y":return e(m%100,p);case"Y":return m;case"Z":return function(a){let s,n,i;return(n=function(a){return Object.keys(d).find((s=>l?new Date(a).toLocaleString("en-US",{timeZoneName:"long"}).includes(s):a.toString().includes(s)))}(a))?d[n]:(i=r(a,{allowGMT:!1}))||(i=function(a){const s=a.toString();let n;if(null!=(n=s.match(/\(([\w\s]+)\)$/))){const a=n[1];return/\s/.test(a)?a.match(/\b(\w)/g).join(""):a}return null!=(n=s.match(/(\w{3,4})\s\d{4}$/))||null!=(n=s.match(/(UTC[\+\-]\d+)/))?n[1]:void 0}(a))?i:(s=r(a,{allowGMT:!0}))?s:""}(a)}}))};function e(a,s){return"-"===s?a:`0${a}`.slice(-2)}function r(a,{allowGMT:s}
3){if(l){const n=new Date(a).toLocaleString("en-US",{timeZoneName:"short"}).split(" ").pop();if(s||!n.includes("GMT"))return n}}return t})(),a.CalendarDate=class{static fromDate(a){return new this(a.getFullYear(),a.getMonth()+1,a.getDate())}static today(){return this.fromDate(new Date)}constructor(a,s,n){this.date=new Date(Date.UTC(a,s-1)),this.date.setUTCDate(n),this.year=this.date.getUTCFullYear(),this.month=this.date.getUTCMonth()+1,this.day=this.date.getUTCDate(),this.value=this.date.getTime()}equals(a){return a?.value===this.value}is(a){return this.equals(a)}isToday(){return this.is(this.constructor.today())}occursOnSameYearAs(a){return this.year===a?.year}occursThisYear(){return this.occursOnSameYearAs(this.constructor.today())}daysSince(a){if(a)return(this.date-a.date)/864e5}daysPassed(){return this.constructor.today().daysSince(this)}};const{strftime:m,translate:h,getI18nValue:g,config:f}=a;a.RelativeTime=class{constructor(s){this.date=s,this.calendarDate=a.CalendarDate.fromDate(this.date)}toString(){let a,s;return(s=this.toTimeElapsedString())?h("time.elapsed",{time:s}):(a=this.toWeekdayString())?(s=this.toTimeString(),h("datetime.at",{date:a,time:s})):h("date.on",{date:this.toDateString()})}toTimeOrDateString(){return this.calendarDate.isToday()?this.toTimeString():this.toDateString()}toTimeElapsedString(){let a;const s=(new Date).getTime()-this.date.getTime(),n=Math.round(s/1e3),i=Math.round(n/60),o=Math.round(i/60);return s<0?null:n<10?(a=h("time.second"),h("time.singular",{time:a})):n<45?`${n} ${h("time.seconds")}`:n<90?(a=h("time.minute"),h("time.singular",{time:a})):i<45?`${i} ${h("time.minutes")}`:i<90?(a=h("time.hour"),h("time.singularAn",{time:a})):o<24?`${o} ${h("time.hours")}`:""}toWeekdayString(){switch(this.calendarDate.daysPassed()){case 0:return h("date.today");case 1:return h("date.yesterday");case-1:return h("date.tomorrow");case 2:case 3:case 4:case 5:case 6:return m(this.date,"%A");default:return""}}toDateString(){const a=this.calendarDate.occursThisYear()?g("date.formats.thisYear"):g("date.formats.default");return m(this.date,a)}toTimeString(){const a=f.useFormat24?"default_24h":"default";return m(this.date,g(`time.formats.${a}`))}};const{elementMatchesSelector:p}=a;a.PageObserver=class{constructor(a,s){this.selector=a,this.callback=s,this.processMutations=this.processMutations.bind(this),this.processInsertion=this.processInsertion.bind(this)}start(){this.started||(this.observeWithMutationObserver()||this.observeWithMutationEvent(),this.started=!0)}observeWithMutationObserver(){return"undefined"!=typeof MutationObserver&&null!==MutationObserver&&(new MutationObserver(this.processMutations).observe(document.documentElement,{childList:!0,subtree:!0}),!0)}observeWithMutationEvent(){return addEventListener("DOMNodeInserted",this.processInsertion,!1),!0}findSignificantElements(a){const s=[];return a?.nodeType===Node.ELEMENT_NODE&&(p(a,this.selector)&&s.push(a),s.push(...Array.from(a.querySelectorAll(this.selector)||[]))),s}processMutations(a){const s=[];for(const n of a)if("childList"===n.type)for(const a of n.addedNodes)s.push(...this.findSignificantElements(a)||[]);this.notify(s)}processInsertion(a){const s=this.findSignificantElements(a.target);this.notify(s)}notify(a){a?.length>0&&"function"==typeof this.callback&&this.callback(a)}};const{parseDate:y,strftime:S,getI18nValue:M,config:E}=a,v="time[data-local]:not([data-localized])",T=a=>a.setAttribute("data-localized",""),b=s=>new a.RelativeTime(s);a.Controller=class{constructor(){this.processElements=this.processElements.bind(this),this.pageObserver=new a.PageObserver(v,this.processElements)}start(){this.started||(this.processElements(),this.startTimer(),this.pageObserver.start(),this.started=!0)}startTimer(){let a;(a=E.timerInterval)&&(this.timer||(this.timer=setInterval(this.processElements,a)))}processElements(a){a||(a=document.querySelectorAll(v));for(const s of Array.from(a))this.processElement(s);return a.length}processElement(a){const s=a.getAttribute("datetime"),n=a.getAttribute("data-local"),i=E.useFormat24&&a.getAttribute("data-format24")||a.getAttribute("data-format"),o=y(s);if(!isNaN(o)){if(!a.hasAttribute("title")){const s=E.useFormat24?"default_24h":"default",n=S(o,M(`datetime.formats.${s}`));a.setAttribute("title",n)}(a=>{a.setAttribute("data-processed-at",(new Date).toISOString())})(a),a.textContent=(()=>{switch(n){case"time":return T(a),S(o,i);case"date":return T(a),b(o).toDateString();case"time-ago":return b(o).toString();
3case"time-or-date":return b(o).toTimeOrDateString();case"weekday":return b(o).toWeekdayString();case"weekday-or-date":return b(o).toWeekdayString()||b(o).toDateString()}})()}}};let w=!1;function D(){a.getController().start()}a.start=()=>{var s;w?a.run():(w=!0,"undefined"!=typeof MutationObserver&&null!==MutationObserver||(document.attachEvent?"complete"===document.readyState:"loading"!==document.readyState)?D():(s=D,"function"==typeof requestAnimationFrame?requestAnimationFrame(s):setTimeout(s,17)))},a.processing=()=>a.getController().started,window.LocalTime===a&&a.start();export{a as default}; 4
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.