@quasar/quasar-ui-qcalendar
Version:
QCalendar - Day/Month/Week Calendars, Popups, Date Pickers, Schedules, Agendas, Planners and Tasks for your Vue Apps
6 lines • 12.3 kB
JavaScript
/*!
* @quasar/quasar-ui-qcalendar v4.1.2
* (c) 2025 Jeff Galbraith <jeff@quasar.dev>
* 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(){const e="4.1.2",u=/^(\d{4})-(\d{1,2})(-(\d{1,2}))?([^\d]+(\d{1,2}))?(:(\d{1,2}))?(:(\d{1,2}))?(.(\d{1,3}))?$/,t=/^(\d{4})-(\d{1,2})(-(\d{1,2}))?/,r=/(\d\d?)(:(\d\d?)|)(:(\d\d?)|)/,n=[0,31,28,31,30,31,30,31,31,30,31,30,31],a=[0,31,29,31,30,31,30,31,31,30,31,30,31],o={MILLISECONDS_IN:{SECOND:1e3,MINUTE:6e4,HOUR:36e5,DAY:864e5,WEEK:6048e5},SECONDS_IN:{MINUTE:60,HOUR:3600,DAY:86400,WEEK:604800},MINUTES_IN:{MINUTE:1,HOUR:60,DAY:1440,WEEK:10080},HOURS_IN:{DAY:24,WEEK:168},DAYS_IN:{WEEK:7}},R=28,L=31,d=12,$=1,i=1,Z=0;function j(e){return"string"===typeof e&&u.test(e)}function w(e){if("string"!==typeof e)return null;const t=u.exec(e);if(!t||!t[1]||!t[2])return null;const n=parseInt(t[1],10),r=parseInt(t[2],10),a=parseInt(t[4]||"1",10),o=parseInt(t[6]||"0",10),i=parseInt(t[8]||"0",10);return{date:e,time:o.toString().padStart(2,"0")+":"+i.toString().padStart(2,"0"),year:n,month:r,day:a,hour:o,minute:i,hasDay:!!t[4],hasTime:!0,past:!1,current:!1,future:!1,disabled:!1,weekday:0,doy:0,workweek:0}}function x(e,t=!1){if(!(e instanceof Date))return null;const n=t?"UTC":"";return k({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 s(e,t){let n=String(e);while(n.length<t)n="0"+n;return n}function m(e){return e%4===0&&e%100!==0||e%400===0}function c(e,t){return(m(e)?a:n)[t]}function T(e){const t=new Date(e.year,e.month-1,e.day+1);return k(F({...e,year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}))}function f(e){const t=new Date(e.year,e.month-1,e.day-1);return k(F({...e,year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate()}))}function y(){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){return e===y()}function B(e,t,n){let r=A(e);if(t){if(1===r.day||0===r.weekday)while(!t.includes(Number(r.weekday)))r=T(r);r=W(r,t[0],f),r=k(r),n&&(r=g(r,n,r.hasTime))}return r}function K(e,t,n){let r=A(e);if(t&&Array.isArray(t)){const a=c(r.year,r.month);if(a===r.day||r.weekday===t[t.length-1])while(!t.includes(Number(r.weekday)))r=f(r);r=W(r,t[t.length-1],T),r=k(r),n&&(r=g(r,n,r.hasTime))}return r}function X(e){let t=A(e);return t.day=i,t=k(t),t}function z(e){let t=A(e);return t.day=c(t.year,t.month),t=k(t),t}function q(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"object"!==typeof e||"number"!==typeof e.hour||"number"!==typeof e.minute?!1:"object"===typeof e&&"hour"in e&&"minute"in e&&60*e.hour+e.minute}return!1}function G(e,t){return!(!e||!t)&&e.year===t.year&&e.month===t.month&&e.day===t.day&&e.hour===t.hour&&e.minute===t.minute}function J(e,t){return E(e)===E(t)}function Q(e,t){return b(e)===b(t)}function V(e,t){return U(e)===U(t)}function N(e,t=null){let n=w(e);return n?(n=k(n),t&&(n=g(n,t,n.hasTime)),n):null}function M(e){return 1e8*(e.year??0)+1e6*(e.month??0)+1e4*(e.day??0)}function l(e){return 100*(e.hour??0)+(e.minute??0)}function h(e){return M(e)+l(e)}function D(e,t,n=!1){const r=Date.UTC(e.year??0,(e.month??1)-1,e.day??1,e.hour??0,e.minute??0),a=Date.UTC(t.year??0,(t.month??1)-1,t.day??1,t.hour??0,t.minute??0);return!0===n&&a<r?0:a-r}function g(e,t,n=!1){let r=A(e),a=M(t),o=M(r),i=a===o;return r.hasTime&&n&&i&&(a=l(t),o=l(r),i=a===o),r.past=o<a,r.current=i,r.future=o>a,r.currentWeekday=r.weekday===t.weekday,r}function p(e,t,n=null){let r=A(e);return r.hasTime=!0,r.hour=Math.floor(t/o.MINUTES_IN.HOUR),r.minute=t%o.MINUTES_IN.HOUR,r.time=b(r),n&&(r=g(r,n,!0)),r}function ee(e){let t=A(e);return t.weekday=S(t),t}function te(e){let t=A(e);return t.doy=_(t)||0,t}function ne(e){let t=A(e);return t.workweek=O(t),t}function I(e,t,n,r,a){let o=A(e);const i=M(o);if(void 0!==t){const m=w(t);if(m){const c=M(m);i<=c&&(o.disabled=!0)}}if(!0!==o.disabled&&void 0!==n){const f=w(n);if(f){const y=M(f);i>=y&&(o.disabled=!0)}}if(!0!==o.disabled&&Array.isArray(r)&&r.length>0)for(var u in r)if(r[u]===o.weekday){o.disabled=!0;break}if(!0!==o.disabled&&Array.isArray(a)&&a.length>0)for(var d in a)if(Array.isArray(a[d])&&2===a[d].length&&a[d][0]&&a[d][1]){const l=w(a[d][0]),h=w(a[d][1]);if(l&&h&&Y(o,l,h)){o.disabled=!0;break}}else{const T=a[d];if(Array.isArray(T))for(var s of T){const D=N(s);if(D){const g=M(D);if(g===i){o.disabled=!0;break}}}else if(T){const p=N(T);if(p){const I=M(p);I===i&&(o.disabled=!0)}}}return o}function k(e){let t=A(e);return t.hasTime=!0,t.time=b(t),t.date=E(t),t.weekday=S(t),t.doy=_(t)||0,t.workweek=O(t),t}function _(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 O(e){let t=A(e);if(0===t.year){const a=N(y());a&&(t=a)}const n=new Date(Date.UTC(t.year,t.month-1,t.day)),r=4;n.setUTCDate(n.getUTCDate()-(n.getUTCDay()+6)%7+r),n.setUTCDate(n.getUTCDate()+r-(n.getUTCDay()||7));e=new Date(Date.UTC(n.getUTCFullYear(),0,1)),e=Math.ceil(((n.valueOf()-e.valueOf())/864e5+1)/7);return e}function S(e){let t=e.weekday;if(e.hasDay){const n=Math.floor,r=e.day,a=(e.month+9)%d+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??0}function A(e){return{...e}}function E(e){let t=s(e.year,4)+"-"+s(e.month,2);return e.hasDay&&(t+="-"+s(e.day,2)),t}function b(e){return e.hasTime?s(e.hour,2)+":"+s(e.minute,2):""}function U(e){return E(e)+" "+(e.hasTime?b(e):"00:00")}function re(e,t=T,n=1,r=[0,1,2,3,4,5,6]){const a=A(e);return v(a,t,n,r)}function v(e,t=T,n=1,r=[0,1,2,3,4,5,6]){let a=A(e);r.includes(Number(a.weekday))||0!==a.weekday||t!==T||++n;while(--n>=0)a=t(a),r.length<7&&!r.includes(Number(a.weekday))&&++n;return a}function W(e,t,n=T,r=6){let a=A(e);while(a.weekday!==t&&--r>=0)a=n(a);return a}function ae(e,t,n,r=[0,1,2,3,4,5,6],a=void 0,o=void 0,i=[],u=[],d=42,s=0){const m=M(e),c=M(t),f=[];let y=A(e),l=0,h=l===c;if(!(c<m))while((!h||f.length<s)&&f.length<d){if(l=M(y),h=h||l>c&&f.length>=s,h)break;if(r.includes(Number(y.weekday))){let e=A(y);e=k(e),e=g(e,n),e=I(e,a,o,i,u),f.push(e)}y=v(y,T)}return f}function oe(t,n,r,a,o){const i=[];for(let e=0;e<a;++e){const u=(n+e)*r,d=A(t);i.push(p(d,u,o))}return i}function ie(r,a){const e=()=>"";return"undefined"===typeof Intl||"undefined"===typeof Intl.DateTimeFormat?e:(t,e)=>{try{const n=new Intl.DateTimeFormat(r||void 0,a(t,e));return n.format(C(t))}catch(e){return console.error(`Intl.DateTimeFormat: ${e.message} -> `+U(t)),""}}}function ue(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 C(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 de(e){return isFinite(Number(e))}function se(e,t=!1){const n=!0===t?h:M;return e.reduce((e,t)=>{return Math.max(n(e),n(t))===n(e)?e:t})}function me(e,t=!1){const n=!0===t?h:M;return e.reduce((e,t)=>{return Math.min(n(e),n(t))===n(e)?e:t})}function Y(e,t,n,r=!1){const a=M(e)+(!0===r?l(e):0),o=M(t)+(!0===r?l(t):0),i=M(n)+(!0===r?l(n):0);return a>=o&&a<=i}function ce(e,t,n,r){const a=M(e),o=M(t),i=M(n),u=M(r);return a>=i&&a<=u||o>=i&&o<=u||i>=a&&o>=u}function fe(e,t){const n=A(e);return t.year&&(n.year+=t.year),t.month&&(n.month+=t.month),t.day&&(n.day+=t.day),t.hour&&(n.hour+=t.hour),t.minute&&(n.minute+=t.minute),k(F(n))}function F(e){const t=new Date(e.year,e.month-1,e.day,e.hour,e.minute);return{...e,year:t.getFullYear(),month:t.getMonth()+1,day:t.getDate(),hour:t.getHours(),minute:t.getMinutes()}}function H(e,t){const n=D(e,t,!0);return Math.floor(n/o.MILLISECONDS_IN.DAY)}function ye(e,t){let n=A(e),r=A(t);return n=W(n,0),r=W(r,6),Math.ceil(H(n,r)/o.DAYS_IN.WEEK)}const le={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 he(){const e=()=>"",a={long:{timeZone:"UTC",weekday:"long"},short:{timeZone:"UTC",weekday:"short"},narrow:{timeZone:"UTC",weekday:"narrow"}};return"undefined"===typeof Intl||"undefined"===typeof Intl.DateTimeFormat?e:t;function t(t,e,n){try{const r=new Intl.DateTimeFormat(n||void 0,a[e]||a["long"]);return r.format(le[t])}catch(e){return e instanceof Error&&console.error(`Intl.DateTimeFormat: ${e.message} -> day of week: `+t),""}}}function Te(t,n){const e=Object.keys(le),r=he();return e.map(e=>String(r(e,t,n)))}function De(){const e=()=>"",o={long:{timeZone:"UTC",month:"long"},short:{timeZone:"UTC",month:"short"},narrow:{timeZone:"UTC",month:"narrow"}};return"undefined"===typeof Intl||"undefined"===typeof Intl.DateTimeFormat?e:t;function t(t,e,n){try{const r=new Intl.DateTimeFormat(n||void 0,o[e]||o["long"]),a=new Date;return a.setDate(1),a.setMonth(t),r.format(a)}catch(e){return e instanceof Error&&console.error(`Intl.DateTimeFormat: ${e.message} -> month: `+t),""}}}function ge(t,n){const r=De();return[...Array(12).keys()].map(e=>r(e,t,n))}var pe={PARSE_DATETIME:u,PARSE_DATE:t,PARSE_TIME:r,DAYS_IN_MONTH:n,DAYS_IN_MONTH_LEAP:a,DAYS_IN_MONTH_MIN:R,DAYS_IN_MONTH_MAX:L,MONTH_MAX:d,MONTH_MIN:$,DAY_MIN:i,TIME_CONSTANTS:o,FIRST_HOUR:Z,today:y,getStartOfWeek:B,getEndOfWeek:K,getStartOfMonth:X,getEndOfMonth:z,parseTime:q,validateTimestamp:j,parsed:w,parseTimestamp:N,parseDate:x,getDayIdentifier:M,getTimeIdentifier:l,getDayTimeIdentifier:h,diffTimestamp:D,updateRelative:g,updateMinutes:p,updateWeekday:ee,updateDayOfYear:te,updateWorkWeek:ne,updateDisabled:I,updateFormatted:k,getDayOfYear:_,getWorkWeek:O,getWeekday:S,isLeapYear:m,daysInMonth:c,copyTimestamp:A,padNumber:s,getDate:E,getTime:b,getDateTime:U,nextDay:T,prevDay:f,relativeDays:v,findWeekday:W,createDayList:ae,createIntervalList:oe,createNativeLocaleFormatter:ie,makeDate:ue,makeDateTime:C,validateNumber:de,isBetweenDates:Y,isOverlappingDates:ce,daysBetween:H,weeksBetween:ye,addToDate:fe,compareTimestamps:G,compareDate:J,compareTime:Q,compareDateTime:V,getWeekdayFormatter:he,getWeekdayNames:Te,getMonthFormatter:De,getMonthNames:ge},pe=Object.freeze({__proto__:null,DAYS_IN_MONTH:n,DAYS_IN_MONTH_LEAP:a,DAYS_IN_MONTH_MAX:L,DAYS_IN_MONTH_MIN:R,DAY_MIN:i,FIRST_HOUR:Z,MONTH_MAX:d,MONTH_MIN:$,PARSE_DATE:t,PARSE_DATETIME:u,PARSE_TIME:r,TIME_CONSTANTS:o,addToDate:fe,compareDate:J,compareDateTime:V,compareTime:Q,compareTimestamps:G,copyTimestamp:A,createDayList:ae,createIntervalList:oe,createNativeLocaleFormatter:ie,daysBetween:H,daysInMonth:c,default:pe,diffTimestamp:D,findWeekday:W,getDate:E,getDateTime:U,getDayIdentifier:M,getDayOfYear:_,getDayTimeIdentifier:h,getEndOfMonth:z,getEndOfWeek:K,getMonthFormatter:De,getMonthNames:ge,getStartOfMonth:X,getStartOfWeek:B,getTime:b,getTimeIdentifier:l,getWeekday:S,getWeekdayFormatter:he,getWeekdayNames:Te,getWorkWeek:O,isBetweenDates:Y,isLeapYear:m,isOverlappingDates:ce,isToday:P,makeDate:ue,makeDateTime:C,maxTimestamp:se,minTimestamp:me,moveRelativeDays:re,nextDay:T,padNumber:s,parseDate:x,parseTime:q,parseTimestamp:N,parsed:w,prevDay:f,relativeDays:v,today:y,updateDayOfYear:te,updateDisabled:I,updateFormatted:k,updateMinutes:p,updateRelative:g,updateWeekday:ee,updateWorkWeek:ne,validateNumber:de,validateTimestamp:j,weeksBetween:ye});function Ie(e,t="px"){if(e)return isNaN(e)?String(e):"auto"===e?e:""+Number(e)+t}function we(t,n){for(let e=0;e<t.length;e++)if(!0===n(t[e],e))return e;return-1}function Ne(e,t){return 0===t?e:e.slice(0,t)}var Me={convertToUnit:Ie,indexOf:we,minCharWidth:Ne},Me=Object.freeze({__proto__:null,convertToUnit:Ie,default:Me,indexOf:we,minCharWidth:Ne}),pe={version:e,...pe,...Me};return pe});