UNPKG

@sbh321/qcalendar

Version:

A forked version of Jeff Galbraith's fork of Quasar UI QCalendar

6 lines 11.4 kB
/*! * @subhambhandari/qcalendar v4.0.0-beta.19 * (c) 2024 Subham Bhandari <bhandarimaiya65@gmail.com> * Released under the MIT License. */ (function(e,t){"object"===typeof exports&&"undefined"!==typeof module?module.exports=t():"function"===typeof define&&define.amd?define(t):(e="undefined"!==typeof globalThis?globalThis:e||self,e.Timestamp=t())})(this,function(){"use strict";const e="4.0.0-beta.19",n=/^(\d{4})-(\d{1,2})(-(\d{1,2}))?([^\d]+(\d{1,2}))?(:(\d{1,2}))?(:(\d{1,2}))?(.(\d{1,3}))?$/,H=/^(\d{4})-(\d{1,2})(-(\d{1,2}))/,r=/(\d\d?)(:(\d\d?)|)(:(\d\d?)|)/,a=[0,31,28,31,30,31,30,31,31,30,31,30,31],o=[0,31,29,31,30,31,30,31,31,30,31,30,31],t=28,$=31,u=12,i=1,s=1,d=7,c=60,m=24,L=0,Z=6e4,x=36e5,f=864e5,y=6048e5,R={date:"",time:"",year:0,month:0,day:0,weekday:0,hour:0,minute:0,doy:0,workweek:0,hasDay:!1,hasTime:!1,past:!1,current:!1,future:!1,disabled:!1,currentWeekday:!1},j={hour:0,minute:0};function h(){const e=new Date,t=""+(e.getMonth()+1),n=""+e.getDate(),r=e.getFullYear();return[r,S(t,2),S(n,2)].join("-")}function P(e,t,n){let r=_(e);if(1===r.day||0===r.weekday)while(!t.includes(r.weekday))r=F(r);return r=W(r,t[0],U),r=I(r),n&&(r=k(r,n,r.hasTime)),r}function B(e,t,n){let r=_(e);const a=O(r.year,r.month);if(a===r.day||6===r.weekday)while(!t.includes(r.weekday))r=U(r);return r=W(r,t[t.length-1],F),r=I(r),n&&(r=k(r,n,r.hasTime)),r}function X(e){const t=_(e);return t.day=s,I(t),t}function z(e){const t=_(e);return t.day=O(t.year,t.month),I(t),t}function J(e){const t=Object.prototype.toString.call(e);switch(t){case"[object Number]":return e;case"[object String]":{const n=r.exec(e);return n?60*parseInt(n[1],10)+parseInt(n[3]||0,10):!1}case"[object Object]":return"number"!==typeof e.hour||"number"!==typeof e.minute?!1:60*e.hour+e.minute}return!1}function K(e){return!!n.exec(e)}function G(e,t){return JSON.stringify(e)===JSON.stringify(t)}function q(e,t){return A(e)===A(t)}function Q(e,t){return v(e)===v(t)}function V(e,t){return E(e)===E(t)}function l(e){const t=n.exec(e);return t?{date:e,time:S(parseInt(t[6],10)||0,2)+":"+S(parseInt(t[8],10)||0,2),year:parseInt(t[1],10),month:parseInt(t[2],10),day:parseInt(t[4],10)||1,hour:isNaN(parseInt(t[6],10))?0:parseInt(t[6],10),minute:isNaN(parseInt(t[8],10))?0:parseInt(t[8],10),weekday:0,doy:0,workweek:0,hasDay:!!t[4],hasTime:!0,past:!1,current:!1,future:!1,disabled:!1}:null}function D(e,t){let n=l(e);return null===n?null:(n=I(n),t&&k(n,t,n.hasTime),n)}function ee(e,t=!1){const n=t?"UTC":"";return I({date:S(e[`get${n}FullYear`](),4)+"-"+S(e[`get${n}Month`]()+1,2)+"-"+S(e[`get${n}Date`](),2),time:S(e[`get${n}Hours`]()||0,2)+":"+S(e[`get${n}Minutes`]()||0,2),year:e[`get${n}FullYear`](),month:e[`get${n}Month`]()+1,day:e[`get${n}Date`](),hour:e[`get${n}Hours`](),minute:e[`get${n}Minutes`](),weekday:0,doy:0,workweek:0,hasDay:!0,hasTime:!0,past:!1,current:!1,future:!1,disabled:!1})}function T(e){return 1e8*e.year+1e6*e.month+1e4*e.day}function w(e){return 100*e.hour+e.minute}function g(e){return T(e)+w(e)}function p(e,t,n){const r=Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute),a=Date.UTC(t.year,t.month-1,t.day,t.hour,t.minute);return!0===n&&a<r?0:a-r}function k(e,t,n=!1){let r=T(t),a=T(e),o=r===a;return e.hasTime&&n&&o&&(r=w(t),a=w(e),o=r===a),e.past=a<r,e.current=o,e.future=a>r,e.currentWeekday=e.weekday===t.weekday,e}function te(e,t,n){return e.hasTime=!0,e.hour=Math.floor(t/c),e.minute=t%c,e.time=v(e),n&&k(e,n,!0),e}function ne(e){return e.weekday=b(e),e}function re(e){return e.doy=M(e),e}function ae(e){return e.workweek=N(e),e}function oe(e,t,n,r,a){const o=T(e);if(void 0!==t){const i=T(l(t));o<=i&&(e.disabled=!0)}if(!0!==e.disabled&&void 0!==n){const u=T(l(n));o>=u&&(e.disabled=!0)}if(!0!==e.disabled&&Array.isArray(r)&&r.length>0)for(const s in r)if(r[s]===e.weekday){e.disabled=!0;break}if(!0!==e.disabled&&Array.isArray(a)&&a.length>0)for(const d in a)if(Array.isArray(a[d])&&2===a[d].length){const c=l(a[d][0]),m=l(a[d][1]);if(Te(e,c,m)){e.disabled=!0;break}}else{const f=T(D(a[d]+" 00:00"));if(f===o){e.disabled=!0;break}}return e}function I(e){return e.hasTime=!0,e.time=v(e),e.date=A(e),e.weekday=b(e),e.doy=M(e),e.workweek=N(e),e}function M(e){if(0!==e.year)return(Date.UTC(e.year,e.month-1,e.day)-Date.UTC(e.year,0,0))/24/60/60/1e3}function N(e){0===e.year&&(e=D(h()));const t=fe(e);if(isNaN(t))return 0;const n=new Date(t.getFullYear(),t.getMonth(),t.getDate()),r=(n.setDate(n.getDate()-(n.getDay()+6)%7+3),new Date(n.getFullYear(),0,4)),a=(r.setDate(r.getDate()-(r.getDay()+6)%7+3),n.getTimezoneOffset()-r.getTimezoneOffset()),o=(n.setHours(n.getHours()-a),(n-r)/y);return 1+Math.floor(o)}function b(e){let t=e.weekday;if(e.hasDay){const n=Math.floor,r=e.day,a=(e.month+9)%u+1,o=n(e.year/100),i=e.year%100-(e.month<=2?1:0);t=((r+n(2.6*a-.2)-2*o+i+n(i/4)+n(o/4))%7+7)%7}return t}function ie(e){return 1===(e%4===0^e%100===0^e%400===0)}function O(e,t){return(ie(e)?o:a)[t]}function _(e){return{...e}}function S(e,t){let n=String(e);while(n.length<t)n="0"+n;return n}function A(e){let t=S(e.year,4)+"-"+S(e.month,2);return e.hasDay&&(t+="-"+S(e.day,2)),t}function v(e){return e.hasTime?S(e.hour,2)+":"+S(e.minute,2):""}function E(e){return A(e)+" "+(e.hasTime?v(e):"00:00")}function F(e){return++e.day,e.weekday=(e.weekday+1)%d,e.day>t&&e.day>O(e.year,e.month)&&(e.day=s,++e.month,e.month>u)&&(e.month=i,++e.year),e}function U(e){return e.day--,e.weekday=(e.weekday+6)%d,e.day<s&&(e.month--,e.month<i&&(e.year--,e.month=u),e.day=O(e.year,e.month)),e}function ue(e,t=F,n=1,r=[0,1,2,3,4,5,6]){return C(e,t,n,r)}function C(e,t=F,n=1,r=[0,1,2,3,4,5,6]){r.includes(e.weekday)||0!==e.weekday||t!==F||++n;while(--n>=0)e=t(e),r.length<7&&!r.includes(e.weekday)&&++n;return e}function W(e,t,n=F,r=6){while(e.weekday!==t&&--r>=0)e=n(e);return e}function se(t){const e=[1,1,1,1,1,1,1],r=[0,0,0,0,0,0,0];for(let e=0;e<t.length;++e)r[t[e]]=1;for(let n=0;n<d;++n){let t=1;for(let e=1;e<d;++e){const a=(n+e)%d;if(r[a])break;++t}e[n]=r[n]*t}return e}function de(e,t,n,r,a,o,i=[],u=[],s=42,d=0){const c=T(t),m=[];let f=_(e),y=0,h=y===c;if(!(c<T(e)))while((!h||m.length<d)&&m.length<s){if(y=T(f),h=h||y>c&&m.length>=d,h)break;if(0===r[f.weekday]);else{const l=_(f);I(l),k(l,n),oe(l,a,o,i,u),m.push(l)}f=C(f,F)}return m}function ce(t,n,r,a,o){const i=[];for(let e=0;e<a;++e){const u=(n+e)*r,s=_(t);i.push(te(s,u,o))}return i}function me(r,a){const o=(e,t)=>"";return"undefined"===typeof Intl||"undefined"===typeof Intl.DateTimeFormat?o:(t,e)=>{try{const n=new Intl.DateTimeFormat(r||void 0,a(t,e));return n.format(ye(t))}catch(e){return console.error(`Intl.DateTimeFormat: ${e.message} -> `+E(t)),o}}}function fe(e,t=!0){return t?new Date(Date.UTC(e.year,e.month-1,e.day,0,0)):new Date(e.year,e.month-1,e.day,0,0)}function ye(e,t=!0){return t?new Date(Date.UTC(e.year,e.month-1,e.day,e.hour,e.minute)):new Date(e.year,e.month-1,e.day,e.hour,e.minute)}function he(e){return isFinite(parseInt(e,10))}function le(e,t=!1){const n=!0===t?g:T;return e.reduce((e,t)=>{return Math.max(n(e),n(t))===n(e)?e:t})}function De(e,t=!1){const n=!0===t?g:T;return e.reduce((e,t)=>{return Math.min(n(e),n(t))===n(e)?e:t})}function Te(e,t,n,r){const a=T(e)+(!0===r?w(e):0),o=T(t)+(!0===r?w(t):0),i=T(n)+(!0===r?w(n):0);return a>=o&&a<=i}function we(e,t,n,r){const a=T(e),o=T(t),i=T(n),u=T(r);return a>=i&&a<=u||o>=i&&o<=u||i>=a&&o>=u}function ge(e,t){const r=_(e);let a;return ke(t,(e,t)=>{if(void 0!==r[t]){r[t]+=parseInt(e,10);const n=pe.indexOf(t);-1!==n&&(a=void 0===a?n:Math.min(n,a))}}),void 0!==a&&be(r,pe[a]),I(r),r}const pe=["minute","hour","day","month"];function ke(t,n){Object.keys(t).forEach(e=>n(t[e],e))}function Ie(e){if(e.minute>=c||e.minute<0){const t=Math.floor(e.minute/c);e.minute-=t*c,e.hour+=t,Me(e)}return e}function Me(e){if(e.hour>=m||e.hour<0){const t=Math.floor(e.hour/m);e.hour-=t*m,e.day+=t,Ne(e)}return e}function Ne(t){Y(t);let n=O(t.year,t.month);if(t.day>n){++t.month,t.month>u&&Y(t);let e=t.day-n;n=O(t.year,t.month);do{e>n&&(++t.month,t.month>u&&Y(t),e-=n,n=O(t.year,t.month))}while(e>n);t.day=e}else if(t.day<=0){let e=-1*t.day;--t.month,t.month<=0&&Y(t),n=O(t.year,t.month);do{e>n&&(e-=n,--t.month,t.month<=0&&Y(t),n=O(t.year,t.month))}while(e>n);t.day=n-e}return t}function Y(e){if(e.month>u){const t=Math.floor(e.month/u);e.month=e.month%u,e.year+=t}else e.month<i&&(e.month+=u,--e.year);return e}function be(e,t){switch(t){case"minute":return Ie(e);case"hour":return Me(e);case"day":return Ne(e);case"month":return Y(e)}}function Oe(e,t){const n=p(e,t,!0);return Math.floor(n/f)}function _e(e,t){let n=_(e),r=_(t);return n=W(n,0),r=W(r,6),Math.ceil(Oe(n,r)/d)}const Se={Sun:new Date("2020-01-05T00:00:00.000Z"),Mon:new Date("2020-01-06T00:00:00.000Z"),Tue:new Date("2020-01-07T00:00:00.000Z"),Wed:new Date("2020-01-08T00:00:00.000Z"),Thu:new Date("2020-01-09T00:00:00.000Z"),Fri:new Date("2020-01-10T00:00:00.000Z"),Sat:new Date("2020-01-11T00:00:00.000Z")};function Ae(){const a=(e,t)=>"",o={long:{timeZone:"UTC",weekday:"long"},short:{timeZone:"UTC",weekday:"short"},narrow:{timeZone:"UTC",weekday:"narrow"}};return"undefined"===typeof Intl||"undefined"===typeof Intl.DateTimeFormat?a:e;function e(t,e,n){try{const r=new Intl.DateTimeFormat(n||void 0,o[e]||o["long"]);return r.format(Se[t])}catch(e){return console.error(`Intl.DateTimeFormat: ${e.message} -> day of week: `+t),a}}}function ve(t,n){const e=Object.keys(Se),r=Ae();return e.map(e=>r(e,t,n))}function Ee(){const o=(e,t)=>"",i={long:{timeZone:"UTC",month:"long"},short:{timeZone:"UTC",month:"short"},narrow:{timeZone:"UTC",month:"narrow"}};return"undefined"===typeof Intl||"undefined"===typeof Intl.DateTimeFormat?o:e;function e(t,e,n){try{const r=new Intl.DateTimeFormat(n||void 0,i[e]||i["long"]),a=new Date;return a.setDate(1),a.setMonth(t),r.format(a)}catch(e){return console.error(`Intl.DateTimeFormat: ${e.message} -> month: `+t),o}}}function Fe(t,n){const r=Ee();return[...Array(12).keys()].map(e=>r(e,t,n))}function Ue(e,t="px"){if(null!=e&&""!==e)return isNaN(e)?String(e):"auto"===e?e:""+Number(e)+t}function Ce(t,n){for(let e=0;e<t.length;e++)if(!0===n(t[e],e))return e;return-1}var We={version:e,PARSE_REGEX:n,PARSE_DATE:H,PARSE_TIME:r,DAYS_IN_MONTH:a,DAYS_IN_MONTH_LEAP:o,DAYS_IN_MONTH_MIN:t,DAYS_IN_MONTH_MAX:$,MONTH_MAX:u,MONTH_MIN:i,DAY_MIN:s,DAYS_IN_WEEK:d,MINUTES_IN_HOUR:c,HOURS_IN_DAY:m,FIRST_HOUR:L,MILLISECONDS_IN_MINUTE:Z,MILLISECONDS_IN_HOUR:x,MILLISECONDS_IN_DAY:f,MILLISECONDS_IN_WEEK:y,Timestamp:R,TimeObject:j,today:h,getStartOfWeek:P,getEndOfWeek:B,getStartOfMonth:X,getEndOfMonth:z,parseTime:J,validateTimestamp:K,parsed:l,parseTimestamp:D,parseDate:ee,getDayIdentifier:T,getTimeIdentifier:w,getDayTimeIdentifier:g,diffTimestamp:p,updateRelative:k,updateMinutes:te,updateWeekday:ne,updateDayOfYear:re,updateWorkWeek:ae,updateDisabled:oe,updateFormatted:I,getDayOfYear:M,getWorkWeek:N,getWeekday:b,isLeapYear:ie,daysInMonth:O,copyTimestamp:_,padNumber:S,getDate:A,getTime:v,getDateTime:E,nextDay:F,prevDay:U,relativeDays:C,moveRelativeDays:ue,findWeekday:W,getWeekdaySkips:se,createDayList:de,createIntervalList:ce,createNativeLocaleFormatter:me,makeDate:fe,makeDateTime:ye,validateNumber:he,maxTimestamp:le,minTimestamp:De,isBetweenDates:Te,isOverlappingDates:we,daysBetween:Oe,weeksBetween:_e,addToDate:ge,compareTimestamps:G,compareDate:q,compareTime:Q,compareDateTime:V,getWeekdayFormatter:Ae,getWeekdayNames:ve,getMonthFormatter:Ee,getMonthNames:Fe,convertToUnit:Ue,indexOf:Ce};return We});