@commversion/libs 0.4.0 → 0.4.1-pre-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/schedule-event.js +1 -6
- package/package.json +2 -4
package/dist/schedule-event.js
CHANGED
|
@@ -1,6 +1 @@
|
|
|
1
|
-
var
|
|
2
|
-
`);let a=e.trim();if(a=a.toLowerCase(),t.hasOwnProperty(a)===!0||(a=(n=>(n=(n=(n=(n=(n=n.replace(/ time/g,"")).replace(/ (standard|daylight|summer)/g,"")).replace(/\b(east|west|north|south)ern/g,"$1")).replace(/\b(africa|america|australia)n/g,"$1")).replace(/\beuropean/g,"europe")).replace(/\islands/g,"island"))(a),t.hasOwnProperty(a)===!0))return a;if(Ne.hasOwnProperty(a)===!0)return Ne[a];if(/[0-9]/.test(a)===!0){let n=nt(a);if(n)return n}throw new Error("Spacetime: Cannot find timezone named: '"+e+"'. Please enter an IANA timezone id.")},f=(function(e,t){t.isLeapYear=a=>a%4==0&&a%100!=0||a%400==0,t.isDate=a=>Object.prototype.toString.call(a)==="[object Date]"&&!isNaN(a.valueOf()),t.isArray=a=>Object.prototype.toString.call(a)==="[object Array]",t.isObject=a=>Object.prototype.toString.call(a)==="[object Object]",t.isBoolean=a=>Object.prototype.toString.call(a)==="[object Boolean]",t.zeroPad=(a,n=2)=>(a+="").length>=n?a:new Array(n-a.length+1).join("0")+a,t.titleCase=a=>a?a[0].toUpperCase()+a.substr(1):"",t.ordinal=a=>{let n=a%10,r=a%100;return n===1&&r!==11?a+"st":n===2&&r!==12?a+"nd":n===3&&r!==13?a+"rd":a+"th"},t.toCardinal=a=>(a=(a=String(a)).replace(/([0-9])(st|nd|rd|th)$/i,"$1"),parseInt(a,10)),t.normalize=(a="")=>(a=(a=(a=(a=a.toLowerCase().trim()).replace(/ies$/,"y")).replace(/s$/,"")).replace(/-/g,""))==="day"||a==="days"?"date":a==="min"||a==="mins"?"minute":a,t.getEpoch=a=>typeof a=="number"?a:t.isDate(a)?a.getTime():a.epoch?a.epoch:null,t.beADate=(a,n)=>t.isObject(a)===!1?n.clone().set(a):a,t.formatTimezone=(a,n="")=>{const r=a>0?"+":"-",o=Math.abs(a);return`${r}${t.zeroPad(parseInt(""+o,10))}${n}${t.zeroPad(o%1*60)}`}}(de={exports:{}},de.exports),de.exports);f.isLeapYear,f.isDate,f.isArray,f.isObject,f.isBoolean,f.zeroPad,f.titleCase,f.ordinal,f.toCardinal,f.normalize,f.getEpoch,f.beADate,f.formatTimezone;const me={year:new Date().getFullYear(),month:0,date:1};var it={parseArray:(e,t,a)=>{if(t.length===0)return e;let n=["year","month","date","hour","minute","second","millisecond"];for(let r=0;r<n.length;r++){let o=t[r]||a[n[r]]||me[n[r]]||0;e=e[n[r]](o)}return e},parseObject:(e,t,a)=>{if(Object.keys(t).length===0)return e;t=Object.assign({},me,a,t);let n=Object.keys(t);for(let r=0;r<n.length;r++){let o=n[r];if(e[o]===void 0||typeof e[o]!="function"||t[o]===null||t[o]===void 0||t[o]==="")continue;let i=t[o]||a[o]||me[o]||0;e=e[o](i)}return e},parseNumber:function(e,t){return t>0&&t<25e8&&e.silent===!1&&(console.warn(" - Warning: You are setting the date to January 1970."),console.warn(" - did input seconds instead of milliseconds?")),e.epoch=t,e}};const I=function(e){return e.epoch=Date.now(),Object.keys(e._today||{}).forEach(t=>{typeof e[t]=="function"&&(e=e[t](e._today[t]))}),e},pe={now:e=>I(e),today:e=>I(e),tonight:e=>e=(e=I(e)).hour(18),tomorrow:e=>e=(e=(e=I(e)).add(1,"day")).startOf("day"),yesterday:e=>e=(e=(e=I(e)).subtract(1,"day")).startOf("day"),christmas:e=>{let t=I(e).year();return e=e.set([t,11,25,18,0,0])},"new years":e=>{let t=I(e).year();return e=e.set([t,11,31,18,0,0])}};pe["new years eve"]=pe["new years"];var st=pe,ut=function(e){return e=(e=(e=(e=e.replace(/\b(mon|tues?|wed|wednes|thur?s?|fri|sat|satur|sun)(day)?\b/i,"")).replace(/([0-9])(th|rd|st|nd)/,"$1")).replace(/,/g,"")).replace(/ +/g," ").trim()};let D={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:864e5};D.date=D.day,D.month=25488e5,D.week=6048e5,D.year=3154e7,Object.keys(D).forEach(e=>{D[e+"s"]=D[e]});var h=D;const ae=(e,t,a,n,r)=>{let o=e.d[a]();if(o===t)return;let i=r===null?null:e.d[r](),u=e.epoch,c=t-o;e.epoch+=h[n]*c,n==="day"&&Math.abs(c)>28&&t<28&&(e.epoch+=h.hour),r!==null&&i!==e.d[r]()&&(e.epoch=u);const m=h[n]/2;for(;e.d[a]()<t;)e.epoch+=m;for(;e.d[a]()>t;)e.epoch-=m;r!==null&&i!==e.d[r]()&&(e.epoch=u)},fe={year:{valid:e=>e>-4e3&&e<4e3,walkTo:(e,t)=>ae(e,t,"getFullYear","year",null)},month:{valid:e=>e>=0&&e<=11,walkTo:(e,t)=>{let a=e.d,n=a.getMonth(),r=e.epoch,o=a.getFullYear();if(n===t)return;let i=t-n;for(e.epoch+=h.day*(28*i),o!==e.d.getFullYear()&&(e.epoch=r);e.d.getMonth()<t;)e.epoch+=h.day;for(;e.d.getMonth()>t;)e.epoch-=h.day}},date:{valid:e=>e>0&&e<=31,walkTo:(e,t)=>ae(e,t,"getDate","day","getMonth")},hour:{valid:e=>e>=0&&e<24,walkTo:(e,t)=>ae(e,t,"getHours","hour","getDate")},minute:{valid:e=>e>=0&&e<60,walkTo:(e,t)=>ae(e,t,"getMinutes","minute","getHours")},second:{valid:e=>e>=0&&e<60,walkTo:(e,t)=>{e.epoch=e.seconds(t).epoch}},millisecond:{valid:e=>e>=0&&e<1e3,walkTo:(e,t)=>{e.epoch=e.milliseconds(t).epoch}}};var lt=(e,t)=>{let a=Object.keys(fe),n=e.clone();for(let r=0;r<a.length;r++){let o=a[r],i=t[o];if(i===void 0&&(i=n[o]()),typeof i=="string"&&(i=parseInt(i,10)),!fe[o].valid(i))return e.epoch=null,void(e.silent===!1&&console.warn("invalid "+o+": "+i));fe[o].walkTo(e,i)}};let U=["jan","feb","mar","apr","may","jun","jul","aug","sept","oct","nov","dec"],V=["january","february","march","april","may","june","july","august","september","october","november","december"];var C=[31,28,31,30,31,30,31,31,30,31,30,31],s=f,M={short:()=>U,long:()=>V,mapping:()=>function(){const e={sep:8};for(let t=0;t<U.length;t++)e[U[t]]=t;for(let t=0;t<V.length;t++)e[V[t]]=t;return e}(),set:e=>{U=e.short||U,V=e.long||V}},ct=(e,t)=>{if(!t)return e;t!=="Z"&&t!=="z"||(t="+0000");let a=0;/^[\+-]?[0-9]{2}:[0-9]{2}$/.test(t)&&(/:00/.test(t)===!0&&(t=t.replace(/:00/,"")),/:30/.test(t)===!0&&(t=t.replace(/:30/,".5"))),/^[\+-]?[0-9]{4}$/.test(t)&&(t=t.replace(/30$/,".5")),a=parseFloat(t),Math.abs(a)>100&&(a/=100),a*=-1,a>=0&&(a="+"+a);let n="etc/gmt"+a;return e.timezones[n]&&(e.tz=n),e},ht=(e,t="")=>{let a=(t=t.replace(/^\s+/,"").toLowerCase()).match(/([0-9]{1,2}):([0-9]{1,2}):?([0-9]{1,2})?[:\.]?([0-9]{1,4})?/);if(a!==null){let n=Number(a[1]);if(n<0||n>24)return e.startOf("day");let r=Number(a[2]);if(a[2].length<2||r<0||r>59)return e.startOf("day");a[4]>999&&(a[4]=parseInt((""+a[4]).substring(0,3),10)),e=(e=(e=(e=e.hour(n)).minute(r)).seconds(a[3]||0)).millisecond(a[4]||0);let o=t.match(/[\b0-9] ?(am|pm)\b/);return o!==null&&o[1]&&(e=e.ampm(o[1])),e}if(a=t.match(/([0-9]+) ?(am|pm)/),a!==null&&a[1]){let n=Number(a[1]);return n>12||n<1?e.startOf("day"):e=(e=(e=e.hour(a[1]||0)).ampm(a[2])).startOf("hour")}return e=e.startOf("day")};const dt=s.isLeapYear,mt=M.mapping();var l=lt,ne={parseOffset:ct,parseTime:ht,parseYear:(e="",t)=>{if(e=e.trim(),/^'[0-9][0-9]$/.test(e)===!0){let n=Number(e.replace(/'/,""));return n>50?1900+n:2e3+n}let a=parseInt(e,10);return!a&&t&&(a=t.year),a=a||new Date().getFullYear(),a},parseMonth:function(e){return e=e.toLowerCase().trim(),mt[e]},validate:e=>{if(C.hasOwnProperty(e.month)!==!0)return!1;if(e.month===1)return!!(dt(e.year)&&e.date<=29)||e.date<=28;let t=C[e.month]||0;return e.date<=t}};const{validate:ye,parseTime:ge,parseYear:pt,parseMonth:ft,parseOffset:yt}=ne;var gt=[{reg:/^(\-?0?0?[0-9]{3,4})-([0-9]{1,2})-([0-9]{1,2})[T| ]([0-9.:]+)(Z|[0-9\-\+:]+)?$/i,parse:(e,t)=>{let a={year:t[1],month:parseInt(t[2],10)-1,date:t[3]};return ye(a)===!1?(e.epoch=null,e):(yt(e,t[5]),l(e,a),e=ge(e,t[4]))}},{reg:/^([0-9]{4})[\-\/\. ]([0-9]{1,2})[\-\/\. ]([0-9]{1,2})( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i,parse:(e,t)=>{let a={year:t[1],month:parseInt(t[2],10)-1,date:parseInt(t[3],10)};return a.month>=12&&(a.date=parseInt(t[2],10),a.month=parseInt(t[3],10)-1),ye(a)===!1?(e.epoch=null,e):(l(e,a),e=ge(e,t[4]))}},{reg:/^([0-9]{4})[\-\/\. ]([a-z]+)[\-\/\. ]([0-9]{1,2})( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i,parse:(e,t)=>{let a={year:pt(t[1],e._today),month:ft(t[2]),date:s.toCardinal(t[3]||"")};return ye(a)===!1?(e.epoch=null,e):(l(e,a),e=ge(e,t[4]))}}];const{validate:re,parseTime:oe,parseYear:ie,parseMonth:be}=ne;var bt=[{reg:/^([0-9]{1,2})[\-\/.]([0-9]{1,2})[\-\/.]?([0-9]{4})?( [0-9]{1,2}:[0-9]{2}:?[0-9]{0,2}? ?(am|pm|gmt))?$/i,parse:(e,t)=>{let a=parseInt(t[1],10)-1,n=parseInt(t[2],10);(e.british||a>=12)&&(n=parseInt(t[1],10),a=parseInt(t[2],10)-1);let r={date:n,month:a,year:ie(t[3],e._today)||new Date().getFullYear()};return re(r)===!1?(e.epoch=null,e):(l(e,r),e=oe(e,t[4]))}},{reg:/^([a-z]+)[\-\/\. ]([0-9]{1,2})[\-\/\. ]?([0-9]{4}|'[0-9]{2})?( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i,parse:(e,t)=>{let a={year:ie(t[3],e._today),month:be(t[1]),date:s.toCardinal(t[2]||"")};return re(a)===!1?(e.epoch=null,e):(l(e,a),e=oe(e,t[4]))}},{reg:/^([a-z]+) ([0-9]{1,2})( [0-9]{4})?( ([0-9:]+( ?am| ?pm| ?gmt)?))?$/i,parse:(e,t)=>{let a={year:ie(t[3],e._today),month:be(t[1]),date:s.toCardinal(t[2]||"")};return re(a)===!1?(e.epoch=null,e):(l(e,a),e=oe(e,t[4]))}},{reg:/^([a-z]+) ([0-9]{1,2})( [0-9:]+)?( \+[0-9]{4})?( [0-9]{4})?$/i,parse:(e,t)=>{let a={year:ie(t[5],e._today),month:be(t[1]),date:s.toCardinal(t[2]||"")};return re(a)===!1?(e.epoch=null,e):(l(e,a),e=oe(e,t[3]))}}];const{validate:we,parseTime:ke,parseYear:Ie,parseMonth:ve}=ne;var wt=[{reg:/^([0-9]{1,2})[\-\/]([a-z]+)[\-\/]?([0-9]{4})?$/i,parse:(e,t)=>{let a={year:Ie(t[3],e._today),month:ve(t[2]),date:s.toCardinal(t[1]||"")};return we(a)===!1?(e.epoch=null,e):(l(e,a),e=ke(e,t[4]))}},{reg:/^([0-9]{1,2})( [a-z]+)( [0-9]{4}| '[0-9]{2})? ?([0-9]{1,2}:[0-9]{2}:?[0-9]{0,2}? ?(am|pm|gmt))?$/i,parse:(e,t)=>{let a={year:Ie(t[3],e._today),month:ve(t[2]),date:s.toCardinal(t[1])};return a.month&&we(a)!==!1?(l(e,a),e=ke(e,t[4])):(e.epoch=null,e)}},{reg:/^([0-9]{1,2})[\. -/]([a-z]+)[\. -/]([0-9]{4})?( [0-9]{1,2}(:[0-9]{0,2})?(:[0-9]{0,3})? ?(am|pm)?)?$/i,parse:(e,t)=>{let a={date:Number(t[1]),month:ve(t[2]),year:Number(t[3])};return we(a)===!1?(e.epoch=null,e):(l(e,a),e=e.startOf("day"),e=ke(e,t[4]))}}];const{validate:W,parseTime:J,parseYear:Ce,parseMonth:kt}=ne;var ze=[].concat(gt,bt,wt,[{reg:/^([0-9]{4})[\-\/]([0-9]{2})$/i,parse:(e,t)=>{let a={year:t[1],month:parseInt(t[2],10)-1,date:1};return W(a)===!1?(e.epoch=null,e):(l(e,a),e=J(e,t[4]))}},{reg:/^([a-z]+) ([0-9]{4})$/i,parse:(e,t)=>{let a={year:Ce(t[2],e._today),month:kt(t[1]),date:e._today.date||1};return W(a)===!1?(e.epoch=null,e):(l(e,a),e=J(e,t[4]))}},{reg:/^(q[0-9])( of)?( [0-9]{4})?/i,parse:(e,t)=>{let a=t[1]||"";e=e.quarter(a);let n=t[3]||"";return n&&(n=n.trim(),e=e.year(n)),e}},{reg:/^(spring|summer|winter|fall|autumn)( of)?( [0-9]{4})?/i,parse:(e,t)=>{let a=t[1]||"";e=e.season(a);let n=t[3]||"";return n&&(n=n.trim(),e=e.year(n)),e}},{reg:/^[0-9,]+ ?b\.?c\.?$/i,parse:(e,t)=>{let a=t[0]||"";a=a.replace(/^([0-9,]+) ?b\.?c\.?$/i,"-$1");let n=new Date,r={year:parseInt(a.trim(),10),month:n.getMonth(),date:n.getDate()};return W(r)===!1?(e.epoch=null,e):(l(e,r),e=J(e))}},{reg:/^[0-9,]+ ?(a\.?d\.?|c\.?e\.?)$/i,parse:(e,t)=>{let a=t[0]||"";a=a.replace(/,/g,"");let n=new Date,r={year:parseInt(a.trim(),10),month:n.getMonth(),date:n.getDate()};return W(r)===!1?(e.epoch=null,e):(l(e,r),e=J(e))}},{reg:/^[0-9]{4}( ?a\.?d\.?)?$/i,parse:(e,t)=>{let a=e._today;a.month&&!a.date&&(a.date=1);let n=new Date,r={year:Ce(t[0],a),month:a.month||n.getMonth(),date:a.date||n.getDate()};return W(r)===!1?(e.epoch=null,e):(l(e,r),e=J(e))}}]),vt=it,Ae=st,zt=ut,_t=function(e,t,a){for(let n=0;n<ze.length;n++){let r=t.match(ze[n].reg);if(r){let o=ze[n].parse(e,r,a);if(o!==null&&o.isValid())return o}}return e.silent===!1&&console.warn("Warning: couldn't parse date-string: '"+t+"'"),e.epoch=null,e};const{parseArray:jt,parseObject:Ye,parseNumber:Ot}=vt,xe={year:new Date().getFullYear(),month:0,date:1};var $t=(e,t)=>{let a=e._today||xe;if(typeof t=="number")return Ot(e,t);if(e.epoch=Date.now(),e._today&&s.isObject(e._today)&&Object.keys(e._today).length>0){let n=Ye(e,a,xe);n.isValid()&&(e.epoch=n.epoch)}return t==null||t===""?e:s.isDate(t)===!0?(e.epoch=t.getTime(),e):s.isArray(t)===!0?e=jt(e,t,a):s.isObject(t)===!0?t.epoch?(e.epoch=t.epoch,e.tz=t.tz,e):e=Ye(e,t,a):typeof t!="string"?e:(t=zt(t),Ae.hasOwnProperty(t)===!0?e=Ae[t](e):_t(e,t))};let _e=["sun","mon","tue","wed","thu","fri","sat"],je=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],Fe=!0;var g={short:()=>_e,long:()=>je,set:e=>{_e=e.short||_e,je=e.long||je},aliases:{mo:1,tu:2,we:3,th:4,fr:5,sa:6,su:7,tues:2,weds:3,wedn:3,thur:4,thurs:4}},Le={useTitleCase:()=>Fe,set:e=>{Fe=e}},Be=e=>{let t=e.timezone().current.offset;return t?s.formatTimezone(t,":"):"Z"};const S=e=>Le.useTitleCase()?s.titleCase(e):e,B={day:e=>S(e.dayName()),"day-short":e=>S(g.short()[e.day()]),"day-number":e=>e.day(),"day-ordinal":e=>s.ordinal(e.day()),"day-pad":e=>s.zeroPad(e.day()),date:e=>e.date(),"date-ordinal":e=>s.ordinal(e.date()),"date-pad":e=>s.zeroPad(e.date()),month:e=>S(e.monthName()),"month-short":e=>S(M.short()[e.month()]),"month-number":e=>e.month(),"month-ordinal":e=>s.ordinal(e.month()),"month-pad":e=>s.zeroPad(e.month()),"iso-month":e=>s.zeroPad(e.month()+1),year:e=>{let t=e.year();return t>0?t:(t=Math.abs(t),t+" BC")},"year-short":e=>{let t=e.year();return t>0?"'"+String(e.year()).substr(2,4):(t=Math.abs(t),t+" BC")},"iso-year":e=>{let t=e.year(),a=t<0,n=s.zeroPad(Math.abs(t),4);return a&&(n=s.zeroPad(n,6),n="-"+n),n},time:e=>e.time(),"time-24":e=>`${e.hour24()}:${s.zeroPad(e.minute())}`,hour:e=>e.hour12(),"hour-pad":e=>s.zeroPad(e.hour12()),"hour-24":e=>e.hour24(),"hour-24-pad":e=>s.zeroPad(e.hour24()),minute:e=>e.minute(),"minute-pad":e=>s.zeroPad(e.minute()),second:e=>e.second(),"second-pad":e=>s.zeroPad(e.second()),millisecond:e=>e.millisecond(),"millisecond-pad":e=>s.zeroPad(e.millisecond(),3),ampm:e=>e.ampm(),quarter:e=>"Q"+e.quarter(),season:e=>e.season(),era:e=>e.era(),json:e=>e.json(),timezone:e=>e.timezone().name,offset:e=>Be(e),numeric:e=>`${e.year()}/${s.zeroPad(e.month()+1)}/${s.zeroPad(e.date())}`,"numeric-us":e=>`${s.zeroPad(e.month()+1)}/${s.zeroPad(e.date())}/${e.year()}`,"numeric-uk":e=>`${s.zeroPad(e.date())}/${s.zeroPad(e.month()+1)}/${e.year()}`,"mm/dd":e=>`${s.zeroPad(e.month()+1)}/${s.zeroPad(e.date())}`,iso:e=>`${e.format("iso-year")}-${s.zeroPad(e.month()+1)}-${s.zeroPad(e.date())}T${s.zeroPad(e.h24())}:${s.zeroPad(e.minute())}:${s.zeroPad(e.second())}.${s.zeroPad(e.millisecond(),3)}${Be(e)}`,"iso-short":e=>{let t=s.zeroPad(e.month()+1),a=s.zeroPad(e.date());var n;return`${(n=e.year())>=0?s.zeroPad(n,4):(n=Math.abs(n),"-"+s.zeroPad(n,4))}-${t}-${a}`},"iso-utc":e=>new Date(e.epoch).toISOString(),nice:e=>`${M.short()[e.month()]} ${s.ordinal(e.date())}, ${e.time()}`,"nice-24":e=>`${M.short()[e.month()]} ${s.ordinal(e.date())}, ${e.hour24()}:${s.zeroPad(e.minute())}`,"nice-year":e=>`${M.short()[e.month()]} ${s.ordinal(e.date())}, ${e.year()}`,"nice-day":e=>`${g.short()[e.day()]} ${S(M.short()[e.month()])} ${s.ordinal(e.date())}`,"nice-full":e=>`${e.dayName()} ${S(e.monthName())} ${s.ordinal(e.date())}, ${e.time()}`,"nice-full-24":e=>`${e.dayName()} ${S(e.monthName())} ${s.ordinal(e.date())}, ${e.hour24()}:${s.zeroPad(e.minute())}`},Ze={"day-name":"day","month-name":"month","iso 8601":"iso","time-h24":"time-24","time-12":"time","time-h12":"time",tz:"timezone","day-num":"day-number","month-num":"month-number","month-iso":"iso-month","year-iso":"iso-year","nice-short":"nice","nice-short-24":"nice-24",mdy:"numeric-us",dmy:"numeric-uk",ymd:"numeric","yyyy/mm/dd":"numeric","mm/dd/yyyy":"numeric-us","dd/mm/yyyy":"numeric-us","little-endian":"numeric-uk","big-endian":"numeric","day-nice":"nice-day"};Object.keys(Ze).forEach(e=>B[e]=B[Ze[e]]);var Dt=(e,t="")=>{if(e.isValid()!==!0)return"";if(B.hasOwnProperty(t)){let a=B[t](e)||"";return t!=="json"&&(a=String(a),t!=="ampm"&&(a=S(a))),a}if(t.indexOf("{")!==-1){let a=/\{(.+?)\}/g;return t=t.replace(a,(n,r)=>{if(r=r.toLowerCase().trim(),B.hasOwnProperty(r)){let o=String(B[r](e));return r!=="ampm"?S(o):o}return""})}return e.format("iso-short")};const z=s.zeroPad,se=s.formatTimezone,ue={G:e=>e.era(),GG:e=>e.era(),GGG:e=>e.era(),GGGG:e=>e.era()==="AD"?"Anno Domini":"Before Christ",y:e=>e.year(),yy:e=>parseInt(String(e.year()).substr(2,4),10),yyy:e=>e.year(),yyyy:e=>e.year(),yyyyy:e=>"0"+e.year(),Q:e=>e.quarter(),QQ:e=>e.quarter(),QQQ:e=>e.quarter(),QQQQ:e=>e.quarter(),M:e=>e.month()+1,MM:e=>z(e.month()+1),MMM:e=>e.format("month-short"),MMMM:e=>e.format("month"),w:e=>e.week(),ww:e=>z(e.week()),d:e=>e.date(),dd:e=>z(e.date()),D:e=>e.dayOfYear(),DD:e=>z(e.dayOfYear()),DDD:e=>z(e.dayOfYear(),3),E:e=>e.format("day-short"),EE:e=>e.format("day-short"),EEE:e=>e.format("day-short"),EEEE:e=>e.format("day"),EEEEE:e=>e.format("day")[0],e:e=>e.day(),ee:e=>e.day(),eee:e=>e.format("day-short"),eeee:e=>e.format("day"),eeeee:e=>e.format("day")[0],a:e=>e.ampm().toUpperCase(),aa:e=>e.ampm().toUpperCase(),aaa:e=>e.ampm().toUpperCase(),aaaa:e=>e.ampm().toUpperCase(),h:e=>e.h12(),hh:e=>z(e.h12()),H:e=>e.hour(),HH:e=>z(e.hour()),m:e=>e.minute(),mm:e=>z(e.minute()),s:e=>e.second(),ss:e=>z(e.second()),SSS:e=>z(e.millisecond(),3),A:e=>e.epoch-e.startOf("day").epoch,z:e=>e.timezone().name,zz:e=>e.timezone().name,zzz:e=>e.timezone().name,zzzz:e=>e.timezone().name,Z:e=>se(e.timezone().current.offset),ZZ:e=>se(e.timezone().current.offset),ZZZ:e=>se(e.timezone().current.offset),ZZZZ:e=>se(e.timezone().current.offset,":")},P=(e,t,a)=>{let n=e,r=t;for(let o=0;o<a;o+=1)ue[n]=ue[r],n+=e,r+=t};P("q","Q",4),P("L","M",4),P("Y","y",4),P("c","e",4),P("k","H",2),P("K","h",2),P("S","s",2),P("v","z",4),P("V","Z",4);var Mt=(e,t)=>{let a=t.split("");return a=function(n){for(let r=0;r<n.length;r+=1)if(n[r]==="'")for(let o=r+1;o<n.length;o+=1){if(n[o]&&(n[r]+=n[o]),n[o]==="'"){n[o]=null;break}n[o]=null}return n.filter(r=>r)}(a),a=function(n){for(let r=0;r<n.length;r+=1){let o=n[r];for(let i=r+1;i<n.length&&n[i]===o;i+=1)n[r]+=n[i],n[i]=null}return(n=n.filter(r=>r)).map(r=>(r==="''"&&(r="'"),r))}(a),a.reduce((n,r)=>(ue[r]!==void 0?n+=ue[r](e)||"":(/^'.{1,}'$/.test(r)&&(r=r.replace(/'/g,"")),n+=r),n),"")};const St=["year","season","quarter","month","week","day","quarterHour","hour","minute"],He=function(e,t){let a=e.clone().startOf(t),n=e.clone().endOf(t).epoch-a.epoch,r=(e.epoch-a.epoch)/n;return parseFloat(r.toFixed(2))};var Pt=(e,t)=>{if(t)return t=s.normalize(t),He(e,t);let a={};return St.forEach(n=>{a[n]=He(e,n)}),a},Et=(e,t)=>{let a=e.progress();return(t=s.normalize(t))==="quarterhour"&&(t="quarterHour"),a[t]!==void 0?(a[t]>.5&&(e=e.add(1,t)),e=e.startOf(t)):e.silent===!1&&console.warn("no known unit '"+t+"'"),e};const Qe=(e,t,a)=>{let n=0;for(e=e.clone();e.isBefore(t);)e=e.add(1,a),n+=1;return e.isAfter(t,a)&&(n-=1),n};var Oe=(e,t,a)=>e.isBefore(t)?Qe(e,t,a):-1*Qe(t,e,a),qt=function(e,t){let a=t.epoch-e.epoch,n={milliseconds:a,seconds:parseInt(a/1e3,10)};n.minutes=parseInt(n.seconds/60,10),n.hours=parseInt(n.minutes/60,10);let r=e.clone();return n.years=((o,i)=>{let u=i.year()-o.year();return(o=o.year(i.year())).isAfter(i)&&(u-=1),u})(r,t),r=e.add(n.years,"year"),n.months=12*n.years,r=e.add(n.months,"month"),n.months+=Oe(r,t,"month"),n.weeks=52*n.years,r=e.add(n.weeks,"week"),n.weeks+=Oe(r,t,"week"),n.days=7*n.weeks,r=e.add(n.days,"day"),n.days+=Oe(r,t,"day"),n},Tt=function(e,t,a){t=s.beADate(t,e);let n=!1;if(e.isAfter(t)){let o=e;e=t,t=o,n=!0}let r=qt(e,t);return n&&(r=function(o){return Object.keys(o).forEach(i=>{o[i]*=-1}),o}(r)),a?(a=s.normalize(a),/s$/.test(a)!==!0&&(a+="s"),a==="dates"&&(a="days"),r[a]):r};const Ge={months:{almost:10,over:4},days:{almost:25,over:10},hours:{almost:20,over:8},minutes:{almost:50,over:20},seconds:{almost:50,over:20}};function Ue(e,t){return e===1&&(t=t.slice(0,-1)),e+" "+t}var Nt=(e,t)=>{const a=function(u,c){const m=u.isBefore(c),F=m?c:u;let _=m?u:c;_=_.clone();const j={years:0,months:0,days:0,hours:0,minutes:0,seconds:0};return Object.keys(j).forEach(O=>{if(_.isSame(F,O))return;let et=_.diff(F,O);_=_.add(et,O),j[O]=et}),m&&Object.keys(j).forEach(O=>{j[O]!==0&&(j[O]*=-1)}),j}(e,t=s.beADate(t,e));if(Object.keys(a).every(u=>!a[u])===!0)return{diff:a,rounded:"now",qualified:"now",precise:"now"};let n,r,o,i=[];return Object.keys(a).forEach((u,c,m)=>{const F=Math.abs(a[u]);if(F===0)return;const _=Ue(F,u);if(i.push(_),!n){if(n=r=_,c>4)return;const j=m[c+1],O=Math.abs(a[j]);O>Ge[j].almost?(n=Ue(F+1,u),r="almost "+n):O>Ge[j].over&&(r="over "+_)}}),o=i.splice(0,2).join(", "),e.isAfter(t)===!0?(n+=" ago",r+=" ago",o+=" ago"):(n="in "+n,r="in "+r,o="in "+o),{diff:a,rounded:n,qualified:r,precise:o}},w={north:[["spring",2,1],["summer",5,1],["fall",8,1],["autumn",8,1],["winter",11,1]],south:[["fall",2,1],["autumn",2,1],["winter",5,1],["spring",8,1],["summer",11,1]]},A=[null,[0,1],[3,1],[6,1],[9,1]];const Y={minute:e=>(l(e,{second:0,millisecond:0}),e),quarterhour:e=>{let t=e.minutes();return e=t>=45?e.minutes(45):t>=30?e.minutes(30):t>=15?e.minutes(15):e.minutes(0),l(e,{second:0,millisecond:0}),e},hour:e=>(l(e,{minute:0,second:0,millisecond:0}),e),day:e=>(l(e,{hour:0,minute:0,second:0,millisecond:0}),e),week:e=>{let t=e.clone();return(e=e.day(e._weekStart)).isAfter(t)&&(e=e.subtract(1,"week")),l(e,{hour:0,minute:0,second:0,millisecond:0}),e},month:e=>(l(e,{date:1,hour:0,minute:0,second:0,millisecond:0}),e),quarter:e=>{let t=e.quarter();return A[t]&&l(e,{month:A[t][0],date:A[t][1],hour:0,minute:0,second:0,millisecond:0}),e},season:e=>{let t=e.season(),a="north";e.hemisphere()==="South"&&(a="south");for(let n=0;n<w[a].length;n++)if(w[a][n][0]===t){let r=e.year();return t==="winter"&&e.month()<3&&(r-=1),l(e,{year:r,month:w[a][n][1],date:w[a][n][2],hour:0,minute:0,second:0,millisecond:0}),e}return e},year:e=>(l(e,{month:0,date:1,hour:0,minute:0,second:0,millisecond:0}),e),decade:e=>{let t=(e=e.startOf("year")).year(),a=10*parseInt(t/10,10);return e=e.year(a)},century:e=>{let t=(e=e.startOf("year")).year(),a=100*parseInt(t/100,10);return e=e.year(a)}};Y.date=Y.day;var le=ot,$e=Dt,It=Mt,Ct=Pt,At=Et,Yt=Tt,xt=Nt,Ve={startOf:(e,t)=>{let a=e.clone();return t=s.normalize(t),Y[t]?Y[t](a):t==="summer"||t==="winter"?(a=a.season(t),Y.season(a)):a},endOf:(e,t)=>{let a=e.clone();return t=s.normalize(t),Y[t]&&(a=Y[t](a),a=a.add(1,t),a=a.subtract(1,"millisecond")),a}},Ft=function(e,t="",a){if(!t||!a)return[];if(t=s.normalize(t),a=e.clone().set(a),e.isAfter(a)){let o=e;e=a,a=o}let n=e.clone();(function(o){return!!g.short().find(i=>i===o)||!!g.long().find(i=>i===o)})(t)?(n=n.next(t),t="week"):n=n.next(t);let r=[];for(;n.isBefore(a);)r.push(n),n=n.add(1,t);return r},K=e=>{let t=e.timezones,a=e.tz;if(t.hasOwnProperty(a)===!1&&(a=le(e.tz,t)),a===null)return e.silent===!1&&console.warn("Warn: could not find given or local timezone - '"+e.tz+"'"),{current:{epochShift:0}};let n=t[a],r={name:(o=a,o=(o=(o=o[0].toUpperCase()+o.substr(1)).replace(/\/gmt/,"/GMT")).replace(/[\/_]([a-z])/gi,m=>m.toUpperCase())),hasDst:Boolean(n.dst),default_offset:n.offset,hemisphere:n.hem==="s"?"South":"North",current:{}};var o,i;if(r.hasDst){let m=(i=n.dst)?i.split("->"):[];r.change={start:m[0],back:m[1]}}let u=n.offset,c=u;return r.hasDst===!0&&(c=r.hemisphere==="North"?u-1:n.offset+1),r.hasDst===!1?(r.current.offset=u,r.current.isDST=!1):ee(e.epoch,r.change.start,r.change.back,u,c)===!0?(r.current.offset=u,r.current.isDST=r.hemisphere==="North"):(r.current.offset=c,r.current.isDST=r.hemisphere==="South"),r},We=$t;const Lt=["century","decade","year","month","date","day","hour","minute","second","millisecond"],x={set:function(e,t){let a=this.clone();return a=We(a,e),t&&(this.tz=le(t)),a},timezone:function(){return K(this)},isDST:function(){return K(this).current.isDST},hasDST:function(){return K(this).hasDst},offset:function(){return 60*K(this).current.offset},hemisphere:function(){return K(this).hemisphere},format:function(e){return $e(this,e)},unixFmt:function(e){return It(this,e)},startOf:function(e){return Ve.startOf(this,e)},endOf:function(e){return Ve.endOf(this,e)},leapYear:function(){let e=this.year();return s.isLeapYear(e)},progress:function(e){return Ct(this,e)},nearest:function(e){return At(this,e)},diff:function(e,t){return Yt(this,e,t)},since:function(e){return e||(e=this.clone().set()),xt(this,e)},next:function(e){return this.add(1,e).startOf(e)},last:function(e){return this.subtract(1,e).startOf(e)},isValid:function(){return!(!this.epoch&&this.epoch!==0)&&!isNaN(this.d.getTime())},goto:function(e){let t=this.clone();return t.tz=le(e,t.timezones),t},every:function(e,t){if(typeof e=="object"&&typeof t=="string"){let a=t;t=e,e=a}return Ft(this,e,t)},isAwake:function(){let e=this.hour();return!(e<8||e>22)},isAsleep:function(){return!this.isAwake()},daysInMonth:function(){switch(this.month()){case 0:return 31;case 1:return this.leapYear()?29:28;case 2:return 31;case 3:return 30;case 4:return 31;case 5:return 30;case 6:case 7:return 31;case 8:return 30;case 9:return 31;case 10:return 30;case 11:return 31;default:throw new Error("Invalid Month state.")}},log:function(){return console.log(""),console.log($e(this,"nice-short")),this},logYear:function(){return console.log(""),console.log($e(this,"full-short")),this},json:function(){return Lt.reduce((e,t)=>(e[t]=this[t](),e),{})},debug:function(){let e=this.timezone(),t=this.format("MM")+" "+this.format("date-ordinal")+" "+this.year();return t+=`
|
|
3
|
-
- `+this.format("time"),console.log(`
|
|
4
|
-
|
|
5
|
-
`,t+`
|
|
6
|
-
- `+e.name+" ("+e.current.offset+")"),this},from:function(e){return(e=this.clone().set(e)).since(this)},fromNow:function(){return this.clone().set(Date.now()).since(this)},weekStart:function(e){if(typeof e=="number")return this._weekStart=e,this;if(typeof e=="string"){e=e.toLowerCase().trim();let t=g.short().indexOf(e);t===-1&&(t=g.long().indexOf(e)),t===-1&&(t=1),this._weekStart=t}else console.warn("Spacetime Error: Cannot understand .weekStart() input:",e);return this}};x.inDST=x.isDST,x.round=x.nearest,x.each=x.every;var Bt=x;const Zt=s.isLeapYear,E=e=>(typeof e=="string"&&(e=parseInt(e,10)),e),De=["year","month","date","hour","minute","second","millisecond"],Me=(e,t,a)=>{let n=De.indexOf(a),r=De.slice(n,De.length);for(let o=0;o<r.length;o++){let i=t[r[o]]();e[r[o]](i)}return e},q=function(e,t,a,n){return a===!0&&e.isBefore(t)?e=e.add(1,n):a===!1&&e.isAfter(t)&&(e=e.minus(1,n)),e};var p={milliseconds:(e,t)=>{t=E(t);let a=e.millisecond()-t;return e.epoch-a},seconds:(e,t,a)=>{t=E(t);let n=e.clone(),r=(e.second()-t)*h.second;return e.epoch=e.epoch-r,(e=q(e,n,a,"minute")).epoch},minutes:(e,t,a)=>{t=E(t);let n=e.clone(),r=(e.minute()-t)*h.minute;return e.epoch-=r,Me(e,n,"second"),(e=q(e,n,a,"hour")).epoch},hours:(e,t,a)=>{(t=E(t))>=24?t=24:t<0&&(t=0);let n=e.clone(),r=e.hour()-t,o=r*h.hour;return e.epoch-=o,e.date()!==n.date()&&(e=n.clone(),r>1&&(r-=1),r<1&&(r+=1),o=r*h.hour,e.epoch-=o),l(e,{hour:t}),Me(e,n,"minute"),(e=q(e,n,a,"day")).epoch},time:(e,t,a)=>{let n=t.match(/([0-9]{1,2})[:h]([0-9]{1,2})(:[0-9]{1,2})? ?(am|pm)?/);if(!n){if(n=t.match(/([0-9]{1,2}) ?(am|pm)/),!n)return e.epoch;n.splice(2,0,"0"),n.splice(3,0,"")}let r=!1,o=parseInt(n[1],10),i=parseInt(n[2],10);i>=60&&(i=59),o>12&&(r=!0),r===!1&&(n[4]==="am"&&o===12&&(o=0),n[4]==="pm"&&o<12&&(o+=12)),n[3]=n[3]||"",n[3]=n[3].replace(/:/,"");let u=parseInt(n[3],10)||0,c=e.clone();return e=(e=(e=(e=e.hour(o)).minute(i)).second(u)).millisecond(0),(e=q(e,c,a,"day")).epoch},date:(e,t,a)=>{if((t=E(t))>28){let r=e.month(),o=C[r];r===1&&t===29&&Zt(e.year())&&(o=29),t>o&&(t=o)}t<=0&&(t=1);let n=e.clone();return l(e,{date:t}),(e=q(e,n,a,"month")).epoch},month:(e,t,a)=>{typeof t=="string"&&(t=M.mapping()[t.toLowerCase()]),(t=E(t))>=12&&(t=11),t<=0&&(t=0);let n=e.date();n>C[t]&&(n=C[t]);let r=e.clone();return l(e,{month:t,date:n}),(e=q(e,r,a,"year")).epoch},year:(e,t)=>(typeof t=="string"&&/^'[0-9]{2}$/.test(t)&&(t=t.replace(/'/,"").trim(),t=(t=Number(t))>30?1900+t:2e3+t),t=E(t),l(e,{year:t}),e.epoch),week:(e,t,a)=>{let n=e.clone();return t=E(t),(e=(e=(e=e.month(0)).date(1)).day("monday")).monthName()==="december"&&e.date()>=28&&(e=e.add(1,"week")),t-=1,e=e.add(t,"weeks"),(e=q(e,n,a,"year")).epoch},dayOfYear:(e,t,a)=>{t=E(t);let n=e.clone();return(t-=1)<=0?t=0:t>=365&&(t=364),e=(e=e.startOf("year")).add(t,"day"),Me(e,n,"hour"),(e=q(e,n,a,"year")).epoch}};const Je=e=>e=(e=(e=e.minute(0)).second(0)).millisecond(1);var Ht={millisecond:function(e){if(e!==void 0){let t=this.clone();return t.epoch=p.milliseconds(t,e),t}return this.d.getMilliseconds()},second:function(e,t){if(e!==void 0){let a=this.clone();return a.epoch=p.seconds(a,e,t),a}return this.d.getSeconds()},minute:function(e,t){if(e!==void 0){let a=this.clone();return a.epoch=p.minutes(a,e,t),a}return this.d.getMinutes()},hour:function(e,t){let a=this.d;if(e!==void 0){let n=this.clone();return n.epoch=p.hours(n,e,t),n}return a.getHours()},hourFloat:function(e,t){if(e!==void 0){let o=this.clone(),i=e%1;i*=60;let u=parseInt(e,10);return o.epoch=p.hours(o,u,t),o.epoch=p.minutes(o,i,t),o}let a=this.d,n=a.getHours(),r=a.getMinutes();return r/=60,n+r},hour12:function(e,t){let a=this.d;if(e!==void 0){let r=this.clone(),o=(e=""+e).match(/^([0-9]+)(am|pm)$/);if(o){let i=parseInt(o[1],10);o[2]==="pm"&&(i+=12),r.epoch=p.hours(r,i,t)}return r}let n=a.getHours();return n>12&&(n-=12),n===0&&(n=12),n},time:function(e,t){if(e!==void 0){let a=this.clone();return e=e.toLowerCase().trim(),a.epoch=p.time(a,e,t),a}return`${this.h12()}:${s.zeroPad(this.minute())}${this.ampm()}`},ampm:function(e,t){let a="am",n=this.hour();if(n>=12&&(a="pm"),typeof e!="string")return a;let r=this.clone();return e=e.toLowerCase().trim(),n>=12&&e==="am"?(n-=12,r.hour(n,t)):n<12&&e==="pm"?(n+=12,r.hour(n,t)):r},dayTime:function(e,t){if(e!==void 0){const n={morning:"7:00am",breakfast:"7:00am",noon:"12:00am",lunch:"12:00pm",afternoon:"2:00pm",evening:"6:00pm",dinner:"6:00pm",night:"11:00pm",midnight:"23:59pm"};let r=this.clone();return e=(e=e||"").toLowerCase(),n.hasOwnProperty(e)===!0&&(r=r.time(n[e],t)),r}let a=this.hour();return a<6?"night":a<12?"morning":a<17?"afternoon":a<22?"evening":"night"},iso:function(e){return e!==void 0?this.set(e):this.format("iso")}},Qt={date:function(e,t){if(e!==void 0){let a=this.clone();return(e=parseInt(e,10))&&(a.epoch=p.date(a,e,t)),a}return this.d.getDate()},day:function(e,t){if(e===void 0)return this.d.getDay();let a=this.clone(),n=e;typeof e=="string"&&(e=e.toLowerCase(),g.aliases.hasOwnProperty(e)?n=g.aliases[e]:(n=g.short().indexOf(e),n===-1&&(n=g.long().indexOf(e))));let r=this.d.getDay()-n;t===!0&&r>0&&(r-=7),t===!1&&r<0&&(r+=7);let o=this.subtract(r,"days");return l(o,{hour:a.hour(),minute:a.minute(),second:a.second()}),o},dayName:function(e,t){if(e===void 0)return g.long()[this.day()];let a=this.clone();return a=a.day(e,t),a}},Gt={dayOfYear:function(e,t){if(e!==void 0){let o=this.clone();return o.epoch=p.dayOfYear(o,e,t),o}let a,n=0,r=this.d.getMonth();for(let o=1;o<=r;o++)a=new Date,a.setDate(1),a.setFullYear(this.d.getFullYear()),a.setHours(1),a.setMinutes(1),a.setMonth(o),a.setHours(-2),n+=a.getDate();return n+this.d.getDate()},week:function(e,t){if(e!==void 0){let u=this.clone();return u.epoch=p.week(this,e,t),u=Je(u),u}let a=this.clone();a=a.month(0),a=a.date(1),a=Je(a),a=a.day("monday"),a.monthName()==="december"&&a.date()>=28&&(a=a.add(1,"week"));let n=1;a.date()===1&&(n=0),a=a.minus(1,"second");const r=this.epoch;if(a.epoch>r)return 1;let o=0,i=4*this.month();for(a.epoch+=h.week*i,o+=i;o<=52;o++){if(a.epoch>r)return o+n;a=a.add(1,"week")}return 52},month:function(e,t){if(e!==void 0){let a=this.clone();return a.epoch=p.month(a,e,t),a}return this.d.getMonth()},monthName:function(e,t){if(e!==void 0){let a=this.clone();return a=a.month(e,t),a}return M.long()[this.month()]},quarter:function(e,t){if(e!==void 0&&(typeof e=="string"&&(e=e.replace(/^q/i,""),e=parseInt(e,10)),A[e])){let n=this.clone(),r=A[e][0];return n=n.month(r,t),n=n.date(1,t),n=n.startOf("day"),n}let a=this.d.getMonth();for(let n=1;n<A.length;n++)if(a<A[n][0])return n-1;return 4},season:function(e,t){let a="north";if(this.hemisphere()==="South"&&(a="south"),e!==void 0){let r=this.clone();for(let o=0;o<w[a].length;o++)e===w[a][o][0]&&(r=r.month(w[a][o][1],t),r=r.date(1),r=r.startOf("day"));return r}let n=this.d.getMonth();for(let r=0;r<w[a].length-1;r++)if(n>=w[a][r][1]&&n<w[a][r+1][1])return w[a][r][0];return"winter"},year:function(e){if(e!==void 0){let t=this.clone();return t.epoch=p.year(t,e),t}return this.d.getFullYear()},era:function(e){if(e!==void 0){let t=this.clone();e=e.toLowerCase();let a=t.d.getFullYear();return e==="bc"&&a>0&&(t.epoch=p.year(t,-1*a)),e==="ad"&&a<0&&(t.epoch=p.year(t,-1*a)),t}return this.d.getFullYear()<0?"BC":"AD"},decade:function(e){if(e!==void 0){if(!(e=(e=(e=String(e)).replace(/([0-9])'?s$/,"$1")).replace(/([0-9])(th|rd|st|nd)/,"$1")))return console.warn("Spacetime: Invalid decade input"),this;e.length===2&&/[0-9][0-9]/.test(e)&&(e="19"+e);let t=Number(e);return isNaN(t)?this:(t=10*Math.floor(t/10),this.year(t))}return this.startOf("decade").year()},century:function(e){if(e!==void 0){typeof e=="string"&&(e=(e=(e=e.replace(/([0-9])(th|rd|st|nd)/,"$1")).replace(/([0-9]+) ?(b\.?c\.?|a\.?d\.?)/i,(n,r,o)=>(o.match(/b\.?c\.?/i)&&(r="-"+r),r))).replace(/c$/,""));let a=Number(e);return isNaN(e)?(console.warn("Spacetime: Invalid century input"),this):(a===0&&(a=1),a=a>=0?100*(a-1):100*(a+1),this.year(a))}let t=this.startOf("century").year();return t=Math.floor(t/100),t<0?t-1:t+1},millenium:function(e){if(e!==void 0){if(typeof e=="string"&&(e=e.replace(/([0-9])(th|rd|st|nd)/,"$1"),e=Number(e),isNaN(e)))return console.warn("Spacetime: Invalid millenium input"),this;e>0&&(e-=1);let a=1e3*e;return a===0&&(a=1),this.year(a)}let t=Math.floor(this.year()/1e3);return t>=0&&(t+=1),t}};const d=Object.assign({},Ht,Qt,Gt);d.milliseconds=d.millisecond,d.seconds=d.second,d.minutes=d.minute,d.hours=d.hour,d.hour24=d.hour,d.h12=d.hour12,d.h24=d.hour24,d.days=d.day;var Ut=e=>{Object.keys(d).forEach(t=>{e.prototype[t]=d[t]})};const Vt=s.isLeapYear,Se=function(e,t){return e===1&&Vt(t)?29:C[e]};var Pe={months:(e,t)=>{if(e.month>0){let a=parseInt(e.month/12,10);e.year=t.year()+a,e.month=e.month%12}else if(e.month<0){let a=Math.floor(Math.abs(e.month)/13,10);a=Math.abs(a)+1,e.year=t.year()-a,e.month=e.month%12,e.month=e.month+12,e.month===12&&(e.month=0)}return e},days:(e,t,a)=>{let n=t.year(),r=t.month(),o=Se(r,n);for(;a>o;)a-=o,r+=1,r>=12&&(r-=12,n+=1),o=Se(r,n);return e.month=r,e.date=a,e},daysBack:(e,t,a)=>{e.year=t.year(),e.month=t.month();let n=t.date();for(e.date=n-Math.abs(a);e.date<1;){e.month-=1,e.month<0&&(e.month=11,e.year-=1);let r=Se(e.month,e.year);e.date+=r}return e}};const k=["millisecond","second","minute","hour","date","month"];let T={second:k.slice(0,1),minute:k.slice(0,2),quarterhour:k.slice(0,2),hour:k.slice(0,3),date:k.slice(0,4),month:k.slice(0,4),quarter:k.slice(0,4),season:k.slice(0,4),year:k,decade:k,century:k};T.week=T.hour,T.season=T.date,T.quarter=T.date;const Wt={year:!0,quarter:!0,season:!0,month:!0,week:!0,date:!0},Jt={month:!0,quarter:!0,season:!0,year:!0};var Kt=e=>{e.prototype.add=function(t,a){let n=this.clone();if(!a||t===0)return n;let r=this.clone();if((a=s.normalize(a))==="millisecond")return n.epoch+=t,n;a==="fortnight"&&(t*=2,a="week"),h[a]?n.epoch+=h[a]*t:a==="week"||a==="weekend"?n.epoch+=h.day*(7*t):a==="quarter"||a==="season"?n.epoch+=h.month*(3*t):a==="quarterhour"&&(n.epoch+=15*h.minute*t);let o={};if(T[a]&&T[a].forEach(i=>{o[i]=r[i]()}),Wt[a]){const i=r.timezone().current.offset-n.timezone().current.offset;n.epoch+=3600*i*1e3}if(a==="month"&&(o.month=r.month()+t,o=Pe.months(o,r)),a==="week"){let i=r.date()+7*t;i<=28&&i>1&&(o.date=i)}if(a==="weekend"&&n.dayName()!=="saturday")n=n.day("saturday",!0);else if(a==="date"){if(t<0)o=Pe.daysBack(o,r,t);else{let i=r.date()+t;o=Pe.days(o,r,i)}t!==0&&r.isSame(n,"day")&&(o.date=r.date()+t)}else if(a==="quarter"){if(o.month=r.month()+3*t,o.year=r.year(),o.month<0){let i=Math.floor(o.month/12),u=o.month+12*Math.abs(i);o.month=u,o.year+=i}else if(o.month>=12){let i=Math.floor(o.month/12);o.month=o.month%12,o.year+=i}o.date=r.date()}else if(a==="year"){let i=r.year()+t,u=n.year();if(u<i){let c=Math.floor(t/4)||1;n.epoch+=Math.abs(h.day*c)}else if(u>i){let c=Math.floor(t/4)||1;n.epoch+=h.day*c}}else a==="decade"?o.year=n.year()+10:a==="century"&&(o.year=n.year()+100);if(Jt[a]){let i=C[o.month];o.date=r.date(),o.date>i&&(o.date=i)}return Object.keys(o).length>1&&l(n,o),n},e.prototype.subtract=function(t,a){return this.clone().add(-1*t,a)},e.prototype.minus=e.prototype.subtract,e.prototype.plus=e.prototype.add};const R={millisecond:e=>e.epoch,second:e=>[e.year(),e.month(),e.date(),e.hour(),e.minute(),e.second()].join("-"),minute:e=>[e.year(),e.month(),e.date(),e.hour(),e.minute()].join("-"),hour:e=>[e.year(),e.month(),e.date(),e.hour()].join("-"),day:e=>[e.year(),e.month(),e.date()].join("-"),week:e=>[e.year(),e.week()].join("-"),month:e=>[e.year(),e.month()].join("-"),quarter:e=>[e.year(),e.quarter()].join("-"),year:e=>e.year()};R.date=R.day;var Rt=e=>{const t={isAfter:function(a){a=s.beADate(a,this);let n=s.getEpoch(a);return n===null?null:this.epoch>n},isBefore:function(a){a=s.beADate(a,this);let n=s.getEpoch(a);return n===null?null:this.epoch<n},isEqual:function(a){a=s.beADate(a,this);let n=s.getEpoch(a);return n===null?null:this.epoch===n},isBetween:function(a,n,r=!1){a=s.beADate(a,this),n=s.beADate(n,this);let o=s.getEpoch(a);if(o===null)return null;let i=s.getEpoch(n);return i===null?null:r?this.isBetween(a,n)||this.isEqual(a)||this.isEqual(n):o<this.epoch&&this.epoch<i}};Object.keys(t).forEach(a=>{e.prototype[a]=t[a]})},Xt=e=>{const t={i18n:a=>{s.isObject(a.days)&&g.set(a.days),s.isObject(a.months)&&M.set(a.months),s.isBoolean(a.useTitleCase)&&Le.set(a.useTitleCase)}};Object.keys(t).forEach(a=>{e.prototype[a]=t[a]})},ea=L,Ke=Bt,ta=Ut,aa=Kt,na=e=>{e.prototype.isSame=function(t,a,n=!0){let r=this;if(!a)return null;if(typeof t=="string"&&typeof a=="object"){let o=t;t=a,a=o}return typeof t!="string"&&typeof t!="number"||(t=new e(t,this.timezone.name)),a=a.replace(/s$/,""),n===!0&&r.tz!==t.tz&&((t=t.clone()).tz=r.tz),R[a]?R[a](r)===R[a](t):null}},ra=Rt,oa=Xt;let Ee=Te;const v=function(e,t,a={}){this.epoch=null,this.tz=le(t,Ee),this.silent=a.silent||!0,this.british=a.dmy||a.british,this._weekStart=1,a.weekStart!==void 0&&(this._weekStart=a.weekStart),this._today={},a.today!==void 0&&(this._today=a.today),Object.defineProperty(this,"d",{get:function(){let r=ea(this),o=(new Date(this.epoch).getTimezoneOffset()||0)+60*r;o=60*o*1e3;let i=this.epoch+o;return new Date(i)}}),Object.defineProperty(this,"timezones",{get:()=>Ee,set:r=>(Ee=r,r)});let n=We(this,e);this.epoch=n.epoch};Object.keys(Ke).forEach(e=>{v.prototype[e]=Ke[e]}),v.prototype.clone=function(){return new v(this.epoch,this.tz,{silent:this.silent,weekStart:this._weekStart,today:this._today,parsers:this.parsers})},v.prototype.toLocalDate=function(){return this.toNativeDate()},v.prototype.toNativeDate=function(){return new Date(this.epoch)},ta(v),aa(v),na(v),ra(v),oa(v);var b=v,ia=(e,t)=>{let a=new b(null),n=new b(null);a=a.time(e),n=t?n.time(t):a.add(59,"minutes");let r=a.hour(),o=n.hour();return Object.keys(a.timezones).filter(i=>{if(i.indexOf("/")===-1)return!1;let u=new b(null,i),c=u.hour();return c>=r&&c<=o&&!(c===r&&u.minute()<a.minute())&&!(c===o&&u.minute()>n.minute())})};const y=(e,t,a)=>new b(e,t,a),ce=function(e){let t=e._today||{};return Object.keys(t).forEach(a=>{e=e[a](t[a])}),e};y.now=(e,t)=>{let a=new b(new Date().getTime(),e,t);return a=ce(a),a},y.today=(e,t)=>{let a=new b(new Date().getTime(),e,t);return a=ce(a),a.startOf("day")},y.tomorrow=(e,t)=>{let a=new b(new Date().getTime(),e,t);return a=ce(a),a.add(1,"day").startOf("day")},y.yesterday=(e,t)=>{let a=new b(new Date().getTime(),e,t);return a=ce(a),a.subtract(1,"day").startOf("day")},y.extend=function(e={}){return Object.keys(e).forEach(t=>{b.prototype[t]=e[t]}),this},y.timezones=function(){return new b().timezones},y.max=function(e,t){let a=new b(null,e,t);return a.epoch=864e13,a},y.min=function(e,t){let a=new b(null,e,t);return a.epoch=-864e13,a},y.whereIts=ia,y.version="6.16.3",y.plugin=y.extend;var sa=y;const ua=()=>{},qe=(e,t,a)=>e*1440+t*60+a;var la=(e,t)=>e.reverse().reduce((n,{from:r,to:o,callback:i})=>{const u=qe(r[0],r[1],r[2]),c=qe(o[0],o[1],o[2]),m=qe(t[0],t[1],t[2]);return u<=m&&m<c?i:n},ua);const ca=(e,t)=>tt(this,null,function*(){const a=sa(new Date,t,{weekStart:0});yield la(e,[a.day(),a.hour(),a.minute()])()});window.commversion=window.commversion||{};const{schedule:Re,timezone:Xe}=window.commversion;[Re,Xe].forEach(e=>{if(typeof e=="undefined")throw new Error("Invalid configuration")}),ca(Re,Xe)})();
|
|
1
|
+
var w=(u,t,o)=>new Promise((d,i)=>{var r=c=>{try{e(o.next(c))}catch(n){i(n)}},a=c=>{try{e(o.throw(c))}catch(n){i(n)}},e=c=>c.done?d(c.value):Promise.resolve(c.value).then(r,a);e((o=o.apply(u,t)).next())});(function(){"use strict";const u=()=>{},t=(e,c,n)=>e*1440+c*60+n;var o=(e,c)=>e.reverse().reduce((l,{from:s,to:v,callback:h})=>{const p=t(s[0],s[1],s[2]),f=t(v[0],v[1],v[2]),m=t(c[0],c[1],c[2]);return p<=m&&m<f?h:l},u);const d="https://commversion-public-functions.vercel.app/api/time",i=(e,c)=>w(this,null,function*(){const n=yield fetch(`${d}?tz=${c}`).then(s=>s.json());yield o(e,[n.day,n.hour,n.minute])()});window.commversion=window.commversion||{};const{schedule:r,timezone:a}=window.commversion;[r,a].forEach(e=>{if(typeof e=="undefined")throw new Error("Invalid configuration")}),i(r,a)})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commversion/libs",
|
|
3
|
-
"version": "0.4.0",
|
|
3
|
+
"version": "0.4.1-pre-0",
|
|
4
4
|
"author": "Marios Antonoudiou <mariosant@sent.com>",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"scripts": {
|
|
@@ -39,9 +39,7 @@
|
|
|
39
39
|
"sinon": "^12.0.1",
|
|
40
40
|
"vite": "^2.7.3"
|
|
41
41
|
},
|
|
42
|
-
"dependencies": {
|
|
43
|
-
"spacetime": "^6.16.3"
|
|
44
|
-
},
|
|
42
|
+
"dependencies": {},
|
|
45
43
|
"volta": {
|
|
46
44
|
"node": "16.13.2"
|
|
47
45
|
}
|