dynamic-html-helpers 1.4.3 → 1.4.5
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/Bundle/htmlhelpers.min.js +13 -13
- package/Bundle/htmlhelpers.script.js +466 -479
- package/Bundle/htmlhelpers.script.min.js +13 -13
- package/README.md +7 -1
- package/Resource/Externals/ticktock.min.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
var[Z,w,q,H]=["2-digit","numeric","long","short"],C={fixed:{MM:{month:q},M:{month:H},m:{month:w},mm:{month:Z},yyyy:{year:w},yy:{year:Z},WD:{weekday:q},wd:{weekday:H},d:{day:w},dd:{day:Z},h:{hour:w},hh:{hour:Z},mi:{minute:w},mmi:{minute:Z},s:{second:w},ss:{second:Z},ms:{fractionalSecondDigits:3},tz:{timeZoneName:"shortOffset"},dl:{locale:"default"},h12:{hour12:!1},yn:{yearName:""},ry:{relatedYear:!0},msp:{fractionalSecond:!0}},dynamic:{tzn:e=>({timeZoneName:e.slice(4)}),hrc:e=>({hourCycle:`h${e.slice(4)}`}),ds:e=>({dateStyle:e.slice(3)}),ts:e=>({timeStyle:e.slice(3)}),tz:e=>({timeZone:e.slice(3)}),e:e=>({era:e.slice(2)}),l:e=>({locale:e.slice(2)})}},b={...C,retrieveDynamic(e){let r=e?.slice(0,e?.indexOf(":"));return C.dynamic[r]&&C.dynamic[r](e)},get re(){return new RegExp(`\\b(${Object.keys(C.fixed).join("|")})\\b`,"g")}},v=xe;function xe(e,r,n="l:default"){return/ds:|ts:/.test(n)?Pe(e,me(void 0),n):Ee(e,me(r||void 0),n)}function me(e="dtf"){let r=` ${e.replace(/[{}]/g,"").trim()} `,n=e.match(/(?<=\{)(.+?)(?=})/g)||[];return{set formatStr(t){r=t},get formatStr(){return r},get units(){return r.match(b.re)||[]},finalize(t="",a="",o="",s=""){return r.replace(/~([\d+]?)/g,"$1").replace(/dtf/,t).replace(/era/,o).replace(/dp\b|~dp\b/,a).replace(/yn\b/,s).replace(/\[(\d+?)]/g,(u,l)=>n[l].trim()).trim()}}}function fe(...e){return e?.reduce((r,n)=>({...r,...b.retrieveDynamic(n)||b.fixed[n]}),b.fixed.dl)}function Pe(e,r,n){let t=fe(...de(n).split(",")),a=Intl.DateTimeFormat(t.locale,t).format(e);return r.finalize(a)}function Ye(e,r){return e==="numeric"&&r.startsWith("0")?r.slice(1):r}function Ee(e,r,n){let t=fe(...r.units.concat(de(n).split(",")).flat()),a={...b.fixed},o=Intl.DateTimeFormat(t.locale,t).formatToParts(e).reduce((s,u)=>u.type==="literal"&&/[ ,/-]/.test(u.value)?s:{...s,[u.type]:Ye(t[u.type],u.value)},{});return a.ms=t.fractionalSecondDigits?a.msp:a.ms,a.yyyy=o.relatedYear?a.ry:a.yyyy,r.formatStr=r.formatStr.replace(b.re,s=>/^(M|MM)$/.test(s)?Ve(e,t.locale,t.timeZone,/^M$/.test(s)):o[Object.keys(a[s]).shift()]||s),r.finalize(void 0,o.dayPeriod,o.era,o.yearName)}function Ve(e,r,n,t){return e.toLocaleString(r,{timeZone:n,month:t?H:q})}function de(e){return e.replace(/\s+/g,"")}var ge=qe;function qe(){let e=(t,a)=>{let o=isNaN(new Date(t)),s=isNaN(new Date(a));if(s){let[u,l,i]=Array(3).fill("end date not valid");return{error:!0,message:u,full:l,clean:i}}if(o){let[u,l,i]=Array(3).fill("start date not valid");return{error:!0,message:u,full:l,clean:i}}if(o&&!s){let[u,l,i]=Array(3).fill("start- and/or end date are not valid");return{error:!0,message:u,full:l,clean:i}}return{error:!1}},r=n();return function({start:t,end:a,diffs:o={}}={}){let s=e(t,a),u=a>t?"+":"-";if(s.error)return s;let l=Math.abs(t-a),i=new Date(l),c=i.getUTCFullYear()-1970,d=i.getUTCMonth(),h=i.getUTCDate()-1,F=h%7,le=Math.floor(h/7),p=i.getUTCHours(),$=i.getUTCMinutes(),S=i.getUTCSeconds(),Le=i.getUTCMilliseconds(),je=Math.floor(l/864e5);o={...o,fromUTC:t,toUTC:a,sign:"",years:c,months:d,days:h,hours:p,minutes:$,seconds:S,milliseconds:Le,diffInDays:je},o.full=r({values:o,full:!0}),o.clean=r({values:o}),o.equalDates=o.clean==="Dates are equal";let ce=p+$+S>0?"T":"";return o.clean!=="Dates are equal"&&(o.sign=u,o.jsPeriod=`${u}P${c>0?`${c}Y`:""}${d>0?`${d}M`:""}${le>0?`${le}W`:""}${F>0?`${F}D`:""}${ce}${p>0?`${p}H`:""}${$>0?`${$}M`:""}${S>0?`${S}S`:""}`,o.ISOPeriod=`P${c>0?`${c}Y`:""}${d>0?`${d}M`:""}${h>0?`${h}D`:""}${ce}${p>0?`${p}H`:""}${$>0?`${$}M`:""}${S>0?`${S}S`:""}`),o};function n(){let t=(...i)=>c=>i.reduce((d,h)=>h(d),c),a=(i,c)=>i===1?c.slice(0,-1):c;return t(({values:i,full:c})=>[Object.entries(i).filter(([d])=>/^(years|month|days|hours|minutes|seconds)/i.test(d)),c],([i,c])=>c?i:i.filter(([,d])=>c?+d:d>0),i=>i.reduce((c,[d,h])=>[...c,`${h} ${a(h,d)}`],[]),i=>i.length<1?"Dates are equal":`${i.slice(0,-1).join(", ")}${i.length>1?" and ":""}${i.slice(-1).shift()}`)}}var ye=He;function He(){let e=Object.entries({year:"FullYear",month:"Month",date:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds",millisecond:"Milliseconds"}).reduce((t,[a,o])=>({...t,[a]:o,[`${a}s`]:o}),{}),r=!1,n=function(...t){let a=t.length===1;return r=t[0].trim().startsWith("subtract,"),r&&(t=a?t[0].trim().replace(/^subtract,/i,"").split(",").map(o=>o.trim()):t.filter(o=>!o.startsWith("subtract"))),a&&!r&&(t=t[0].split(",").map(o=>o.trim())),t.map(function(o){if(!o)return!1;let s=o.toLowerCase().split(/ {1,}/);return s.length<2?!1:s.map(u=>{u=`${u}`.trim().replace(/[^a-z0-9-+]/g,"");let l=parseInt(u,10);return Number.isNaN(l)?u:r?-l:+l})}).filter(o=>o)};return function(t,...a){if(a.length<1)return t;let o=n(...a);return o.length&&o.forEach(([s,u])=>{u=u,u=e[u],s&&u&&t[`set${u}`](t[`get${u}`]()+s)}),t}}var $e=ge(),Se=Re(),D=ye(),Ge=["sun","mon","tue","wed","thu","fri","sat"],Ze=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function G(e,...r){return D(e,...r),e}function we(e,r=!1){let n=R(e.clone,{sunday:r}),t=[n];return{weekStart:n.format("WD","l:en-GB"),inputDate:e,dates:t.concat([...Array(6)].map((a,o)=>n.clone.addDays(o+1)))}}function W(e,{start:r,end:n,future:t,past:a,include:o={start:!1,end:!1}}={}){let s=e.clone.UTC;return r=r?.value||r?.constructor===Date?m(r?.value||r).UTC:m.now.UTC,n=n&&n?.value||n?.constructor===Date?m(n?.value||n).UTC:m.now.UTC,s.milliseconds=0,r.milliseconds=0,n.milliseconds=0,t?r>n:a?r<n:(o.start?+s>=+r:+s>+r)&&(o.end?+s<=+n:+s<+n)}function _(e,{zoneTime:r=!1,formatStr:n,moreOptions:t}={}){return t=r?e.localeInfo.formatOptions+(t?`,${t}`:""):f.formatOptions+(t?`,${t}`:""),r?(e.localeInfo||(e.localeInfo=f),v(e,n,t)):_e(e,n,t)}function _e(e,r,n){let t=e.clone.relocate(f);return n=(n||"").startsWith("+")?`${t.localeInfo.formatOptions},${n.slice(1)}`:n||t.localeInfo.formatOptions,v(t,r,n)}function be(e,r){let n=$e({start:e,end:r||e});return parseInt(`${n.sign}${n.diffInDays}`)}function B(e,r=!1){let{locale:n,timeZone:t}=r?e.localeInfo:f,a=ue(n,t),o=e.format("MM|WD",a).split("|");return{locale:n,timeZone:t,monthName:o[0],dayName:o[1],dayNames:se(n),monthNames:Y(n)}}function J(e,r=!1){let[n,t,a,o]=U(e,r),u={values4Timezone:r?f.timeZone:e.timeZone,hours:n,minutes:t,seconds:a,milliseconds:o};return Object.freeze(u)}function U(e,r=!1){let t=`l:en-CA,${r?`tz:${f.timeZone}`:`tz:${e.timeZone}`},hrc:23,ts:medium`;return e.format("",t).split(/:/).map(Number).concat(e.getMilliseconds())}function K(e,r){let n=r?`tz:${f.timeZone}`:`,tz:${e.timeZone}`,[t,a,o]=e.format("yyyy-mm-dd",n).split(/-/).map(Number);a-=1;let s=r?f.timeZone:e.timeZone;return Object.freeze({values4Timezone:s,year:t,month:a,date:o})}function Q(e,r=!0){if(r)return[e.getFullYear(),e.getMonth(),e.getDate()];let n=e.format("yyyy-m-d",e.localeInfo.formatOptions).split(/-/).map(Number);return n[1]-=1,n}function Be(e){let r=new Intl.Locale(e.localeInfo.locale),n=r.getWeekInfo&&r.getWeekInfo().firstDay||1;return n=n===7?0:n,Ze[n]}function R(e,{sunday:r=!1}={}){let n=r?"sunday":Be(e);return j(e,{day:n,preserveTodayWhenEqual:!0})}function Je(e,r){let n=e.toString().match(/GMT([+-])\d+/)?.[0]?.slice(3)??"+0000",t=r.toString().match(/GMT([+-])\d+/)?.[0]?.slice(3)??"+0000";return n=A(n.slice(0,3)+":"+n.slice(-2),!0),t=A(t.slice(0,3)+":"+t.slice(-2),!0),[-n[0]+t[0],-n[1]+t[1]].map(a=>n[0]<0?-a:a)}function X({start:e,end:r}={}){r||(r=e.clone),r?.clone||(r=m(r,{timeZone:e.timeZone})),e=m(Te(e,e.timeZone),{timeZone:e.timeZone}),r=m(Te(r,r.timeZone),{timeZone:r.timeZone});let n=$e({start:e,end:r,diffs:{timeZoneStart:e.timeZone,timeZoneEnd:r.timeZone}}),t=Je(r,e),a=n.sign.startsWith("-")?"ahead of":"behind",[o,s]=t.map(i=>Math.abs(i)),[u,l]=[`${o} ${k(o,"hour")}`,`${s} ${k(s,"minute")}`];return n.timeZonesOffsetDifference=n.sign.length<1||o+s===0?`Offsets of ${e.timeZone} and ${r.timeZone} are equal`:`${e.timeZone} is ${u}${s>0?` and ${l}`:""} ${a} ${r.timeZone}`,n}function ee(e,r){r=String(r).toLowerCase()==="utc"||r.timeZone==="UTC"?e.clone.relocate({timeZone:"UTC"}):m(e.value,{timeZone:r.timeZone||f.timeZone});let t=X({start:e.clone,end:r}),o=`${t.sign}${he(t.hours)}:${he(t.minutes)}`;return{fromTZ:e.timeZone,toTZ:r.timeZone,offset:o,offsetText:`${r.timeZone} ${Ke(o)} ${e.timeZone}`}}function he(e,r=2){return`${e}`.padStart(r,"0")}function k(e,r){return`${r}${e>1||e===0?"s":""}`}function Ke(e){if(/00:00/.test(e))return"no time diffence to";let r=e.slice(1).split(":").map(Number),[n,t]=r,a=k(n,"hour"),o=k(t,"minute"),s=e.startsWith("+");return t>0?`${n} ${a} and ${t} ${o} ${s?"ahead of":"behind"}`:`${n} ${a} ${s?"ahead of":"behind"}`}function De(e,r,n){return e.clone.format(r,n||e.localeInfo.formatOptions)}function ve(e,{withFormat:r,withFormatOptions:n,local:t=!1}={}){if(r)return t?De(e,r,$D.localeInformation.formatOptions):De(e,r,n);let a=e.clone.relocate({locale:"en"}),o=t?f.formatOptions:a.localeInfo.formatOptions,u=`wd M dd yyyy hh:mmi:ss ${a.format("tz",o+",tzn:longOffset").replace(":","")} (tz)`;return a.format(u,o+",tzn:long, hrc:23")}function te(e,r=!1){let n=Intl.DateTimeFormat("en",{timeZone:r?e.timeZone:f.timeZone,weekday:"short"});return Se(n.format(e))}function Ne(e){let r=f,n=e.localeInfo,t=e.clone.relocate({locale:r.locale,timeZone:r.timeZone}),a=e.offsetFrom(t),o=t.offsetFrom(e),s=r,u=n,l=e.format("hh:mmi:ss dp",`hrc:12,tz:${e.timeZone}`),i=t.format("hh:mmi:ss dp",`hrc:12,tz:${t.timeZone}`),c={note:"'user' are values for your locale/timeZone, 'remote' (if applicable) idem for the instance",locales:{user:{locale:s.locale,timeZone:s.timeZone}},dateTime:{user:{...e.dateTime,monthName:t.monthName,weekdayNr:t.day,weekdayName:t.dayName,dayPeriodTime:i,hasDST:t.hasDST,DSTActive:t.DSTActive,offsetFromRemote:a.offset,string:t.toString()}},offset:{fromUTC:e.UTC.offsetFrom(e).offsetText}};return n.timeZone!==r.timeZone&&(c.locales.remote={locale:u.locale,timeZone:u.timeZone},c.dateTime.remote={...e.zoneDateTime,monthName:e.zoneNames.monthName,weekdayNr:te(e,!0),weekdayName:e.zoneNames.dayName,dayPeriodTime:l,hasDST:e.hasDST,DSTActive:e.DSTActive,offsetFromUser:o.offset,string:e.toString()},c.offset.fromUserTime=o.offsetText),c}function z(e,r=!0){if(r)return[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];let n=e.format("yyyy-m-d-hh-mmi-ss",`${e.localeInfo.formatOptions},hrc23:true`).split(/-/).map(Number).concat(e.getMilliseconds());return n[1]-=1,n}function re(e){return new Date(e.year,e.month+1,0,0,0,0).getDate()}function L(e,r){r=g({locale:r||e.localeInfo.locale}).locale;let n=e.clone.relocate({locale:r});return n.date={date:1},[n].concat([...Array(re(n)-1)].map((t,a)=>n.clone.add(`${a+1} days`)))}function j(e,{day:r,next:n=!1,preserveTodayWhenEqual:t=!1}={}){r=r?.toLowerCase()||"-";let a=Se(r);if(a<0)return console.error(`[TickTock instance].next/previous invalid day value ${r}`),e.clone;let o=n?1:-1,s=m(new Date(...e.dateTimeValues),e.localeInfo);return t&&a===s.day?s:Qe(s.addDays(n?1:-1),a,o)}function Qe(e,r,n){function t(a){switch(!0){case a.day===r:return a;default:return t(a.add(`${n} days`))}}return t(e)}function O(e,{dateOnly:r=!1,timeOnly:n=!1}={}){let{locale:t,timeZone:a}=e.localeInfo;return r?new Date(e).toLocaleDateString(t,{timeZone:a}):n?new Date(e).toLocaleTimeString(t,{timeZone:a}):new Date(e).toLocaleString(t,{timeZone:a})}function Te(e,r){let n={timeZone:r,hourCycle:"h23"};return new Date(new Date(e).toLocaleString("en",n))}function N(e,{year:r,month:n,date:t}={}){return y(r)&&e.setFullYear(parseInt(r)),y(t)&&e.setDate(parseInt(t)),y(n)&&e.setMonth(parseInt(n)),e}function T(e,{hours:r,minutes:n,seconds:t,milliseconds:a}={}){return y(r)&&e.setHours(parseInt(r)),y(n)&&e.setMinutes(parseInt(n)),y(t)&&e.setSeconds(parseInt(t)),y(a)&&e.setMilliseconds(parseInt(a)),e}function Ie(e){return e?.constructor===Date||e?.value}function ne(e,r){return Ie(r)?m(r?.value||r,e.localeInfo):m.from(...e.dateTimeValues).relocate(e.localeInfo)}function Re(){return function(e){e=`${e}`.toLowerCase();let r=Ge.indexOf(e);return r<0?Ze.indexOf(e):r}}function A(e){let r=e.slice(1).split(/[-:]/).map(Number),n=e.startsWith("-");return r=r.map(t=>n?-t:t),r}function ze(e){return e.time={hours:0,minutes:0,seconds:0,milliseconds:0},e}function pe(e,r){return Intl.DateTimeFormat("en-CA",{timeZone:r,timeZoneName:"long"}).format(e).split(/,/)[1].trim()}function x(e,r){r=r||e?.timeZone||f.timeZone,e=e?.value?e:e?.constructor===Date?m(e,{timeZone:r}):m({timeZone:r});let n=e.year||e.getFullYear(),t=pe(new Date(n,0,1),r),a=pe(new Date(n,5,1),r);return t!==a}function P(e,r){return r=r||e?.timeZone||f.timeZone,e=e?.hasDST?e:e?.constructor===Date?m(e,{timeZone:r}):m({timeZone:r}),e.hasDST?!/standard/i.test(e.toString()):!1}function Oe(e,{locale:r,timeZone:n,l:t,tz:a}={}){return e.localeInfo=g({locale:t||r||e.l||e.locale,timeZone:a||n||e.tz||e.timeZone}),e}function Me(e,r){return Ie(r)&&(e=m(r.value||r,r.localeInfo||e.localeInfo)),e}function M(e,r){let n=ae(new Date(e,11,r||31));return n===1?M(e,(r||31)-1):n}function oe(e,r){let n=e.month;switch(!0){case n<3:return r?1:"First";case n<6:return r?2:"Second";case n<9:return r?3:"Third";case n<12:return r?4:"Fourth";default:return"unknown"}}function ae(e){let r=new Date(e),n=(r.getDay()+6)%7;r.setDate(r.getDate()-n+3);let t=r.valueOf();return r.setMonth(0,1),r.getDay()!==4&&r.setMonth(0,1+(4-r.getDay()+7)%7),1+Math.ceil((t-r)/6048e5)}var E=Xe;function Xe({localeInfo:e,customMethods:r,dateValue:n}={}){let t,a={add(...o){return G(t,...o)},between({start:o,end:s,include:u}={}){return W(t,{start:o,end:s,include:u})},cloneWith(o){return ne(t,o)},daysUntil(o){return be(t,o)},differenceTo(o){return X({start:t,end:o})},differenceUntil(o){return t.differenceTo(o).clean},firstWeekday({sunday:o=!1,midnight:s=!1}={}){return R(t,{sunday:o,midnight:s})},format(o,s){return _(t,{formatStr:o,moreOptions:s})},fullMonth(o){return L(t,o)},fullWeek(o=!1){return we(t,!!o)},isFuture(o){return W(t,{start:t,end:o,future:!0})},isPast(o){return W(t,{start:t,end:o,past:!0})},next(o,s){return j(t,{day:o,next:!0,preserveTodayWhenEqual:!!s})},offsetFrom(o){return ee(t,o)},previous(o,s){return j(t,{day:o,next:!1,preserveTodayWhenEqual:!!s})},relocate({locale:o,timeZone:s,l:u,tz:l}={}){return Oe(t,{locale:o,timeZone:s,l:u,tz:l})},revalue(o){return t=Me(t,o),t},setDateValues({year:o,month:s,date:u}={}){return N(t,{year:o,month:s,date:u})},setTimeValues({hours:o,minutes:s,seconds:u,milliseconds:l}={}){return T(t,{hours:o,minutes:s,seconds:u,milliseconds:l})},subtract(...o){return G(t,"subtract,"+o.join(","))},toArray(o=!1){return z(t,o)},toString({template:o,formatOptions:s,local:u}={}){return ve(t,{withFormat:o,withFormatOptions:s,local:u})},values(o=!1){return o?t.dateTime:t.zoneDateTime},zoneFormat(o,s){return _(t,{zoneTime:!0,formatStr:o,moreOptions:s})},set date({year:o,month:s,date:u}){N(t,{year:o,month:s,date:u})},set dateNr(o){N(t,{date:o})},set hours(o){T(t,{hours:o})},set localeInfo({locale:o,timeZone:s,l:u,tz:l}){e=I({locale:o,timeZone:s,l:u,tz:l})},set milliseconds(o){T(t,{milliseconds:`${o}`})},set minutes(o){T(t,{minutes:o})},set month(o){N(t,{month:o})},set seconds(o){T(t,{seconds:o})},set time({hours:o,minutes:s,seconds:u,milliseconds:l}){T(t,{hours:o,minutes:s,seconds:u,milliseconds:l})},set year(o){N(t,{year:o})},get age(){return t.differenceTo(new Date).years},get ageFull(){return t.differenceTo(new Date).clean},get clone(){return ne(t)},get date(){return K(t,!0)},get dateNr(){return t.date.date},get dateTime(){return{...t.date,...t.time}},get dateTimeValues(){return z(t,!0)},get dateValues(){return Q(t,!0)},get day(){return t.getDay()},get dayName(){return t.names.dayName},get daysThisMonth(){return re(t)},get DSTActive(){return P(t)},get hasDST(){return x(t)},get hours(){return t.time.hours},get info(){return Ne(t)},get isLeapYear(){return new Date(t.getFullYear(),2,0).getDate()===29},get ISO(){return t.toISOString()},get local(){return O(t)},get localDate(){return O(t,{dateOnly:!0})},get locale(){return(e||I()).locale},get localeInfo(){return e},get localeString(){return O(t)},get localTime(){return O(t,{timeOnly:!0})},get milliseconds(){return t.getMilliseconds()},get minutes(){return t.time.minutes},get month(){return t.date.month},get monthName(){return t.names.monthName},get names(){return B(t)},get quarter(){return oe(t)},get quarterNr(){return oe(t,!0)},get removeTime(){return ze(t)},get seconds(){return t.time.seconds},get time(){return J(t,!0)},get timeValues(){return U(t,!0)},get timeZone(){return(e||I()).timeZone},get unixEpochTimestamp(){return Math.floor(+t/1e3)},get userLocaleInfo(){return f},get UTC(){return t.clone.relocate({locale:t.locale,timeZone:"UTC"})},get UTCOffset(){return ee(t,"UTC")},get value(){return new Date(t)},get weeknr(){return ae(t)},get weeksInYear(){return M(t.year,31)},get year(){return t.date.year},get zoneDate(){return K(t,!1)},get zoneDateNr(){return t.zoneDate.date},get zoneDateTime(){return{...t.zoneDate,...t.zoneTime}},get zoneDateTimeValues(){return z(t,!1)},get zoneDateValues(){return Q(t,!1)},get zoneDay(){return te(t,!0)},get zoneDayname(){return t.zoneNames.dayName},get zoneHours(){return t.zoneTime.hours},get zoneMinutes(){return t.zoneTime.minutes},get zoneMonth(){return t.zoneDate.month},get zoneMonthname(){return t.zoneNames.monthName},get zoneNames(){return B(t,!0)},get zoneSeconds(){return t.zoneTime.seconds},get zoneTime(){return J(t)},get zoneTimeValues(){return U(t)},get zoneYear(){return t.zoneDate.year},get zoneValues(){return t.zoneDateTime},get zoneArray(){return z(t,!1)}};return!e&&!n?a:(a.localeInfo=e||I(),t=new Proxy(n,et(a)),Object.entries(Object.getOwnPropertyDescriptors(ie(t,r))).forEach(([o,s])=>Object.defineProperty(a,o,s)),Object.freeze(t))}function et(e){return{get(r,n){return n!=="toString"&&n in r?r[n].bind(r):Reflect.get(e,n)},set(r,n,t){return n in e&&Reflect.set(e,n,t)}}}var f=ke(Intl.DateTimeFormat().resolvedOptions()),tt=Object.getOwnPropertyNames(Date.prototype).filter(e=>e.startsWith("set")).reduce((e,r)=>[...e,{native:r,syn:"change"+r.slice(3)}],[]);function se(e="en-GB"){return e=g({locale:e}).locale,{long:[...Array(7).keys()].map(r=>new Date(Date.UTC(1970,0,4+r)).toLocaleDateString(e,{timeZone:"Etc/UTC",weekday:"long"})),short:[...Array(7).keys()].map(r=>new Date(Date.UTC(1970,0,4+r)).toLocaleDateString(e,{timeZone:"Etc/UTC",weekday:"short"}))}}function Y(e="en"){return e=g({locale:e}).locale,{long:[...Array(12).keys()].map(r=>new Date(Date.UTC(1970,r,1)).toLocaleDateString(e,{timeZone:"Etc/UTC",month:"long"})),short:[...Array(12).keys()].map(r=>new Date(Date.UTC(1970,r,1)).toLocaleDateString(e,{timeZone:"Etc/UTC",month:"short"}))}}function rt({year:e,locale:r}={}){e=y(e)?parseInt(e):new Date().getFullYear();let n={year:e,calendar:{}},t=Y().long.map(a=>a.toLowerCase());for(let a=0;a<12;a+=1){let o=m.from(e,a,1);n.calendar[t[a]]=L(o,r)}return n}function nt({year:e,monthNr:r,locale:n="en-CA"}={}){e=y(r)&&parseInt(e)||-1,r=y(r)&&parseInt(r)||new Date().getFullYear();let t=r>=1&&r<=12;return n=g({locale:n}).locale,r=t?r-1:void 0,t?m.from(e,r,1).relocate({locale:n}).fullMonth(n):"MonthNr should be a specific number (1 = january - 12 = december)"}function ke(e){let r=ue(e.locale,e.timeZone),n=new Intl.Locale(e.locale);return e.weekInfo=n.getWeekInfo?n.getWeekInfo():null,Object.defineProperty(e,"formatOptions",{value:r,enumerable:!1})}function ue(e,r){return[`${e&&!(Array.isArray(e)&&e.length<1)?`l:${e}`:""}`,`${r?`tz:${r}`:""}`].filter(n=>n).join(",")}function g({locale:e,timeZone:r,l:n,tz:t}={}){return r=r||t,e=e||n,e=Ce({trial:function(){return Intl.DateTimeFormat(e,{timeZone:f.timeZone}).resolvedOptions().locale},onError:function(){return console.warn(`Intl locale "${e}" best fit impossible, using "${f.locale}"`),f.locale}}),r=Ce({trial:function(){return Intl.DateTimeFormat(e,{timeZone:r}).resolvedOptions().timeZone},onError:function(){return console.warn(`timeZone "${r}" not valid. Using "${f.timeZone}"`),f.timeZone}}),ke(Intl.DateTimeFormat(e,{timeZone:r}).resolvedOptions())}function I({locale:e,timeZone:r,l:n,tz:t}={}){return g({locale:e,timeZone:r,l:n,tz:t},!0)}function Fe(e){return!Number.isNaN(+e)&&e?.constructor===Date&&!e?.toISOString?.().startsWith("1970-01-01T00:00:00")?e:new Date}function Ae(e){let r=new Date;switch(!0){case e?.constructor===String:return Fe(new Date(e));case(Array.isArray(e)&&e.map(Number).length===e.length):return e.length===1?new Date(e[0],0,1):new Date(...e);case e?.constructor===Date:return Fe(e);default:return r}}function Ce({trial:e,onError:r=()=>{}}={}){if(e?.constructor===Function)try{return e()}catch(n){return r?.constructor===Function?r(n):void 0}}function ot({timeZoneDate:e,timeZoneID:r,userTimeZoneID:n}={}){let t={timeZone:g({timeZone:r}).timeZone},a={timeZone:g({timeZone:n||""}).timeZone},o=m(e,t),s=m(e,a),u=s.differenceTo(o),l=o.offsetFrom(s).offset,[i,c]=A(l,!0),d=s.clone.add(`${i} hours, ${c} minutes`),F=u.equalDates?"No difference":`Time offset ${l}: ${a.timeZone} is ${u.clean} ${i<0?"behind":"ahead of"} ${t.timeZone}`;return{remoteTimezone:t.timeZone,userTimezone:a.timeZone,timeDifference:F,result:{[t.timeZone.replace(/\//,"_")]:m(e).toString({template:"yyyy/mm/dd hh:mmi:ss",formatOptions:"hrc:23"}),[a.timeZone.replace(/\//,"_")]:d.toString({template:"yyyy/mm/dd hh:mmi:ss",formatOptions:"hrc:23"})}}}function y(e){return!Number.isNaN(parseInt(e))}function V(e,r,n){return e?.constructor===Number?D(r,`${e} ${n}`):r}function at(e){let r={addYears(n=1){return V(n,e,"years")},addMonths(n=1){return V(n,e,"months")},addWeeks(n=1){return n=n?.constructor===Number?n*7:1,V(n,e,"days")},addDays(n=1){return V(n,e,"days")},get nextYear(){return D(e,"1 year")},get nextWeek(){return D(e,"7 days")},get previousWeek(){return D(e,"-7 days")},get previousYear(){return D(e,"-1 year")},get nextMonth(){return D(e,"1 month")},get previousMonth(){return D(e,"-1 month")},get tomorrow(){return D(e,"1 day")},get yesterday(){return D(e,"-1 day")}};for(let n of tt)r[n.syn]=function(...t){return e[n.native](...t),e};return r}function ie(e,r){let n=at(e);for(let[t,a]of Object.entries(r||{})){let o=a.enumerable,s=a.isGetter?{get(){return a.method(e)},enumerable:o}:{value(...u){return a.method(e,...u)},enumerable:o};Object.defineProperty(n,t,s)}return n}function We(e,r){return Object.defineProperties(e,{now:{get(){return e(new Date)}},localeInformation:{get(){return g()}},localWeekdaynames:{value(n){return se(n)}},localMonthnames:{value(n){return Y(n)}},daysInMonth:{value(n,t=!1){return n=y(n)?parseInt(n):0,n>=1&&n<=12?new Date(t?2e3:2005,n,0).getDate():`${n} should be a Number between (1 (january) - 12 (december))`}},yearCalendar:{value:rt},monthCalendar:{value:nt},from:{value(...n){return e(n)}},fromUxTS:{value(n,t){n=y(n)?parseInt(n)*1e3:void 0;let a=n?new Date(n):new Date;return m(a,t||f)}},hasDST:{value({date:n,timeZone:t}={}){return x(n,t)}},DSTActive:{value({date:n,timeZone:t}={}){return P(n,t)}},values:{value({date:n,timeZone:t}={}){n=n||n?.value||new Date;let a=v(n,"yyyy-m-d-h-mi-s",g({timeZone:t}).formatOptions.concat(",hrc:23")).split("-").map(Number).concat(n.getMilliseconds());return a[1]-=1,a}},format:{value({date:n,template:t,timeZone:a,locale:o,opts:s}={}){n=n||n?.value||new Date,t=t?.constructor===String?t:"yyyy/mm/dd hh:mmi:ss dp";let u=g({timeZone:a,locale:o}).formatOptions;return u+=s?`,${s}`:"",v(n,t,u)}},addCustom:{value({name:n,method:t,enumerable:a=!1,isGetter:o=!1}={}){n?.constructor===String&&t?.constructor===Function&&t.length>0&&(r[n]={method:t,enumerable:a,isGetter:o})}},validateLocaleInformation:{value:g},timeAcrossZones:{value:ot},weeksInYear:{value(n){return M(n,31)}},keys:{get(){let n=Object.fromEntries(Object.entries(r).filter(([a,o])=>o.enumerable===!0));return[...Object.keys(E()),...Object.keys(ie()),...Object.keys(n)].sort((a,o)=>a.localeCompare(o))}}}),e}var Ue={},m=We(st,Ue);function st(e,r){if(e?.localeInfo)return e.clone;let n=e?.locale||e?.timeZone||e?.tz||e?.l;return E({localeInfo:g(n?e:r),dateValue:new Date(n?Date.now():Ae(e)),customMethods:Ue})}export{m as default};
|
|
1
|
+
var I=Fe();function Fe(){let[e,r,n,t]=["2-digit","numeric","long","short"],a={fixed:{MM:{month:n},M:{month:t},m:{month:r},mm:{month:e},yyyy:{year:r},yy:{year:e},WD:{weekday:n},wd:{weekday:t},d:{day:r},dd:{day:e},h:{hour:r},hh:{hour:e},mi:{minute:r},mmi:{minute:e},s:{second:r},ss:{second:e},ms:{fractionalSecondDigits:3},tz:{timeZoneName:"shortOffset"},dl:{locale:"default"},h12:{hour12:!1},yn:{yearName:""},ry:{relatedYear:!0},msp:{fractionalSecond:!0}},dynamic:{tzn:i=>({timeZoneName:i.slice(4)}),hrc:i=>({hourCycle:`h${i.slice(4)}`}),ds:i=>({dateStyle:i.slice(3)}),ts:i=>({timeStyle:i.slice(3)}),tz:i=>({timeZone:i.slice(3)}),e:i=>({era:i.slice(2)}),l:i=>({locale:i.slice(2)})}},o={...a,retrieveDyn(i){let y=i?.slice(0,i.indexOf(":"));return a.dynamic[y]&&a.dynamic[y](i)},get re(){return new RegExp(`\\b(${Object.keys(a.fixed).join("|")})\\b`,"g")}},s=(i="dtf",y=0)=>{let h=` ${i.replace(/(?<=\{)(.+?)(?=})/g,d=>`[${y++}]`).replace(/[{}]/g,"").trim()} `,D=i.match(/(?<=\{)(.+?)(?=})/g)||[];return{get texts(){return D},formatString(d){h=d},set formatStr(d){h=d},get formatStr(){return h},get units(){return h.match(o.re)||[]},finalize(d="",b="",v="",$=""){return h.replace(/~([\d+]?)/g,"$1").replace(/dtf/,d).replace(/era/,v).replace(/dp\b|~dp\b/,b).replace(/yn\b/,$).replace(/\[(\d+?)]/g,(S,Me)=>D[Me].trim()).trim()}}},u=i=>i.replace(/\s+/g,""),c=(...i)=>i?.reduce((y,h)=>({...y,...o.retrieveDyn(h)||o.fixed[h]}),o.fixed.dl),l=(i,y,h)=>{let D=c(...u(h).split(",")),d=Intl.DateTimeFormat(D.locale,D).format(i);return y.finalize(d)},m=(i,y,h,D)=>i.toLocaleString(y,{timeZone:h,month:D?t:n}),T=(i,y,h)=>{let D=c(...y.units.concat(u(h).split(",")).flat()),d={...o.fixed},b=($,S)=>D[$]==="numeric"&&S.startsWith("0")?S.slice(1):S,v=Intl.DateTimeFormat(D.locale,D).formatToParts(i).reduce(($,S)=>S.type==="literal"&&/[ ,/-]/.test(S.value)?$:{...$,[S.type]:b(S.type,S.value)},{});return d.ms=D.fractionalSecondDigits?d.msp:d.ms,d.yyyy=v.relatedYear?d.ry:d.yyyy,y.formatStr=y.formatStr.replace(o.re,$=>/^(M|MM)$/.test($)?m(i,D.locale,D.timeZone,/^M$/.test($)):v[Object.keys(d[$]).shift()]||$),y.finalize(void 0,v.dayPeriod,v.era,v.yearName)};return(i,y,h="l:default")=>/ds:|ts:/.test(h)?l(i,s(void 0),h):T(i,s(y||void 0),h)}var ue=Ce;function Ce(){let e=(t,a)=>{let o=isNaN(new Date(t)),s=isNaN(new Date(a));if(s){let[u,c,l]=Array(3).fill("end date not valid");return{error:!0,message:u,full:c,clean:l}}if(o){let[u,c,l]=Array(3).fill("start date not valid");return{error:!0,message:u,full:c,clean:l}}if(o&&!s){let[u,c,l]=Array(3).fill("start- and/or end date are not valid");return{error:!0,message:u,full:c,clean:l}}return{error:!1}},r=n();return function({start:t,end:a,diffs:o={}}={}){let s=e(t,a),u=a>t?"+":"-";if(s.error)return s;let c=Math.abs(t-a),l=new Date(c),m=l.getUTCFullYear()-1970,T=l.getUTCMonth(),i=l.getUTCDate()-1,y=i%7,h=Math.floor(i/7),D=l.getUTCHours(),d=l.getUTCMinutes(),b=l.getUTCSeconds(),v=l.getUTCMilliseconds(),$=Math.floor(c/864e5);o={...o,fromUTC:t,toUTC:a,sign:"",years:m,months:T,days:i,hours:D,minutes:d,seconds:b,milliseconds:v,diffInDays:$},o.full=r({values:o,full:!0}),o.clean=r({values:o}),o.equalDates=o.clean==="Dates are equal";let S=D+d+b>0?"T":"";return o.clean!=="Dates are equal"&&(o.sign=u,o.jsPeriod=`${u}P${m>0?`${m}Y`:""}${T>0?`${T}M`:""}${h>0?`${h}W`:""}${y>0?`${y}D`:""}${S}${D>0?`${D}H`:""}${d>0?`${d}M`:""}${b>0?`${b}S`:""}`,o.ISOPeriod=`P${m>0?`${m}Y`:""}${T>0?`${T}M`:""}${i>0?`${i}D`:""}${S}${D>0?`${D}H`:""}${d>0?`${d}M`:""}${b>0?`${b}S`:""}`),o};function n(){let t=(...l)=>m=>l.reduce((T,i)=>i(T),m),a=(l,m)=>l===1?m.slice(0,-1):m;return t(({values:l,full:m})=>[Object.entries(l).filter(([T])=>/^(years|month|days|hours|minutes|seconds)/i.test(T)),m],([l,m])=>m?l:l.filter(([,T])=>m?+T:T>0),l=>l.reduce((m,[T,i])=>[...m,`${i} ${a(i,T)}`],[]),l=>l.length<1?"Dates are equal":`${l.slice(0,-1).join(", ")}${l.length>1?" and ":""}${l.slice(-1).shift()}`)}}var ie=ke;function ke(){let e=Object.entries({year:"FullYear",month:"Month",date:"Date",day:"Date",hour:"Hours",minute:"Minutes",second:"Seconds",millisecond:"Milliseconds"}).reduce((t,[a,o])=>({...t,[a]:o,[`${a}s`]:o}),{}),r=!1,n=function(...t){let a=t.length===1;return r=t[0].trim().startsWith("subtract,"),r&&(t=a?t[0].trim().replace(/^subtract,/i,"").split(",").map(o=>o.trim()):t.filter(o=>!o.startsWith("subtract"))),a&&!r&&(t=t[0].split(",").map(o=>o.trim())),t.map(function(o){if(!o)return!1;let s=o.toLowerCase().split(/ {1,}/);return s.length<2?!1:s.map(u=>{u=`${u}`.trim().replace(/[^a-z0-9-+]/g,"");let c=parseInt(u,10);return Number.isNaN(c)?u:r?-c:+c})}).filter(o=>o)};return function(t,...a){if(a.length<1)return t;let o=n(...a);return o.length&&o.forEach(([s,u])=>{u=u,u=e[u],s&&u&&t[`set${u}`](t[`get${u}`]()+s)}),t}}var de=ue(),ge=Pe(),w=ie(),Ae=["sun","mon","tue","wed","thu","fri","sat"],ye=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];function q(e,...r){return w(e,...r),e}function he(e,r=!1){let n=K(e.clone,{sunday:r}),t=[n];return{weekStart:n.format("WD","l:en-GB"),inputDate:e,dates:t.concat([...Array(6)].map((a,o)=>n.clone.addDays(o+1)))}}function W(e,{start:r,end:n,future:t,past:a,include:o={start:!1,end:!1}}={}){let s=e.clone.UTC;return r=r?.value||r?.constructor===Date?f(r?.value||r).UTC:f.now.UTC,n=n&&n?.value||n?.constructor===Date?f(n?.value||n).UTC:f.now.UTC,s.milliseconds=0,r.milliseconds=0,n.milliseconds=0,t?r>n:a?r<n:(o.start?+s>=+r:+s>+r)&&(o.end?+s<=+n:+s<+n)}function H(e,{zoneTime:r=!1,formatStr:n,moreOptions:t}={}){return t=r?e.localeInfo.formatOptions+(t?`,${t}`:""):g.formatOptions+(t?`,${t}`:""),r?(e.localeInfo||(e.localeInfo=g),I(e,n,t)):We(e,n,t)}function We(e,r,n){let t=e.clone.relocate(g);return n=(n||"").startsWith("+")?`${t.localeInfo.formatOptions},${n.slice(1)}`:n||t.localeInfo.formatOptions,I(t,r,n)}function De(e,r){let n=de({start:e,end:r||e});return parseInt(`${n.sign}${n.diffInDays}`)}function _(e,r=!1){let{locale:n,timeZone:t}=r?e.localeInfo:g,a=ae(n,t),o=e.format("MM|WD",a).split("|");return{locale:n,timeZone:t,monthName:o[0],dayName:o[1],dayNames:oe(n),monthNames:Y(n)}}function G(e,r=!1){let[n,t,a,o]=U(e,r),u={values4Timezone:r?g.timeZone:e.timeZone,hours:n,minutes:t,seconds:a,milliseconds:o};return Object.freeze(u)}function U(e,r=!1){let t=`l:en-CA,${r?`tz:${g.timeZone}`:`tz:${e.timeZone}`},hrc:23,ts:medium`;return e.format("",t).split(/:/).map(Number).concat(e.getMilliseconds())}function B(e,r){let n=r?`tz:${g.timeZone}`:`,tz:${e.timeZone}`,[t,a,o]=e.format("yyyy-mm-dd",n).split(/-/).map(Number);a-=1;let s=r?g.timeZone:e.timeZone;return Object.freeze({values4Timezone:s,year:t,month:a,date:o})}function J(e,r=!0){if(r)return[e.getFullYear(),e.getMonth(),e.getDate()];let n=e.format("yyyy-m-d",e.localeInfo.formatOptions).split(/-/).map(Number);return n[1]-=1,n}function Ue(e){let r=new Intl.Locale(e.localeInfo.locale),n=r.getWeekInfo&&r.getWeekInfo().firstDay||1;return n=n===7?0:n,ye[n]}function K(e,{sunday:r=!1}={}){let n=r?"sunday":Ue(e);return x(e,{day:n,preserveTodayWhenEqual:!0})}function Le(e,r){let n=e.toString().match(/GMT([+-])\d+/)?.[0]?.slice(3)??"+0000",t=r.toString().match(/GMT([+-])\d+/)?.[0]?.slice(3)??"+0000";return n=A(n.slice(0,3)+":"+n.slice(-2),!0),t=A(t.slice(0,3)+":"+t.slice(-2),!0),[-n[0]+t[0],-n[1]+t[1]].map(a=>n[0]<0?-a:a)}function Q({start:e,end:r}={}){r||(r=e.clone),r?.clone||(r=f(r,{timeZone:e.timeZone})),e=f(me(e,e.timeZone),{timeZone:e.timeZone}),r=f(me(r,r.timeZone),{timeZone:r.timeZone});let n=de({start:e,end:r,diffs:{timeZoneStart:e.timeZone,timeZoneEnd:r.timeZone}}),t=Le(r,e),a=n.sign.startsWith("-")?"ahead of":"behind",[o,s]=t.map(l=>Math.abs(l)),[u,c]=[`${o} ${k(o,"hour")}`,`${s} ${k(s,"minute")}`];return n.timeZonesOffsetDifference=n.sign.length<1||o+s===0?`Offsets of ${e.timeZone} and ${r.timeZone} are equal`:`${e.timeZone} is ${u}${s>0?` and ${c}`:""} ${a} ${r.timeZone}`,n}function R(e,r){r=String(r).toLowerCase()==="utc"||r.timeZone==="UTC"?e.clone.relocate({timeZone:"UTC"}):f(e.value,{timeZone:r.timeZone||g.timeZone});let t=Q({start:e.clone,end:r}),o=`${t.sign}${le(t.hours)}:${le(t.minutes)}`;return{fromTZ:e.timeZone,toTZ:r.timeZone,offset:o,offsetText:`${r.timeZone} ${xe(o)} ${e.timeZone}`}}function le(e,r=2){return`${e}`.padStart(r,"0")}function k(e,r){return`${r}${e>1||e===0?"s":""}`}function xe(e){if(/00:00/.test(e))return"no time diffence to";let r=e.slice(1).split(":").map(Number),[n,t]=r,a=k(n,"hour"),o=k(t,"minute"),s=e.startsWith("+");return t>0?`${n} ${a} and ${t} ${o} ${s?"ahead of":"behind"}`:`${n} ${a} ${s?"ahead of":"behind"}`}function ce(e,r,n){return e.clone.format(r,n||e.localeInfo.formatOptions)}function Te(e,{withFormat:r,withFormatOptions:n,local:t=!1}={}){if(r)return t?ce(e,r,$D.localeInformation.formatOptions):ce(e,r,n);let a=e.clone.relocate({locale:"en"}),o=t?g.formatOptions:a.localeInfo.formatOptions,u=`wd M dd yyyy hh:mmi:ss ${a.format("tz",o+",tzn:longOffset").replace(":","")} (tz)`;return a.format(u,o+",tzn:long, hrc:23")}function X(e,r=!1){let n=Intl.DateTimeFormat("en",{timeZone:r?e.timeZone:g.timeZone,weekday:"short"});return ge(n.format(e))}function pe(e){let r=g,n=e.localeInfo,t=e.clone.relocate({locale:r.locale,timeZone:r.timeZone}),a=e.offsetFrom(t),o=t.offsetFrom(e),s=r,u=n,c=e.format("hh:mmi:ss dp",`hrc:12,tz:${e.timeZone}`),l=t.format("hh:mmi:ss dp",`hrc:12,tz:${t.timeZone}`),m={note:"'user' are values for your locale/timeZone, 'remote' (if applicable) idem for the instance",locales:{user:{locale:s.locale,timeZone:s.timeZone}},dateTime:{user:{...e.dateTime,monthName:t.monthName,weekdayNr:t.day,weekdayName:t.dayName,dayPeriodTime:l,hasDST:t.hasDST,DSTActive:t.DSTActive,offsetFromRemote:a.offset,string:t.toString()}},offset:{fromUTC:e.UTC.offsetFrom(e).offsetText}};return n.timeZone!==r.timeZone&&(m.locales.remote={locale:u.locale,timeZone:u.timeZone},m.dateTime.remote={...e.zoneDateTime,monthName:e.zoneNames.monthName,weekdayNr:X(e,!0),weekdayName:e.zoneNames.dayName,dayPeriodTime:c,hasDST:e.hasDST,DSTActive:e.DSTActive,offsetFromUser:o.offset,string:e.toString()},m.offset.fromUserTime=o.offsetText),m}function M(e,r=!0){if(r)return[e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes(),e.getSeconds(),e.getMilliseconds()];let n=e.format("yyyy-m-d-hh-mmi-ss",`${e.localeInfo.formatOptions},hrc23:true`).split(/-/).map(Number).concat(e.getMilliseconds());return n[1]-=1,n}function ee(e){return new Date(e.year,e.month+1,0,0,0,0).getDate()}function L(e,r){r=p({locale:r||e.localeInfo.locale}).locale;let n=e.clone.relocate({locale:r});return n.date={date:1},[n].concat([...Array(ee(n)-1)].map((t,a)=>n.clone.add(`${a+1} days`)))}function x(e,{day:r,next:n=!1,preserveTodayWhenEqual:t=!1}={}){r=r?.toLowerCase()||"-";let a=ge(r);if(a<0)return console.error(`[TickTock instance].next/previous invalid day value ${r}`),e.clone;let o=n?1:-1,s=f(new Date(...e.dateTimeValues),e.localeInfo);return t&&a===s.day?s:je(s.addDays(n?1:-1),a,o)}function je(e,r,n){function t(a){switch(!0){case a.day===r:return a;default:return t(a.add(`${n} days`))}}return t(e)}function F(e,{dateOnly:r=!1,timeOnly:n=!1}={}){let{locale:t,timeZone:a}=e.localeInfo;return r?new Date(e).toLocaleDateString(t,{timeZone:a}):n?new Date(e).toLocaleTimeString(t,{timeZone:a}):new Date(e).toLocaleString(t,{timeZone:a})}function me(e,r){let n={timeZone:r,hourCycle:"h23"};return new Date(new Date(e).toLocaleString("en",n))}function z(e,{year:r,month:n,date:t}={}){return Z(r)&&e.setFullYear(parseInt(r)),Z(t)&&e.setDate(parseInt(t)),Z(n)&&e.setMonth(parseInt(n)),e}function N(e,{hours:r,minutes:n,seconds:t,milliseconds:a}={}){return Z(r)&&e.setHours(parseInt(r)),Z(n)&&e.setMinutes(parseInt(n)),Z(t)&&e.setSeconds(parseInt(t)),Z(a)&&e.setMilliseconds(parseInt(a)),e}function $e(e){return e?.constructor===Date||e?.value}function te(e,r){return $e(r)?f(r?.value||r,e.localeInfo):f.from(...e.dateTimeValues).relocate(e.localeInfo)}function Pe(){return function(e){e=`${e}`.toLowerCase();let r=Ae.indexOf(e);return r<0?ye.indexOf(e):r}}function A(e){let r=e.slice(1).split(/[-:]/).map(Number),n=e.startsWith("-");return r=r.map(t=>n?-t:t),r}function Se(e){return e.time={hours:0,minutes:0,seconds:0,milliseconds:0},e}function fe(e,r){return Intl.DateTimeFormat("en-CA",{timeZone:r,timeZoneName:"long"}).format(e).split(/,/)[1].trim()}function j(e,r){r=r||e?.timeZone||g.timeZone,e=e?.value?e:e?.constructor===Date?f(e,{timeZone:r}):f({timeZone:r});let n=e.year||e.getFullYear(),t=fe(new Date(n,0,1),r),a=fe(new Date(n,5,1),r);return t!==a}function P(e,r){return r=r||e?.timeZone||g.timeZone,e=e?.hasDST?e:e?.constructor===Date?f(e,{timeZone:r}):f({timeZone:r}),e.hasDST?!/standard/i.test(e.toString()):!1}function Ze(e,{locale:r,timeZone:n,l:t,tz:a}={}){return e.localeInfo=p({locale:t||r||e.l||e.locale,timeZone:a||n||e.tz||e.timeZone}),e}function we(e,r){return $e(r)&&(e=f(r.value||r,r.localeInfo||e.localeInfo)),e}function C(e,r){let n=ne(new Date(e,11,r||31));return n===1?C(e,(r||31)-1):n}function re(e,r){let n=e.month;switch(!0){case n<3:return r?1:"First";case n<6:return r?2:"Second";case n<9:return r?3:"Third";case n<12:return r?4:"Fourth";default:return"unknown"}}function ne(e){let r=new Date(e),n=(r.getDay()+6)%7;r.setDate(r.getDate()-n+3);let t=r.valueOf();return r.setMonth(0,1),r.getDay()!==4&&r.setMonth(0,1+(4-r.getDay()+7)%7),1+Math.ceil((t-r)/6048e5)}var E=Ye;function Ye({localeInfo:e,customMethods:r,dateValue:n}={}){let t,a={add(...o){return q(t,...o)},between({start:o,end:s,include:u}={}){return W(t,{start:o,end:s,include:u})},cloneWith(o){return te(t,o)},daysUntil(o){return De(t,o)},differenceTo(o){return Q({start:t,end:o})},differenceUntil(o){return t.differenceTo(o).clean},firstWeekday({sunday:o=!1,midnight:s=!1}={}){return K(t,{sunday:o,midnight:s})},format(o,s){return H(t,{formatStr:o,moreOptions:s})},fullMonth(o){return L(t,o)},fullWeek(o=!1){return he(t,!!o)},isFuture(o){return W(t,{start:t,end:o,future:!0})},isPast(o){return W(t,{start:t,end:o,past:!0})},next(o,s){return x(t,{day:o,next:!0,preserveTodayWhenEqual:!!s})},offsetFrom(o){return R(t,o)},previous(o,s){return x(t,{day:o,next:!1,preserveTodayWhenEqual:!!s})},relocate({locale:o,timeZone:s,l:u,tz:c}={}){return Ze(t,{locale:o,timeZone:s,l:u,tz:c})},revalue(o){return t=we(t,o),t},setDateValues({year:o,month:s,date:u}={}){return z(t,{year:o,month:s,date:u})},setTimeValues({hours:o,minutes:s,seconds:u,milliseconds:c}={}){return N(t,{hours:o,minutes:s,seconds:u,milliseconds:c})},subtract(...o){return q(t,"subtract,"+o.join(","))},toArray(o=!1){return M(t,o)},toString({template:o,formatOptions:s,local:u}={}){return Te(t,{withFormat:o,withFormatOptions:s,local:u})},values(o=!1){return o?t.dateTime:t.zoneDateTime},zoneFormat(o,s){return H(t,{zoneTime:!0,formatStr:o,moreOptions:s})},set date({year:o,month:s,date:u}){z(t,{year:o,month:s,date:u})},set dateNr(o){z(t,{date:o})},set hours(o){N(t,{hours:o})},set localeInfo({locale:o,timeZone:s,l:u,tz:c}){e=O({locale:o,timeZone:s,l:u,tz:c})},set milliseconds(o){N(t,{milliseconds:`${o}`})},set minutes(o){N(t,{minutes:o})},set month(o){z(t,{month:o})},set seconds(o){N(t,{seconds:o})},set time({hours:o,minutes:s,seconds:u,milliseconds:c}){N(t,{hours:o,minutes:s,seconds:u,milliseconds:c})},set year(o){z(t,{year:o})},get age(){return t.differenceTo(new Date).years},get ageFull(){return t.differenceTo(new Date).clean},get clone(){return te(t)},get date(){return B(t,!0)},get dateNr(){return t.date.date},get dateTime(){return{...t.date,...t.time}},get dateTimeValues(){return M(t,!0)},get dateValues(){return J(t,!0)},get day(){return t.getDay()},get dayName(){return t.names.dayName},get daysThisMonth(){return ee(t)},get DSTActive(){return P(t)},get hasDST(){return j(t)},get hours(){return t.time.hours},get info(){return pe(t)},get isLeapYear(){return new Date(t.getFullYear(),2,0).getDate()===29},get ISO(){return t.toISOString()},get local(){return F(t)},get localDate(){return F(t,{dateOnly:!0})},get locale(){return(e||O()).locale},get localeInfo(){return e},get localeString(){return F(t)},get localTime(){return F(t,{timeOnly:!0})},get milliseconds(){return t.getMilliseconds()},get minutes(){return t.time.minutes},get month(){return t.date.month},get monthName(){return t.names.monthName},get names(){return _(t)},get quarter(){return re(t)},get quarterNr(){return re(t,!0)},get removeTime(){return Se(t)},get seconds(){return t.time.seconds},get time(){return G(t,!0)},get timeValues(){return U(t,!0)},get timeZone(){return(e||O()).timeZone},get unixEpochTimestamp(){return Math.floor(+t/1e3)},get userLocaleInfo(){return g},get UTC(){return t.clone.relocate({locale:t.locale,timeZone:"UTC"})},get UTCOffset(){return R(t,"UTC")},get value(){return new Date(t)},get weeknr(){return ne(t)},get weeksInYear(){return C(t.year,31)},get year(){return t.date.year},get zoneDate(){return B(t,!1)},get zoneDateNr(){return t.zoneDate.date},get zoneDateTime(){return{...t.zoneDate,...t.zoneTime}},get zoneDateTimeValues(){return M(t,!1)},get zoneDateValues(){return J(t,!1)},get zoneDay(){return X(t,!0)},get zoneDayname(){return t.zoneNames.dayName},get zoneHours(){return t.zoneTime.hours},get zoneMinutes(){return t.zoneTime.minutes},get zoneMonth(){return t.zoneDate.month},get zoneMonthname(){return t.zoneNames.monthName},get zoneNames(){return _(t,!0)},get zoneSeconds(){return t.zoneTime.seconds},get zoneTime(){return G(t)},get zoneTimeValues(){return U(t)},get zoneYear(){return t.zoneDate.year},get zoneValues(){return t.zoneDateTime},get zoneArray(){return M(t,!1)}};return!e&&!n?a:(a.localeInfo=e||O(),t=new Proxy(n,Ee(a)),Object.entries(Object.getOwnPropertyDescriptors(se(t,r))).forEach(([o,s])=>Object.defineProperty(a,o,s)),Object.freeze(t))}function Ee(e){return{get(r,n){return n!=="toString"&&n in r?r[n].bind(r):Reflect.get(e,n)},set(r,n,t){return n in e&&Reflect.set(e,n,t)}}}var g=Ne(Intl.DateTimeFormat().resolvedOptions()),Ve=Object.getOwnPropertyNames(Date.prototype).filter(e=>e.startsWith("set")).reduce((e,r)=>[...e,{native:r,syn:"change"+r.slice(3)}],[]);function oe(e="en-GB"){return e=p({locale:e}).locale,{long:[...Array(7).keys()].map(r=>new Date(Date.UTC(1970,0,4+r)).toLocaleDateString(e,{timeZone:"Etc/UTC",weekday:"long"})),short:[...Array(7).keys()].map(r=>new Date(Date.UTC(1970,0,4+r)).toLocaleDateString(e,{timeZone:"Etc/UTC",weekday:"short"}))}}function Y(e="en"){return e=p({locale:e}).locale,{long:[...Array(12).keys()].map(r=>new Date(Date.UTC(1970,r,1)).toLocaleDateString(e,{timeZone:"Etc/UTC",month:"long"})),short:[...Array(12).keys()].map(r=>new Date(Date.UTC(1970,r,1)).toLocaleDateString(e,{timeZone:"Etc/UTC",month:"short"}))}}function qe({year:e,locale:r}={}){e=Z(e)?parseInt(e):new Date().getFullYear();let n={year:e,calendar:{}},t=Y().long.map(a=>a.toLowerCase());for(let a=0;a<12;a+=1){let o=f.from(e,a,1);n.calendar[t[a]]=L(o,r)}return n}function He({year:e,monthNr:r,locale:n="en-CA"}={}){e=Z(r)&&parseInt(e)||-1,r=Z(r)&&parseInt(r)||new Date().getFullYear();let t=r>=1&&r<=12;return n=p({locale:n}).locale,r=t?r-1:void 0,t?f.from(e,r,1).relocate({locale:n}).fullMonth(n):"MonthNr should be a specific number (1 = january - 12 = december)"}function Ne(e){let r=ae(e.locale,e.timeZone),n=new Intl.Locale(e.locale);return e.weekInfo=n.getWeekInfo?n.getWeekInfo():null,Object.defineProperty(e,"formatOptions",{value:r,enumerable:!1})}function ae(e,r){return[`${e&&!(Array.isArray(e)&&e.length<1)?`l:${e}`:""}`,`${r?`tz:${r}`:""}`].filter(n=>n).join(",")}function p({locale:e,timeZone:r,l:n,tz:t}={}){return r=r||t,e=e||n,e=ve({trial:function(){return Intl.DateTimeFormat(e,{timeZone:g.timeZone}).resolvedOptions().locale},onError:function(){return console.warn(`Intl locale "${e}" best fit impossible, using "${g.locale}"`),g.locale}}),r=ve({trial:function(){return Intl.DateTimeFormat(e,{timeZone:r}).resolvedOptions().timeZone},onError:function(){return console.warn(`timeZone "${r}" not valid. Using "${g.timeZone}"`),g.timeZone}}),Ne(Intl.DateTimeFormat(e,{timeZone:r}).resolvedOptions())}function O({locale:e,timeZone:r,l:n,tz:t}={}){return p({locale:e,timeZone:r,l:n,tz:t},!0)}function be(e){return!Number.isNaN(+e)&&e?.constructor===Date&&!e?.toISOString?.().startsWith("1970-01-01T00:00:00")?e:new Date}function Ie(e){let r=new Date;switch(!0){case e?.constructor===String:return be(new Date(e));case(Array.isArray(e)&&e.map(Number).length===e.length):return e.length===1?new Date(e[0],0,1):new Date(...e);case e?.constructor===Date:return be(e);default:return r}}function ve({trial:e,onError:r=()=>{}}={}){if(e?.constructor===Function)try{return e()}catch(n){return r?.constructor===Function?r(n):void 0}}function _e({timeZoneDate:e,timeZoneID:r,userTimeZoneID:n}={}){let t={timeZone:p({timeZone:r}).timeZone},a={timeZone:p({timeZone:n||""}).timeZone},o=f(e,t),s=f(e,a),u=s.differenceTo(o),c=o.offsetFrom(s).offset,[l,m]=A(c,!0),T=s.clone.add(`${l} hours, ${m} minutes`),y=u.equalDates?"No difference":`Time offset ${c}: ${a.timeZone} is ${u.clean} ${l<0?"behind":"ahead of"} ${t.timeZone}`;return{remoteTimezone:t.timeZone,userTimezone:a.timeZone,timeDifference:y,result:{[t.timeZone.replace(/\//,"_")]:f(e).toString({template:"yyyy/mm/dd hh:mmi:ss",formatOptions:"hrc:23"}),[a.timeZone.replace(/\//,"_")]:T.toString({template:"yyyy/mm/dd hh:mmi:ss",formatOptions:"hrc:23"})}}}function Z(e){return!Number.isNaN(parseInt(e))}function V(e,r,n){return e?.constructor===Number?w(r,`${e} ${n}`):r}function Ge(e){let r={addYears(n=1){return V(n,e,"years")},addMonths(n=1){return V(n,e,"months")},addWeeks(n=1){return n=n?.constructor===Number?n*7:1,V(n,e,"days")},addDays(n=1){return V(n,e,"days")},get nextYear(){return w(e,"1 year")},get nextWeek(){return w(e,"7 days")},get previousWeek(){return w(e,"-7 days")},get previousYear(){return w(e,"-1 year")},get nextMonth(){return w(e,"1 month")},get previousMonth(){return w(e,"-1 month")},get tomorrow(){return w(e,"1 day")},get yesterday(){return w(e,"-1 day")}};for(let n of Ve)r[n.syn]=function(...t){return e[n.native](...t),e};return r}function se(e,r){let n=Ge(e);for(let[t,a]of Object.entries(r||{})){let o=a.enumerable,s=a.isGetter?{get(){return a.method(e)},enumerable:o}:{value(...u){return a.method(e,...u)},enumerable:o};Object.defineProperty(n,t,s)}return n}function ze(e,r){return Object.defineProperties(e,{now:{get(){return e(new Date)}},localeInformation:{get(){return p()}},localWeekdaynames:{value(n){return oe(n)}},localMonthnames:{value(n){return Y(n)}},daysInMonth:{value(n,t=!1){return n=Z(n)?parseInt(n):0,n>=1&&n<=12?new Date(t?2e3:2005,n,0).getDate():`${n} should be a Number between (1 (january) - 12 (december))`}},yearCalendar:{value:qe},monthCalendar:{value:He},from:{value(...n){return e(n)}},fromUxTS:{value(n,t){n=Z(n)?parseInt(n)*1e3:void 0;let a=n?new Date(n):new Date;return f(a,t||g)}},hasDST:{value({date:n,timeZone:t}={}){return j(n,t)}},DSTActive:{value({date:n,timeZone:t}={}){return P(n,t)}},values:{value({date:n,timeZone:t}={}){n=n||n?.value||new Date;let a=I(n,"yyyy-m-d-h-mi-s",p({timeZone:t}).formatOptions.concat(",hrc:23")).split("-").map(Number).concat(n.getMilliseconds());return a[1]-=1,a}},format:{value({date:n,template:t,timeZone:a,locale:o,opts:s}={}){n=n||n?.value||new Date,t=t?.constructor===String?t:"yyyy/mm/dd hh:mmi:ss dp";let u=p({timeZone:a,locale:o}).formatOptions;return u+=s?`,${s}`:"",I(n,t,u)}},addCustom:{value({name:n,method:t,enumerable:a=!1,isGetter:o=!1}={}){n?.constructor===String&&t?.constructor===Function&&t.length>0&&(r[n]={method:t,enumerable:a,isGetter:o})}},validateLocaleInformation:{value:p},timeAcrossZones:{value:_e},weeksInYear:{value(n){return C(n,31)}},keys:{get(){let n=Object.fromEntries(Object.entries(r).filter(([a,o])=>o.enumerable===!0));return[...Object.keys(E()),...Object.keys(se()),...Object.keys(n)].sort((a,o)=>a.localeCompare(o))}}}),e}var Oe={},f=ze(Be,Oe);function Be(e,r){if(e?.localeInfo)return e.clone;let n=e?.locale||e?.timeZone||e?.tz||e?.l;return E({localeInfo:p(n?e:r),dateValue:new Date(n?Date.now():Ie(e)),customMethods:Oe})}export{f as default};
|