diff --git a/dist/calendars/persian.js b/dist/calendars/persian.js index 7aafc60..c5e3a54 100644 --- a/dist/calendars/persian.js +++ b/dist/calendars/persian.js @@ -12,15 +12,23 @@ /* http://keith-wood.name/calendars.html Persian calendar for jQuery v2.0.2. Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. - Available under the MIT (http://keith-wood.name/licence.html) license. + Available under the MIT (http://keith-wood.name/licence.html) license. Please attribute the author if you use it. */ var main = require('../main'); var assign = require('object-assign'); - /** Implementation of the Persian or Jalali calendar. - Based on code from http://www.iranchamber.com/calendar/converter/iranian_calendar_converter.php. + + Modified Keith Wood's code by Mojtaba Samimi 2025. + Persian Calendar is a calendar based on solar system. + In the code below mean tropical year is used to calculate leap years. + You may also refer to the figure 2 presented on page 15 of the book titled + Intelligent Design using Solar-Climatic Vision. + Free download links: + https://depositonce.tu-berlin.de/items/c091139a-09cf-44c3-99a9-6adf59f7eaf8 + https://depositonce.tu-berlin.de/bitstreams/25a20942-2433-4ebe-90e2-0dfa69df5563/download + See also http://en.wikipedia.org/wiki/Iranian_calendar. @class PersianCalendar @param [language=''] {string} The language code (default English) for localisation. */ @@ -28,6 +36,24 @@ function PersianCalendar(language) { this.local = this.regionalOptions[language || ''] || this.regionalOptions['']; } +function _leapYear(year) { + // 475 S.H. (1096 A.D.) possibly when the solar calendar is adjusted by + // Omar Khayyam (https://en.wikipedia.org/wiki/Omar_Khayyam) + var x = year - 475; + if(year < 0) x++; + + // diff between approximate tropical year and 365 + var c = 0.242197; + + var v0 = c * x; + var v1 = c * (x + 1); + + var r0 = v0 - Math.floor(v0); + var r1 = v1 - Math.floor(v1); + + return r0 > r1; +} + PersianCalendar.prototype = new main.baseCalendar; assign(PersianCalendar.prototype, { @@ -73,10 +99,10 @@ assign(PersianCalendar.prototype, { name: 'Persian', epochs: ['BP', 'AP'], monthNames: ['Farvardin', 'Ordibehesht', 'Khordad', 'Tir', 'Mordad', 'Shahrivar', - 'Mehr', 'Aban', 'Azar', 'Day', 'Bahman', 'Esfand'], - monthNamesShort: ['Far', 'Ord', 'Kho', 'Tir', 'Mor', 'Sha', 'Meh', 'Aba', 'Aza', 'Day', 'Bah', 'Esf'], - dayNames: ['Yekshambe', 'Doshambe', 'Seshambe', 'Chæharshambe', 'Panjshambe', 'Jom\'e', 'Shambe'], - dayNamesShort: ['Yek', 'Do', 'Se', 'Chæ', 'Panj', 'Jom', 'Sha'], + 'Mehr', 'Aban', 'Azar', 'Dey', 'Bahman', 'Esfand'], + monthNamesShort: ['Far', 'Ord', 'Kho', 'Tir', 'Mor', 'Sha', 'Meh', 'Aba', 'Aza', 'Dey', 'Bah', 'Esf'], + dayNames: ['Yekshanbeh', 'Doshanbeh', 'Seshanbeh', 'Chahārshanbeh', 'Panjshanbeh', 'Jom\'eh', 'Shanbeh'], + dayNamesShort: ['Yek', 'Do', 'Se', 'Cha', 'Panj', 'Jom', 'Sha'], dayNamesMin: ['Ye','Do','Se','Ch','Pa','Jo','Sh'], digits: null, dateFormat: 'yyyy/mm/dd', @@ -92,8 +118,8 @@ assign(PersianCalendar.prototype, { @throws Error if an invalid year or a different calendar used. */ leapYear: function(year) { var date = this._validate(year, this.minMonth, this.minDay, main.local.invalidYear); - return (((((date.year() - (date.year() > 0 ? 474 : 473)) % 2820) + - 474 + 38) * 682) % 2816) < 682; + + return _leapYear(date.year()); }, /** Determine the week of the year for a date. @@ -146,11 +172,20 @@ assign(PersianCalendar.prototype, { year = date.year(); month = date.month(); day = date.day(); - var epBase = year - (year >= 0 ? 474 : 473); - var epYear = 474 + mod(epBase, 2820); + + var nLeapYearsSince = 0; + if(year > 0) { + for(var i = 1; i < year; i++) { + if(_leapYear(i)) nLeapYearsSince++; + } + } else if(year < 0) { + for(var i = year; i < 0; i++) { + if(_leapYear(i)) nLeapYearsSince--; + } + } + return day + (month <= 7 ? (month - 1) * 31 : (month - 1) * 30 + 6) + - Math.floor((epYear * 682 - 110) / 2816) + (epYear - 1) * 365 + - Math.floor(epBase / 2820) * 1029983 + this.jdEpoch - 1; + (year > 0 ? year - 1 : year) * 365 + nLeapYearsSince + this.jdEpoch - 1; }, /** Create a new date from a Julian date. @@ -159,29 +194,25 @@ assign(PersianCalendar.prototype, { @return {CDate} The equivalent date. */ fromJD: function(jd) { jd = Math.floor(jd) + 0.5; - var depoch = jd - this.toJD(475, 1, 1); - var cycle = Math.floor(depoch / 1029983); - var cyear = mod(depoch, 1029983); - var ycycle = 2820; - if (cyear !== 1029982) { - var aux1 = Math.floor(cyear / 366); - var aux2 = mod(cyear, 366); - ycycle = Math.floor(((2134 * aux1) + (2816 * aux2) + 2815) / 1028522) + aux1 + 1; + + // find year + var y = 475 + (jd - this.toJD(475, 1, 1)) / 365.242197; + var year = Math.floor(y); + if(year <= 0) year--; + + if(jd > this.toJD(year, 12, _leapYear(year) ? 30 : 29)) { + year++; + if(year === 0) year++; } - var year = ycycle + (2820 * cycle) + 474; - year = (year <= 0 ? year - 1 : year); + var yday = jd - this.toJD(year, 1, 1) + 1; var month = (yday <= 186 ? Math.ceil(yday / 31) : Math.ceil((yday - 6) / 30)); var day = jd - this.toJD(year, month, 1) + 1; + return this.newDate(year, month, day); } }); -// Modulus function which works for non-integers. -function mod(a, b) { - return a - (b * Math.floor(a / b)); -} - // Persian (Jalali) calendar implementation main.calendars.persian = PersianCalendar; main.calendars.jalali = PersianCalendar; diff --git a/jquery-src/jquery.calendars.all.min.js b/jquery-src/jquery.calendars.all.min.js deleted file mode 100755 index e22eef6..0000000 --- a/jquery-src/jquery.calendars.all.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/* http://keith-wood.name/calendars.html - Calendars for jQuery v2.0.2. - Written by Keith Wood (wood.keith{at}optusnet.com.au) August 2009. - Available under the MIT (http://keith-wood.name/licence.html) license. - Please attribute the author if you use it. */ -(function($){function Calendars(){this.regionalOptions=[];this.regionalOptions['']={invalidCalendar:'Calendar {0} not found',invalidDate:'Invalid {0} date',invalidMonth:'Invalid {0} month',invalidYear:'Invalid {0} year',differentCalendars:'Cannot mix {0} and {1} dates'};this.local=this.regionalOptions[''];this.calendars={};this._localCals={}}$.extend(Calendars.prototype,{instance:function(a,b){a=(a||'gregorian').toLowerCase();b=b||'';var c=this._localCals[a+'-'+b];if(!c&&this.calendars[a]){c=new this.calendars[a](b);this._localCals[a+'-'+b]=c}if(!c){throw(this.local.invalidCalendar||this.regionalOptions[''].invalidCalendar).replace(/\{0\}/,a)}return c},newDate:function(a,b,c,d,e){d=(a!=null&&a.year?a.calendar():(typeof d==='string'?this.instance(d,e):d))||this.instance();return d.newDate(a,b,c)},substituteDigits:function(c){return function(b){return(b+'').replace(/[0-9]/g,function(a){return c[a]})}},substituteChineseDigits:function(e,f){return function(a){var b='';var c=0;while(a>0){var d=a%10;b=(d===0?'':e[d]+f[c])+b;c++;a=Math.floor(a/10)}if(b.indexOf(e[1]+f[1])===0){b=b.substr(1)}return b||e[0]}}});function CDate(a,b,c,d){this._calendar=a;this._year=b;this._month=c;this._day=d;if(this._calendar._validateLevel===0&&!this._calendar.isValid(this._year,this._month,this._day)){throw($.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate).replace(/\{0\}/,this._calendar.local.name)}}function pad(a,b){a=''+a;return'000000'.substring(0,b-a.length)+a}$.extend(CDate.prototype,{newDate:function(a,b,c){return this._calendar.newDate((a==null?this:a),b,c)},year:function(a){return(arguments.length===0?this._year:this.set(a,'y'))},month:function(a){return(arguments.length===0?this._month:this.set(a,'m'))},day:function(a){return(arguments.length===0?this._day:this.set(a,'d'))},date:function(a,b,c){if(!this._calendar.isValid(a,b,c)){throw($.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate).replace(/\{0\}/,this._calendar.local.name)}this._year=a;this._month=b;this._day=c;return this},leapYear:function(){return this._calendar.leapYear(this)},epoch:function(){return this._calendar.epoch(this)},formatYear:function(){return this._calendar.formatYear(this)},monthOfYear:function(){return this._calendar.monthOfYear(this)},weekOfYear:function(){return this._calendar.weekOfYear(this)},daysInYear:function(){return this._calendar.daysInYear(this)},dayOfYear:function(){return this._calendar.dayOfYear(this)},daysInMonth:function(){return this._calendar.daysInMonth(this)},dayOfWeek:function(){return this._calendar.dayOfWeek(this)},weekDay:function(){return this._calendar.weekDay(this)},extraInfo:function(){return this._calendar.extraInfo(this)},add:function(a,b){return this._calendar.add(this,a,b)},set:function(a,b){return this._calendar.set(this,a,b)},compareTo:function(a){if(this._calendar.name!==a._calendar.name){throw($.calendars.local.differentCalendars||$.calendars.regionalOptions[''].differentCalendars).replace(/\{0\}/,this._calendar.local.name).replace(/\{1\}/,a._calendar.local.name)}var c=(this._year!==a._year?this._year-a._year:this._month!==a._month?this.monthOfYear()-a.monthOfYear():this._day-a._day);return(c===0?0:(c<0?-1:+1))},calendar:function(){return this._calendar},toJD:function(){return this._calendar.toJD(this)},fromJD:function(a){return this._calendar.fromJD(a)},toJSDate:function(){return this._calendar.toJSDate(this)},fromJSDate:function(a){return this._calendar.fromJSDate(a)},toString:function(){return(this.year()<0?'-':'')+pad(Math.abs(this.year()),4)+'-'+pad(this.month(),2)+'-'+pad(this.day(),2)}});function BaseCalendar(){this.shortYearCutoff='+10'}$.extend(BaseCalendar.prototype,{_validateLevel:0,newDate:function(a,b,c){if(a==null){return this.today()}if(a.year){this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);c=a.day();b=a.month();a=a.year()}return new CDate(this,a,b,c)},today:function(){return this.fromJSDate(new Date())},epoch:function(a){var b=this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear||$.calendars.regionalOptions[''].invalidYear);return(b.year()<0?this.local.epochs[0]:this.local.epochs[1])},formatYear:function(a){var b=this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear||$.calendars.regionalOptions[''].invalidYear);return(b.year()<0?'-':'')+pad(Math.abs(b.year()),4)},monthsInYear:function(a){this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear||$.calendars.regionalOptions[''].invalidYear);return 12},monthOfYear:function(a,b){var c=this._validate(a,b,this.minDay,$.calendars.local.invalidMonth||$.calendars.regionalOptions[''].invalidMonth);return(c.month()+this.monthsInYear(c)-this.firstMonth)%this.monthsInYear(c)+this.minMonth},fromMonthOfYear:function(a,b){var m=(b+this.firstMonth-2*this.minMonth)%this.monthsInYear(a)+this.minMonth;this._validate(a,m,this.minDay,$.calendars.local.invalidMonth||$.calendars.regionalOptions[''].invalidMonth);return m},daysInYear:function(a){var b=this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidYear||$.calendars.regionalOptions[''].invalidYear);return(this.leapYear(b)?366:365)},dayOfYear:function(a,b,c){var d=this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);return d.toJD()-this.newDate(d.year(),this.fromMonthOfYear(d.year(),this.minMonth),this.minDay).toJD()+1},daysInWeek:function(){return 7},dayOfWeek:function(a,b,c){var d=this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);return(Math.floor(this.toJD(d))+2)%this.daysInWeek()},extraInfo:function(a,b,c){this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);return{}},add:function(a,b,c){this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);return this._correctAdd(a,this._add(a,b,c),b,c)},_add:function(c,f,g){this._validateLevel++;if(g==='d'||g==='w'){var h=c.toJD()+f*(g==='w'?this.daysInWeek():1);var d=c.calendar().fromJD(h);this._validateLevel--;return[d.year(),d.month(),d.day()]}try{var y=c.year()+(g==='y'?f:0);var m=c.monthOfYear()+(g==='m'?f:0);var d=c.day();var i=function(a){while(mb-1+a.minMonth){y++;m-=b;b=a.monthsInYear(y)}};if(g==='y'){if(c.month()!==this.fromMonthOfYear(y,m)){m=this.newDate(y,c.month(),this.minDay).monthOfYear()}m=Math.min(m,this.monthsInYear(y));d=Math.min(d,this.daysInMonth(y,this.fromMonthOfYear(y,m)))}else if(g==='m'){i(this);d=Math.min(d,this.daysInMonth(y,this.fromMonthOfYear(y,m)))}var j=[y,this.fromMonthOfYear(y,m),d];this._validateLevel--;return j}catch(e){this._validateLevel--;throw e;}},_correctAdd:function(a,b,c,d){if(!this.hasYearZero&&(d==='y'||d==='m')){if(b[0]===0||(a.year()>0)!==(b[0]>0)){var e={y:[1,1,'y'],m:[1,this.monthsInYear(-1),'m'],w:[this.daysInWeek(),this.daysInYear(-1),'d'],d:[1,this.daysInYear(-1),'d']}[d];var f=(c<0?-1:+1);b=this._add(a,c*e[0]+f*e[1],e[2])}}return a.date(b[0],b[1],b[2])},set:function(a,b,c){this._validate(a,this.minMonth,this.minDay,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);var y=(c==='y'?b:a.year());var m=(c==='m'?b:a.month());var d=(c==='d'?b:a.day());if(c==='y'||c==='m'){d=Math.min(d,this.daysInMonth(y,m))}return a.date(y,m,d)},isValid:function(a,b,c){this._validateLevel++;var d=(this.hasYearZero||a!==0);if(d){var e=this.newDate(a,b,this.minDay);d=(b>=this.minMonth&&b-this.minMonth=this.minDay&&c-this.minDay13.5?13:1);var i=c-(h>2.5?4716:4715);if(i<=0){i--}return this.newDate(i,h,g)},toJSDate:function(a,b,c){var d=this._validate(a,b,c,$.calendars.local.invalidDate||$.calendars.regionalOptions[''].invalidDate);var e=new Date(d.year(),d.month()-1,d.day());e.setHours(0);e.setMinutes(0);e.setSeconds(0);e.setMilliseconds(0);e.setHours(e.getHours()>12?e.getHours()+2:0);return e},fromJSDate:function(a){return this.newDate(a.getFullYear(),a.getMonth()+1,a.getDate())}});$.calendars=new Calendars();$.calendars.cdate=CDate;$.calendars.baseCalendar=BaseCalendar;$.calendars.calendars.gregorian=GregorianCalendar})(jQuery);(function($){$.extend($.calendars.regionalOptions[''],{invalidArguments:'Invalid arguments',invalidFormat:'Cannot format a date from another calendar',missingNumberAt:'Missing number at position {0}',unknownNameAt:'Unknown name at position {0}',unexpectedLiteralAt:'Unexpected literal at position {0}',unexpectedText:'Additional text found at end'});$.calendars.local=$.calendars.regionalOptions[''];$.extend($.calendars.cdate.prototype,{formatDate:function(a,b){if(typeof a!=='string'){b=a;a=''}return this._calendar.formatDate(a||'',this,b)}});$.extend($.calendars.baseCalendar.prototype,{UNIX_EPOCH:$.calendars.instance().newDate(1970,1,1).toJD(),SECS_PER_DAY:24*60*60,TICKS_EPOCH:$.calendars.instance().jdEpoch,TICKS_PER_DAY:24*60*60*10000000,ATOM:'yyyy-mm-dd',COOKIE:'D, dd M yyyy',FULL:'DD, MM d, yyyy',ISO_8601:'yyyy-mm-dd',JULIAN:'J',RFC_822:'D, d M yy',RFC_850:'DD, dd-M-yy',RFC_1036:'D, d M yy',RFC_1123:'D, d M yyyy',RFC_2822:'D, d M yyyy',RSS:'D, d M yy',TICKS:'!',TIMESTAMP:'@',W3C:'yyyy-mm-dd',formatDate:function(f,g,h){if(typeof f!=='string'){h=g;g=f;f=''}if(!g){return''}if(g.calendar()!==this){throw $.calendars.local.invalidFormat||$.calendars.regionalOptions[''].invalidFormat;}f=f||this.local.dateFormat;h=h||{};var i=h.dayNamesShort||this.local.dayNamesShort;var j=h.dayNames||this.local.dayNames;var k=h.monthNamesShort||this.local.monthNamesShort;var l=h.monthNames||this.local.monthNames;var m=h.calculateWeek||this.local.calculateWeek;var n=function(a,b){var c=1;while(u+c1};var o=function(a,b,c,d){var e=''+b;if(n(a,d)){while(e.length1};var x=function(a,b){var c=w(a,b);var d=[2,3,c?4:2,c?4:2,10,11,20]['oyYJ@!'.indexOf(a)+1];var e=new RegExp('^-?\\d{1,'+d+'}');var f=h.substring(B).match(e);if(!f){throw($.calendars.local.missingNumberAt||$.calendars.regionalOptions[''].missingNumberAt).replace(/\{0\}/,B)}B+=f[0].length;return parseInt(f[0],10)};var y=this;var z=function(a,b,c,d){var e=(w(a,d)?c:b);for(var i=0;i-1){r=1;s=t;for(var E=this.daysInMonth(q,r);s>E;E=this.daysInMonth(q,r)){r++;s-=E}}return(p>-1?this.fromJD(p):this.newDate(q,r,s))},determineDate:function(f,g,h,i,j){if(h&&typeof h!=='object'){j=i;i=h;h=null}if(typeof i!=='string'){j=i;i=''}var k=this;var l=function(a){try{return k.parseDate(i,a,j)}catch(e){}a=a.toLowerCase();var b=(a.match(/^c/)&&h?h.newDate():null)||k.today();var c=/([+-]?[0-9]+)\s*(d|w|m|y)?/g;var d=c.exec(a);while(d){b.add(parseInt(d[1],10),d[2]||'d');d=c.exec(a)}return b};g=(g?g.newDate():null);f=(f==null?g:(typeof f==='string'?l(f):(typeof f==='number'?(isNaN(f)||f===Infinity||f===-Infinity?g:k.today().add(f,'d')):k.newDate(f))));return f}})})(jQuery);(function($){var H='calendarsPicker';$.JQPlugin.createPlugin({name:H,defaultRenderer:{picker:'
'+'
{link:prev}{link:today}{link:next}
{months}'+'{popup:start}
{link:clear}{link:close}
{popup:end}'+'
',monthRow:'
{months}
',month:'
{monthHeader}
'+'{weekHeader}{weeks}
',weekHeader:'{days}',dayHeader:'{day}',week:'{days}',day:'{day}',monthSelector:'.calendars-month',daySelector:'td',rtlClass:'calendars-rtl',multiClass:'calendars-multi',defaultClass:'',selectedClass:'calendars-selected',highlightedClass:'calendars-highlight',todayClass:'calendars-today',otherMonthClass:'calendars-other-month',weekendClass:'calendars-weekend',commandClass:'calendars-cmd',commandButtonClass:'',commandLinkClass:'',disabledClass:'calendars-disabled'},commands:{prev:{text:'prevText',status:'prevStatus',keystroke:{keyCode:33},enabled:function(a){var b=a.curMinDate();return(!b||a.drawDate.newDate().add(1-a.options.monthsToStep-a.options.monthsOffset,'m').day(a.options.calendar.minDay).add(-1,'d').compareTo(b)!==-1)},date:function(a){return a.drawDate.newDate().add(-a.options.monthsToStep-a.options.monthsOffset,'m').day(a.options.calendar.minDay)},action:function(a){I.changeMonth(this,-a.options.monthsToStep)}},prevJump:{text:'prevJumpText',status:'prevJumpStatus',keystroke:{keyCode:33,ctrlKey:true},enabled:function(a){var b=a.curMinDate();return(!b||a.drawDate.newDate().add(1-a.options.monthsToJump-a.options.monthsOffset,'m').day(a.options.calendar.minDay).add(-1,'d').compareTo(b)!==-1)},date:function(a){return a.drawDate.newDate().add(-a.options.monthsToJump-a.options.monthsOffset,'m').day(a.options.calendar.minDay)},action:function(a){I.changeMonth(this,-a.options.monthsToJump)}},next:{text:'nextText',status:'nextStatus',keystroke:{keyCode:34},enabled:function(a){var b=a.get('maxDate');return(!b||a.drawDate.newDate().add(a.options.monthsToStep-a.options.monthsOffset,'m').day(a.options.calendar.minDay).compareTo(b)!==+1)},date:function(a){return a.drawDate.newDate().add(a.options.monthsToStep-a.options.monthsOffset,'m').day(a.options.calendar.minDay)},action:function(a){I.changeMonth(this,a.options.monthsToStep)}},nextJump:{text:'nextJumpText',status:'nextJumpStatus',keystroke:{keyCode:34,ctrlKey:true},enabled:function(a){var b=a.get('maxDate');return(!b||a.drawDate.newDate().add(a.options.monthsToJump-a.options.monthsOffset,'m').day(a.options.calendar.minDay).compareTo(b)!==+1)},date:function(a){return a.drawDate.newDate().add(a.options.monthsToJump-a.options.monthsOffset,'m').day(a.options.calendar.minDay)},action:function(a){I.changeMonth(this,a.options.monthsToJump)}},current:{text:'currentText',status:'currentStatus',keystroke:{keyCode:36,ctrlKey:true},enabled:function(a){var b=a.curMinDate();var c=a.get('maxDate');var d=a.selectedDates[0]||a.options.calendar.today();return(!b||d.compareTo(b)!==-1)&&(!c||d.compareTo(c)!==+1)},date:function(a){return a.selectedDates[0]||a.options.calendar.today()},action:function(a){var b=a.selectedDates[0]||a.options.calendar.today();I.showMonth(this,b.year(),b.month())}},today:{text:'todayText',status:'todayStatus',keystroke:{keyCode:36,ctrlKey:true},enabled:function(a){var b=a.curMinDate();var c=a.get('maxDate');return(!b||a.options.calendar.today().compareTo(b)!==-1)&&(!c||a.options.calendar.today().compareTo(c)!==+1)},date:function(a){return a.options.calendar.today()},action:function(a){I.showMonth(this)}},clear:{text:'clearText',status:'clearStatus',keystroke:{keyCode:35,ctrlKey:true},enabled:function(a){return true},date:function(a){return null},action:function(a){I.clear(this)}},close:{text:'closeText',status:'closeStatus',keystroke:{keyCode:27},enabled:function(a){return true},date:function(a){return null},action:function(a){I.hide(this)}},prevWeek:{text:'prevWeekText',status:'prevWeekStatus',keystroke:{keyCode:38,ctrlKey:true},enabled:function(a){var b=a.curMinDate();return(!b||a.drawDate.newDate().add(-a.options.calendar.daysInWeek(),'d').compareTo(b)!==-1)},date:function(a){return a.drawDate.newDate().add(-a.options.calendar.daysInWeek(),'d')},action:function(a){I.changeDay(this,-a.options.calendar.daysInWeek())}},prevDay:{text:'prevDayText',status:'prevDayStatus',keystroke:{keyCode:37,ctrlKey:true},enabled:function(a){var b=a.curMinDate();return(!b||a.drawDate.newDate().add(-1,'d').compareTo(b)!==-1)},date:function(a){return a.drawDate.newDate().add(-1,'d')},action:function(a){I.changeDay(this,-1)}},nextDay:{text:'nextDayText',status:'nextDayStatus',keystroke:{keyCode:39,ctrlKey:true},enabled:function(a){var b=a.get('maxDate');return(!b||a.drawDate.newDate().add(1,'d').compareTo(b)!==+1)},date:function(a){return a.drawDate.newDate().add(1,'d')},action:function(a){I.changeDay(this,1)}},nextWeek:{text:'nextWeekText',status:'nextWeekStatus',keystroke:{keyCode:40,ctrlKey:true},enabled:function(a){var b=a.get('maxDate');return(!b||a.drawDate.newDate().add(a.options.calendar.daysInWeek(),'d').compareTo(b)!==+1)},date:function(a){return a.drawDate.newDate().add(a.options.calendar.daysInWeek(),'d')},action:function(a){I.changeDay(this,a.options.calendar.daysInWeek())}}},defaultOptions:{calendar:$.calendars.instance(),pickerClass:'',showOnFocus:true,showTrigger:null,showAnim:'show',showOptions:{},showSpeed:'normal',popupContainer:null,alignment:'bottom',fixedWeeks:false,firstDay:null,calculateWeek:null,localNumbers:false,monthsToShow:1,monthsOffset:0,monthsToStep:1,monthsToJump:12,useMouseWheel:true,changeMonth:true,yearRange:'c-10:c+10',showOtherMonths:false,selectOtherMonths:false,defaultDate:null,selectDefaultDate:false,minDate:null,maxDate:null,dateFormat:null,autoSize:false,rangeSelect:false,rangeSeparator:' - ',multiSelect:0,multiSeparator:',',onDate:null,onShow:null,onChangeMonthYear:null,onSelect:null,onClose:null,altField:null,altFormat:null,constrainInput:true,commandsAsDateFormat:false,commands:{}},regionalOptions:{'':{renderer:{},prevText:'<Prev',prevStatus:'Show the previous month',prevJumpText:'<<',prevJumpStatus:'Show the previous year',nextText:'Next>',nextStatus:'Show the next month',nextJumpText:'>>',nextJumpStatus:'Show the next year',currentText:'Current',currentStatus:'Show the current month',todayText:'Today',todayStatus:'Show today\'s month',clearText:'Clear',clearStatus:'Clear all the dates',closeText:'Close',closeStatus:'Close the datepicker',yearStatus:'Change the year',earlierText:'  ▲',laterText:'  ▼',monthStatus:'Change the month',weekText:'Wk',weekStatus:'Week of the year',dayStatus:'Select DD, M d, yyyy',defaultStatus:'Select a date',isRTL:false}},_getters:['getDate','isDisabled','isSelectable','retrieveDate'],_disabled:[],_popupClass:'calendars-popup',_triggerClass:'calendars-trigger',_disableClass:'calendars-disable',_monthYearClass:'calendars-month-year',_curMonthClass:'calendars-month-',_anyYearClass:'calendars-any-year',_curDoWClass:'calendars-dow-',_init:function(){this.defaultOptions.commands=this.commands;this.regionalOptions[''].renderer=this.defaultRenderer;this._super()},_instSettings:function(b,c){return{selectedDates:[],drawDate:null,pickingRange:false,inline:($.inArray(b[0].nodeName.toLowerCase(),['div','span'])>-1),get:function(a){if($.inArray(a,['defaultDate','minDate','maxDate'])>-1){return this.options.calendar.determineDate(this.options[a],null,this.selectedDates[0],this.get('dateFormat'),this.getConfig())}if(a==='dateFormat'){return this.options.dateFormat||this.options.calendar.local.dateFormat}return this.options[a]},curMinDate:function(){return(this.pickingRange?this.selectedDates[0]:this.get('minDate'))},getConfig:function(){return{dayNamesShort:this.options.dayNamesShort,dayNames:this.options.dayNames,monthNamesShort:this.options.monthNamesShort,monthNames:this.options.monthNames,calculateWeek:this.options.calculateWeek,shortYearCutoff:this.options.shortYearCutoff}}}},_postAttach:function(a,b){if(b.inline){b.drawDate=I._checkMinMax((b.selectedDates[0]||b.get('defaultDate')||b.options.calendar.today()).newDate(),b);b.prevDate=b.drawDate.newDate();this._update(a[0]);if($.fn.mousewheel){a.mousewheel(this._doMouseWheel)}}else{this._attachments(a,b);a.on('keydown.'+b.name,this._keyDown).on('keypress.'+b.name,this._keyPress).on('keyup.'+b.name,this._keyUp);if(a.attr('disabled')){this.disable(a[0])}}},_optionsChanged:function(b,c,d){if(d.calendar&&d.calendar!==c.options.calendar){var e=function(a){return(typeof c.options[a]==='object'?null:c.options[a])};d=$.extend({defaultDate:e('defaultDate'),minDate:e('minDate'),maxDate:e('maxDate')},d);c.selectedDates=[];c.drawDate=null}var f=c.selectedDates;$.extend(c.options,d);this.setDate(b[0],f,null,false,true);c.pickingRange=false;var g=c.options.calendar;var h=c.get('defaultDate');c.drawDate=this._checkMinMax((h?h:c.drawDate)||h||g.today(),c).newDate();if(!c.inline){this._attachments(b,c)}if(c.inline||c.div){this._update(b[0])}},_attachments:function(a,b){a.off('focus.'+b.name);if(b.options.showOnFocus){a.on('focus.'+b.name,this.show)}if(b.trigger){b.trigger.remove()}var c=b.options.showTrigger;b.trigger=(!c?$([]):$(c).clone().removeAttr('id').addClass(this._triggerClass)[b.options.isRTL?'insertBefore':'insertAfter'](a).click(function(){if(!I.isDisabled(a[0])){I[I.curInst===b?'hide':'show'](a[0])}}));this._autoSize(a,b);var d=this._extractDates(b,a.val());if(d){this.setDate(a[0],d,null,true)}var e=b.get('defaultDate');if(b.options.selectDefaultDate&&e&&b.selectedDates.length===0){this.setDate(a[0],(e||b.options.calendar.today()).newDate())}},_autoSize:function(d,e){if(e.options.autoSize&&!e.inline){var f=e.options.calendar;var g=f.newDate(2009,10,20);var h=e.get('dateFormat');if(h.match(/[DM]/)){var j=function(a){var b=0;var c=0;for(var i=0;ib){b=a[i].length;c=i}}return c};g.month(j(f.local[h.match(/MM/)?'monthNames':'monthNamesShort'])+1);g.day(j(f.local[h.match(/DD/)?'dayNames':'dayNamesShort'])+20-g.dayOfWeek())}e.elem.attr('size',g.formatDate(h,{localNumbers:e.options.localnumbers}).length)}},_preDestroy:function(a,b){if(b.trigger){b.trigger.remove()}a.empty().off('.'+b.name);if(b.inline&&$.fn.mousewheel){a.unmousewheel()}if(!b.inline&&b.options.autoSize){a.removeAttr('size')}},multipleEvents:function(b){var c=arguments;return function(a){for(var i=0;i').find('button,select').prop('disabled',true).end().find('a').removeAttr('href')}else{b.prop('disabled',true);c.trigger.filter('button.'+this._triggerClass).prop('disabled',true).end().filter('img.'+this._triggerClass).css({opacity:'0.5',cursor:'default'})}this._disabled=$.map(this._disabled,function(a){return(a===b[0]?null:a)});this._disabled.push(b[0])},isDisabled:function(a){return(a&&$.inArray(a,this._disabled)>-1)},show:function(a){a=$(a.target||a);var b=I._getInst(a);if(I.curInst===b){return}if(I.curInst){I.hide(I.curInst,true)}if(!$.isEmptyObject(b)){b.lastVal=null;b.selectedDates=I._extractDates(b,a.val());b.pickingRange=false;b.drawDate=I._checkMinMax((b.selectedDates[0]||b.get('defaultDate')||b.options.calendar.today()).newDate(),b);b.prevDate=b.drawDate.newDate();I.curInst=b;I._update(a[0],true);var c=I._checkOffset(b);b.div.css({left:c.left,top:c.top});var d=b.options.showAnim;var e=b.options.showSpeed;e=(e==='normal'&&$.ui&&parseInt($.ui.version.substring(2))>=8?'_default':e);if($.effects&&($.effects[d]||($.effects.effect&&$.effects.effect[d]))){var f=b.div.data();for(var g in f){if(g.match(/^ec\.storage\./)){f[g]=b._mainDiv.css(g.replace(/ec\.storage\./,''))}}b.div.data(f).show(d,b.options.showOptions,e)}else{b.div[d||'show'](d?e:0)}}},_extractDates:function(a,b){if(b===a.lastVal){return}a.lastVal=b;b=b.split(a.options.multiSelect?a.options.multiSeparator:(a.options.rangeSelect?a.options.rangeSeparator:'\x00'));var c=[];for(var i=0;i').addClass(this._popupClass).css({display:(b?'none':'static'),position:'absolute',left:a.offset().left,top:a.offset().top+a.outerHeight()}).appendTo($(c.options.popupContainer||'body'));if($.fn.mousewheel){c.div.mousewheel(this._doMouseWheel)}}c.div.html(this._generateContent(a[0],c));a.focus()}}},_updateInput:function(a,b){var c=this._getInst(a);if(!$.isEmptyObject(c)){var d='';var e='';var f=(c.options.multiSelect?c.options.multiSeparator:c.options.rangeSeparator);var g=c.options.calendar;var h=c.get('dateFormat');var j=c.options.altFormat||h;var k={localNumbers:c.options.localNumbers};for(var i=0;i0?f:'')+g.formatDate(h,c.selectedDates[i],k));e+=(i>0?f:'')+g.formatDate(j,c.selectedDates[i],k)}if(!c.inline&&!b){$(a).val(d)}$(c.options.altField).val(e);if($.isFunction(c.options.onSelect)&&!b&&!c.inSelect){c.inSelect=true;c.options.onSelect.apply(a,[c.selectedDates]);c.inSelect=false}}},_getBorders:function(b){var c=function(a){return{thin:1,medium:3,thick:5}[a]||a};return[parseFloat(c(b.css('border-left-width'))),parseFloat(c(b.css('border-top-width')))]},_checkOffset:function(a){var b=(a.elem.is(':hidden')&&a.trigger?a.trigger:a.elem);var c=b.offset();var d=$(window).width();var e=$(window).height();if(d===0){return c}var f=false;$(a.elem).parents().each(function(){f|=$(this).css('position')==='fixed';return!f});var g=document.documentElement.scrollLeft||document.body.scrollLeft;var h=document.documentElement.scrollTop||document.body.scrollTop;var i=c.top-(f?h:0)-a.div.outerHeight();var j=c.top-(f?h:0)+b.outerHeight();var k=c.left-(f?g:0);var l=c.left-(f?g:0)+b.outerWidth()-a.div.outerWidth();var m=(c.left-g+a.div.outerWidth())>d;var n=(c.top-h+a.elem.outerHeight()+a.div.outerHeight())>e;a.div.css('position',f?'fixed':'absolute');var o=a.options.alignment;if(o==='topLeft'){c={left:k,top:i}}else if(o==='topRight'){c={left:l,top:i}}else if(o==='bottomLeft'){c={left:k,top:j}}else if(o==='bottomRight'){c={left:l,top:j}}else if(o==='top'){c={left:(a.options.isRTL||m?l:k),top:i}}else{c={left:(a.options.isRTL||m?l:k),top:(n?i:j)}}c.left=Math.max((f?0:g),c.left);c.top=Math.max((f?0:h),c.top);return c},_checkExternalClick:function(a){if(!I.curInst){return}var b=$(a.target);if(b.closest('.'+I._popupClass+',.'+I._triggerClass).length===0&&!b.hasClass(I._getMarker())){I.hide(I.curInst)}},hide:function(a,b){if(!a){return}var c=this._getInst(a);if($.isEmptyObject(c)){c=a}if(c&&c===I.curInst){var d=(b?'':c.options.showAnim);var e=c.options.showSpeed;e=(e==='normal'&&$.ui&&parseInt($.ui.version.substring(2))>=8?'_default':e);var f=function(){if(!c.div){return}c.div.remove();c.div=null;I.curInst=null;if($.isFunction(c.options.onClose)){c.options.onClose.apply(a,[c.selectedDates])}};c.div.stop();if($.effects&&($.effects[d]||($.effects.effect&&$.effects.effect[d]))){c.div.hide(d,c.options.showOptions,e,f)}else{var g=(d==='slideDown'?'slideUp':(d==='fadeIn'?'fadeOut':'hide'));c.div[g]((d?e:''),f)}if(!d){f()}}},_keyDown:function(a){var b=(a.data&&a.data.elem)||a.target;var c=I._getInst(b);var d=false;if(c.inline||c.div){if(a.keyCode===9){I.hide(b)}else if(a.keyCode===13){I.selectDate(b,$('a.'+c.options.renderer.highlightedClass,c.div)[0]);d=true}else{var e=c.options.commands;for(var f in e){var g=e[f];if(g.keystroke.keyCode===a.keyCode&&!!g.keystroke.ctrlKey===!!(a.ctrlKey||a.metaKey)&&!!g.keystroke.altKey===a.altKey&&!!g.keystroke.shiftKey===a.shiftKey){I.performAction(b,f);d=true;break}}}}else{var g=c.options.commands.current;if(g.keystroke.keyCode===a.keyCode&&!!g.keystroke.ctrlKey===!!(a.ctrlKey||a.metaKey)&&!!g.keystroke.altKey===a.altKey&&!!g.keystroke.shiftKey===a.shiftKey){I.show(b);d=true}}c.ctrlKey=((a.keyCode<48&&a.keyCode!==32)||a.ctrlKey||a.metaKey);if(d){a.preventDefault();a.stopPropagation()}return!d},_keyPress:function(a){var b=I._getInst((a.data&&a.data.elem)||a.target);if(!$.isEmptyObject(b)&&b.options.constrainInput){var c=String.fromCharCode(a.keyCode||a.charCode);var d=I._allowedChars(b);return(a.metaKey||b.ctrlKey||c<' '||!d||d.indexOf(c)>-1)}return true},_allowedChars:function(a){var b=(a.options.multiSelect?a.options.multiSeparator:(a.options.rangeSelect?a.options.rangeSeparator:''));var c=false;var d=false;var e=a.get('dateFormat');for(var i=0;i0){I.setDate(b,d,null,true)}}catch(a){}}return true},_doMouseWheel:function(a,b){var c=(I.curInst&&I.curInst.elem[0])||$(a.target).closest('.'+I._getMarker())[0];if(I.isDisabled(c)){return}var d=I._getInst(c);if(d.options.useMouseWheel){b=(b<0?-1:+1);I.changeMonth(c,-d.options[a.ctrlKey?'monthsToJump':'monthsToStep']*b)}a.preventDefault()},clear:function(a){var b=this._getInst(a);if(!$.isEmptyObject(b)){b.selectedDates=[];this.hide(a);var c=b.get('defaultDate');if(b.options.selectDefaultDate&&c){this.setDate(a,(c||b.options.calendar.today()).newDate())}else{this._updateInput(a)}}},getDate:function(a){var b=this._getInst(a);return(!$.isEmptyObject(b)?b.selectedDates:[])},setDate:function(a,b,c,d,e){var f=this._getInst(a);if(!$.isEmptyObject(f)){if(!$.isArray(b)){b=[b];if(c){b.push(c)}}var g=f.get('minDate');var h=f.get('maxDate');var k=f.selectedDates[0];f.selectedDates=[];for(var i=0;i=d.toJD())&&(!e||b.toJD()<=e.toJD())},performAction:function(a,b){var c=this._getInst(a);if(!$.isEmptyObject(c)&&!this.isDisabled(a)){var d=c.options.commands;if(d[b]&&d[b].enabled.apply(a,[c])){d[b].action.apply(a,[c])}}},showMonth:function(a,b,c,d){var e=this._getInst(a);if(!$.isEmptyObject(e)&&(d!=null||(e.drawDate.year()!==b||e.drawDate.month()!==c))){e.prevDate=e.drawDate.newDate();var f=e.options.calendar;var g=this._checkMinMax((b!=null?f.newDate(b,c,1):f.today()),e);e.drawDate.date(g.year(),g.month(),(d!=null?d:Math.min(e.drawDate.day(),f.daysInMonth(g.year(),g.month()))));this._update(a)}},changeMonth:function(a,b){var c=this._getInst(a);if(!$.isEmptyObject(c)){var d=c.drawDate.newDate().add(b,'m');this.showMonth(a,d.year(),d.month())}},changeDay:function(a,b){var c=this._getInst(a);if(!$.isEmptyObject(c)){var d=c.drawDate.newDate().add(b,'d');this.showMonth(a,d.year(),d.month(),d.day())}},_checkMinMax:function(a,b){var c=b.get('minDate');var d=b.get('maxDate');a=(c&&a.compareTo(c)===-1?c.newDate():a);a=(d&&a.compareTo(d)===+1?d.newDate():a);return a},retrieveDate:function(a,b){var c=this._getInst(a);return($.isEmptyObject(c)?null:c.options.calendar.fromJD(parseFloat(b.className.replace(/^.*jd(\d+\.5).*$/,'$1'))))},selectDate:function(a,b){var c=this._getInst(a);if(!$.isEmptyObject(c)&&!this.isDisabled(a)){var d=this.retrieveDate(a,b);if(c.options.multiSelect){var e=false;for(var i=0;i'+(g?g.formatDate(i.options[f.text],{localNumbers:i.options.localNumbers}):i.options[f.text])+'')};for(var r in i.options.commands){q('button','button type="button"','button',r,i.options.renderer.commandButtonClass);q('link','a href="javascript:void(0)"','a',r,i.options.renderer.commandLinkClass)}p=$(p);if(j[1]>1){var s=0;$(i.options.renderer.monthSelector,p).each(function(){var a=++s%j[1];$(this).addClass(a===1?'first':(a===0?'last':''))})}var t=this;function removeHighlight(){(i.inline?$(this).closest('.'+t._getMarker()):i.div).find(i.options.renderer.daySelector+' a').removeClass(i.options.renderer.highlightedClass)}p.find(i.options.renderer.daySelector+' a').hover(function(){removeHighlight.apply(this);$(this).addClass(i.options.renderer.highlightedClass)},removeHighlight).click(function(){t.selectDate(h,this)}).end().find('select.'+this._monthYearClass+':not(.'+this._anyYearClass+')').change(function(){var a=$(this).val().split('/');t.showMonth(h,parseInt(a[1],10),parseInt(a[0],10))}).end().find('select.'+this._anyYearClass).click(function(){$(this).css('visibility','hidden').next('input').css({left:this.offsetLeft,top:this.offsetTop,width:this.offsetWidth,height:this.offsetHeight}).show().focus()}).end().find('input.'+t._monthYearClass).change(function(){try{var a=parseInt($(this).val(),10);a=(isNaN(a)?i.drawDate.year():a);t.showMonth(h,a,i.drawDate.month(),i.drawDate.day())}catch(e){alert(e)}}).keydown(function(a){if(a.keyCode===13){$(a.elem).change()}else if(a.keyCode===27){$(a.elem).hide().prev('select').css('visibility','visible');i.elem.focus()}});var u={elem:i.elem[0]};p.keydown(u,this._keyDown).keypress(u,this._keyPress).keyup(u,this._keyUp);p.find('.'+i.options.renderer.commandClass).click(function(){if(!$(this).hasClass(i.options.renderer.disabledClass)){var a=this.className.replace(new RegExp('^.*'+i.options.renderer.commandClass+'-([^ ]+).*$'),'$1');I.performAction(h,a)}});if(i.options.isRTL){p.addClass(i.options.renderer.rtlClass)}if(j[0]*j[1]>1){p.addClass(i.options.renderer.multiClass)}if(i.options.pickerClass){p.addClass(i.options.pickerClass)}$('body').append(p);var v=0;p.find(i.options.renderer.monthSelector).each(function(){v+=$(this).outerWidth()});p.width(v/j[0]);if($.isFunction(i.options.onShow)){i.options.onShow.apply(h,[p,i.options.calendar,i])}return p},_generateMonth:function(b,c,d,e,f,g,h){var j=f.daysInMonth(d,e);var k=c.options.monthsToShow;k=($.isArray(k)?k:[1,k]);var l=c.options.fixedWeeks||(k[0]*k[1]>1);var m=c.options.firstDay;m=(m==null?f.local.firstDay:m);var n=(f.dayOfWeek(d,e,f.minDay)-m+f.daysInWeek())%f.daysInWeek();var o=(l?6:Math.ceil((n+j)/f.daysInWeek()));var p=c.options.selectOtherMonths&&c.options.showOtherMonths;var q=(c.pickingRange?c.selectedDates[0]:c.get('minDate'));var r=c.get('maxDate');var s=g.week.indexOf('{weekOfYear}')>-1;var t=f.today();var u=f.newDate(d,e,f.minDay);u.add(-n-(l&&(u.dayOfWeek()===m||u.daysInMonth()'+($.isFunction(c.options.calculateWeek)?c.options.calculateWeek(u):u.weekOfYear())+'');var A='';for(var B=0;B0){C=(u.compareTo(c.selectedDates[0])!==-1&&u.compareTo(c.selectedDates[1])!==+1)}else{for(var i=0;i'+(c.options.showOtherMonths||u.month()===e?D.content||w(u.day()):' ')+(E?'':''));u.add(1,'d');v++}x+=this._prepare(g.week,c).replace(/\{days\}/g,A).replace(/\{weekOfYear\}/g,z)}var F=this._prepare(g.month,c).match(/\{monthHeader(:[^\}]+)?\}/);F=(F[0].length<=13?'MM yyyy':F[0].substring(13,F[0].length-1));F=(h?this._generateMonthSelection(c,d,e,q,r,F,f,g):f.formatDate(F,f.newDate(d,e,f.minDay),{localNumbers:c.options.localNumbers}));var G=this._prepare(g.weekHeader,c).replace(/\{days\}/g,this._generateDayHeaders(c,f,g));return this._prepare(g.month,c).replace(/\{monthHeader(:[^\}]+)?\}/g,F).replace(/\{weekHeader\}/g,G).replace(/\{weeks\}/g,x)},_generateDayHeaders:function(a,b,c){var d=a.options.firstDay;d=(d==null?b.local.firstDay:d);var e='';for(var f=0;f'+b.local.dayNamesMin[g]+'')}return e},_generateMonthSelection:function(b,c,d,e,f,g,h){if(!b.options.changeMonth){return h.formatDate(g,h.newDate(c,d,1),{localNumbers:b.options.localNumbers})}var i=h.local['monthNames'+(g.match(/mm/i)?'':'Short')];var j=g.replace(/m+/i,'\\x2E').replace(/y+/i,'\\x2F');var k='';j=j.replace(/\\x2E/,k);var n=b.options.yearRange;if(n==='any'){k=''+''}else{n=n.split(':');var o=h.today().year();var p=(n[0].match('c[+-].*')?c+parseInt(n[0].substring(1),10):((n[0].match('[+-].*')?o:0)+parseInt(n[0],10)));var q=(n[1].match('c[+-].*')?c+parseInt(n[1].substring(1),10):((n[1].match('[+-].*')?o:0)+parseInt(n[1],10)));k='';var l=h.monthsInYear(c)+h.minMonth;for(var m=h.minMonth;m'+i[m-h.minMonth]+''}}k+='';j=j.replace(/\\x2E/,k);var n=b.options.yearRange;if(n==='any'){k=''+''}else{n=n.split(':');var o=h.today().year();var p=(n[0].match('c[+-].*')?c+parseInt(n[0].substring(1),10):((n[0].match('[+-].*')?o:0)+parseInt(n[0],10)));var q=(n[1].match('c[+-].*')?c+parseInt(n[1].substring(1),10):((n[1].match('[+-].*')?o:0)+parseInt(n[1],10)));k='