2 * Datepicker for Bootstrap v1.9.0 (https://github.com/uxsolutions/bootstrap-datepicker)
4 * Licensed under the Apache License v2.0 (http://www.apache.org/licenses/LICENSE-2.0)
8 if (typeof define === 'function' && define.amd) {
9 define(['jquery'], factory);
10 } else if (typeof exports === 'object') {
11 factory(require('jquery'));
15 }(function($, undefined){
17 return new Date(Date.UTC.apply(Date, arguments));
20 var today = new Date();
21 return UTCDate(today.getFullYear(), today.getMonth(), today.getDate());
23 function isUTCEquals(date1, date2) {
25 date1.getUTCFullYear() === date2.getUTCFullYear() &&
26 date1.getUTCMonth() === date2.getUTCMonth() &&
27 date1.getUTCDate() === date2.getUTCDate()
30 function alias(method, deprecationMsg){
32 if (deprecationMsg !== undefined) {
33 $.fn.datepicker.deprecated(deprecationMsg);
36 return this[method].apply(this, arguments);
39 function isValidDate(d) {
40 return d && !isNaN(d.getTime());
43 var DateArray = (function(){
46 return this.slice(i)[0];
48 contains: function(d){
49 // Array.indexOf is not cross-browser;
50 // $.inArray doesn't work with Dates
51 var val = d && d.valueOf();
52 for (var i=0, l=this.length; i < l; i++)
53 // Use date arithmetic to allow dates with different times to match
54 if (0 <= this[i].valueOf() - val && this[i].valueOf() - val < 1000*60*60*24)
61 replace: function(new_array){
64 if (!$.isArray(new_array))
65 new_array = [new_array];
67 this.push.apply(this, new_array);
73 var a = new DateArray();
81 a.push.apply(a, arguments);
90 var Datepicker = function(element, options){
91 $.data(element, 'datepicker', this);
94 this._secondaryEvents = [];
96 this._process_options(options);
98 this.dates = new DateArray();
99 this.viewDate = this.o.defaultViewDate;
100 this.focusDate = null;
102 this.element = $(element);
103 this.isInput = this.element.is('input');
104 this.inputField = this.isInput ? this.element : this.element.find('input');
105 this.component = this.element.hasClass('date') ? this.element.find('.add-on, .input-group-addon, .input-group-append, .input-group-prepend, .btn') : false;
106 if (this.component && this.component.length === 0)
107 this.component = false;
108 this.isInline = !this.component && this.element.is('div');
110 this.picker = $(DPGlobal.template);
112 // Checking templates and inserting
113 if (this._check_template(this.o.templates.leftArrow)) {
114 this.picker.find('.prev').html(this.o.templates.leftArrow);
117 if (this._check_template(this.o.templates.rightArrow)) {
118 this.picker.find('.next').html(this.o.templates.rightArrow);
122 this._attachEvents();
125 this.picker.addClass('datepicker-inline').appendTo(this.element);
128 this.picker.addClass('datepicker-dropdown dropdown-menu');
132 this.picker.addClass('datepicker-rtl');
135 if (this.o.calendarWeeks) {
136 this.picker.find('.datepicker-days .datepicker-switch, thead .datepicker-title, tfoot .today, tfoot .clear')
137 .attr('colspan', function(i, val){
138 return Number(val) + 1;
142 this._process_options({
143 startDate: this._o.startDate,
144 endDate: this._o.endDate,
145 daysOfWeekDisabled: this.o.daysOfWeekDisabled,
146 daysOfWeekHighlighted: this.o.daysOfWeekHighlighted,
147 datesDisabled: this.o.datesDisabled
150 this._allow_update = false;
151 this.setViewMode(this.o.startView);
152 this._allow_update = true;
164 Datepicker.prototype = {
165 constructor: Datepicker,
167 _resolveViewName: function(view){
168 $.each(DPGlobal.viewModes, function(i, viewMode){
169 if (view === i || $.inArray(view, viewMode.names) !== -1){
178 _resolveDaysOfWeek: function(daysOfWeek){
179 if (!$.isArray(daysOfWeek))
180 daysOfWeek = daysOfWeek.split(/[,\s]*/);
181 return $.map(daysOfWeek, Number);
184 _check_template: function(tmp){
187 if (tmp === undefined || tmp === "") {
190 // If no html, everything ok
191 if ((tmp.match(/[<>]/g) || []).length <= 0) {
194 // Checking if html is fine
196 return jDom.length > 0;
203 _process_options: function(opts){
204 // Store raw options for reference
205 this._o = $.extend({}, this._o, opts);
207 var o = this.o = $.extend({}, this._o);
209 // Check if "de-DE" style date is available, if not language should
210 // fallback to 2 letter code eg "de"
211 var lang = o.language;
213 lang = lang.split('-')[0];
215 lang = defaults.language;
219 // Retrieve view index from any aliases
220 o.startView = this._resolveViewName(o.startView);
221 o.minViewMode = this._resolveViewName(o.minViewMode);
222 o.maxViewMode = this._resolveViewName(o.maxViewMode);
224 // Check view is between min and max
225 o.startView = Math.max(this.o.minViewMode, Math.min(this.o.maxViewMode, o.startView));
227 // true, false, or Number > 0
228 if (o.multidate !== true){
229 o.multidate = Number(o.multidate) || false;
230 if (o.multidate !== false)
231 o.multidate = Math.max(0, o.multidate);
233 o.multidateSeparator = String(o.multidateSeparator);
236 o.weekEnd = (o.weekStart + 6) % 7;
238 var format = DPGlobal.parseFormat(o.format);
239 if (o.startDate !== -Infinity){
241 if (o.startDate instanceof Date)
242 o.startDate = this._local_to_utc(this._zero_time(o.startDate));
244 o.startDate = DPGlobal.parseDate(o.startDate, format, o.language, o.assumeNearbyYear);
247 o.startDate = -Infinity;
250 if (o.endDate !== Infinity){
252 if (o.endDate instanceof Date)
253 o.endDate = this._local_to_utc(this._zero_time(o.endDate));
255 o.endDate = DPGlobal.parseDate(o.endDate, format, o.language, o.assumeNearbyYear);
258 o.endDate = Infinity;
262 o.daysOfWeekDisabled = this._resolveDaysOfWeek(o.daysOfWeekDisabled||[]);
263 o.daysOfWeekHighlighted = this._resolveDaysOfWeek(o.daysOfWeekHighlighted||[]);
265 o.datesDisabled = o.datesDisabled||[];
266 if (!$.isArray(o.datesDisabled)) {
267 o.datesDisabled = o.datesDisabled.split(',');
269 o.datesDisabled = $.map(o.datesDisabled, function(d){
270 return DPGlobal.parseDate(d, format, o.language, o.assumeNearbyYear);
273 var plc = String(o.orientation).toLowerCase().split(/\s+/g),
274 _plc = o.orientation.toLowerCase();
275 plc = $.grep(plc, function(word){
276 return /^auto|left|right|top|bottom$/.test(word);
278 o.orientation = {x: 'auto', y: 'auto'};
279 if (!_plc || _plc === 'auto')
281 else if (plc.length === 1){
285 o.orientation.y = plc[0];
289 o.orientation.x = plc[0];
294 _plc = $.grep(plc, function(word){
295 return /^left|right$/.test(word);
297 o.orientation.x = _plc[0] || 'auto';
299 _plc = $.grep(plc, function(word){
300 return /^top|bottom$/.test(word);
302 o.orientation.y = _plc[0] || 'auto';
304 if (o.defaultViewDate instanceof Date || typeof o.defaultViewDate === 'string') {
305 o.defaultViewDate = DPGlobal.parseDate(o.defaultViewDate, format, o.language, o.assumeNearbyYear);
306 } else if (o.defaultViewDate) {
307 var year = o.defaultViewDate.year || new Date().getFullYear();
308 var month = o.defaultViewDate.month || 0;
309 var day = o.defaultViewDate.day || 1;
310 o.defaultViewDate = UTCDate(year, month, day);
312 o.defaultViewDate = UTCToday();
315 _applyEvents: function(evs){
316 for (var i=0, el, ch, ev; i < evs.length; i++){
318 if (evs[i].length === 2){
321 } else if (evs[i].length === 3){
328 _unapplyEvents: function(evs){
329 for (var i=0, el, ev, ch; i < evs.length; i++){
331 if (evs[i].length === 2){
334 } else if (evs[i].length === 3){
341 _buildEvents: function(){
343 keyup: $.proxy(function(e){
344 if ($.inArray(e.keyCode, [27, 37, 39, 38, 40, 32, 13, 9]) === -1)
347 keydown: $.proxy(this.keydown, this),
348 paste: $.proxy(this.paste, this)
351 if (this.o.showOnFocus === true) {
352 events.focus = $.proxy(this.show, this);
355 if (this.isInput) { // single input
357 [this.element, events]
360 // component: input + button
361 else if (this.component && this.inputField.length) {
363 // For components that are not readonly, allow keyboard nav
364 [this.inputField, events],
366 click: $.proxy(this.show, this)
373 click: $.proxy(this.show, this),
374 keydown: $.proxy(this.keydown, this)
379 // Component: listen for blur on element descendants
380 [this.element, '*', {
381 blur: $.proxy(function(e){
382 this._focused_from = e.target;
385 // Input: listen for blur on element
387 blur: $.proxy(function(e){
388 this._focused_from = e.target;
393 if (this.o.immediateUpdates) {
394 // Trigger input updates immediately on changed year/month
395 this._events.push([this.element, {
396 'changeYear changeMonth': $.proxy(function(e){
402 this._secondaryEvents = [
404 click: $.proxy(this.click, this)
406 [this.picker, '.prev, .next', {
407 click: $.proxy(this.navArrowsClick, this)
409 [this.picker, '.day:not(.disabled)', {
410 click: $.proxy(this.dayCellClick, this)
413 resize: $.proxy(this.place, this)
416 'mousedown touchstart': $.proxy(function(e){
417 // Clicked outside the datepicker, hide it
419 this.element.is(e.target) ||
420 this.element.find(e.target).length ||
421 this.picker.is(e.target) ||
422 this.picker.find(e.target).length ||
431 _attachEvents: function(){
432 this._detachEvents();
433 this._applyEvents(this._events);
435 _detachEvents: function(){
436 this._unapplyEvents(this._events);
438 _attachSecondaryEvents: function(){
439 this._detachSecondaryEvents();
440 this._applyEvents(this._secondaryEvents);
442 _detachSecondaryEvents: function(){
443 this._unapplyEvents(this._secondaryEvents);
445 _trigger: function(event, altdate){
446 var date = altdate || this.dates.get(-1),
447 local_date = this._utc_to_local(date);
449 this.element.trigger({
452 viewMode: this.viewMode,
453 dates: $.map(this.dates, this._utc_to_local),
454 format: $.proxy(function(ix, format){
455 if (arguments.length === 0){
456 ix = this.dates.length - 1;
457 format = this.o.format;
458 } else if (typeof ix === 'string'){
460 ix = this.dates.length - 1;
462 format = format || this.o.format;
463 var date = this.dates.get(ix);
464 return DPGlobal.formatDate(date, format, this.o.language);
470 if (this.inputField.is(':disabled') || (this.inputField.prop('readonly') && this.o.enableOnReadonly === false))
473 this.picker.appendTo(this.o.container);
476 this._attachSecondaryEvents();
477 this._trigger('show');
478 if ((window.navigator.msMaxTouchPoints || 'ontouchstart' in document) && this.o.disableTouchKeyboard) {
479 $(this.element).blur();
485 if (this.isInline || !this.picker.is(':visible'))
487 this.focusDate = null;
488 this.picker.hide().detach();
489 this._detachSecondaryEvents();
490 this.setViewMode(this.o.startView);
492 if (this.o.forceParse && this.inputField.val())
494 this._trigger('hide');
500 this._detachEvents();
501 this._detachSecondaryEvents();
502 this.picker.remove();
503 delete this.element.data().datepicker;
505 delete this.element.data().date;
512 if (e.originalEvent.clipboardData && e.originalEvent.clipboardData.types
513 && $.inArray('text/plain', e.originalEvent.clipboardData.types) !== -1) {
514 dateString = e.originalEvent.clipboardData.getData('text/plain');
515 } else if (window.clipboardData) {
516 dateString = window.clipboardData.getData('Text');
520 this.setDate(dateString);
525 _utc_to_local: function(utc){
530 var local = new Date(utc.getTime() + (utc.getTimezoneOffset() * 60000));
532 if (local.getTimezoneOffset() !== utc.getTimezoneOffset()) {
533 local = new Date(utc.getTime() + (local.getTimezoneOffset() * 60000));
538 _local_to_utc: function(local){
539 return local && new Date(local.getTime() - (local.getTimezoneOffset()*60000));
541 _zero_time: function(local){
542 return local && new Date(local.getFullYear(), local.getMonth(), local.getDate());
544 _zero_utc_time: function(utc){
545 return utc && UTCDate(utc.getUTCFullYear(), utc.getUTCMonth(), utc.getUTCDate());
548 getDates: function(){
549 return $.map(this.dates, this._utc_to_local);
552 getUTCDates: function(){
553 return $.map(this.dates, function(d){
559 return this._utc_to_local(this.getUTCDate());
562 getUTCDate: function(){
563 var selected_date = this.dates.get(-1);
564 if (selected_date !== undefined) {
565 return new Date(selected_date);
571 clearDates: function(){
572 this.inputField.val('');
574 this._trigger('changeDate');
576 if (this.o.autoclose) {
581 setDates: function(){
582 var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
583 this.update.apply(this, args);
584 this._trigger('changeDate');
589 setUTCDates: function(){
590 var args = $.isArray(arguments[0]) ? arguments[0] : arguments;
591 this.setDates.apply(this, $.map(args, this._utc_to_local));
595 setDate: alias('setDates'),
596 setUTCDate: alias('setUTCDates'),
597 remove: alias('destroy', 'Method `remove` is deprecated and will be removed in version 2.0. Use `destroy` instead'),
599 setValue: function(){
600 var formatted = this.getFormattedDate();
601 this.inputField.val(formatted);
605 getFormattedDate: function(format){
606 if (format === undefined)
607 format = this.o.format;
609 var lang = this.o.language;
610 return $.map(this.dates, function(d){
611 return DPGlobal.formatDate(d, format, lang);
612 }).join(this.o.multidateSeparator);
615 getStartDate: function(){
616 return this.o.startDate;
619 setStartDate: function(startDate){
620 this._process_options({startDate: startDate});
622 this.updateNavArrows();
626 getEndDate: function(){
627 return this.o.endDate;
630 setEndDate: function(endDate){
631 this._process_options({endDate: endDate});
633 this.updateNavArrows();
637 setDaysOfWeekDisabled: function(daysOfWeekDisabled){
638 this._process_options({daysOfWeekDisabled: daysOfWeekDisabled});
643 setDaysOfWeekHighlighted: function(daysOfWeekHighlighted){
644 this._process_options({daysOfWeekHighlighted: daysOfWeekHighlighted});
649 setDatesDisabled: function(datesDisabled){
650 this._process_options({datesDisabled: datesDisabled});
658 var calendarWidth = this.picker.outerWidth(),
659 calendarHeight = this.picker.outerHeight(),
661 container = $(this.o.container),
662 windowWidth = container.width(),
663 scrollTop = this.o.container === 'body' ? $(document).scrollTop() : container.scrollTop(),
664 appendOffset = container.offset();
666 var parentsZindex = [0];
667 this.element.parents().each(function(){
668 var itemZIndex = $(this).css('z-index');
669 if (itemZIndex !== 'auto' && Number(itemZIndex) !== 0) parentsZindex.push(Number(itemZIndex));
671 var zIndex = Math.max.apply(Math, parentsZindex) + this.o.zIndexOffset;
672 var offset = this.component ? this.component.parent().offset() : this.element.offset();
673 var height = this.component ? this.component.outerHeight(true) : this.element.outerHeight(false);
674 var width = this.component ? this.component.outerWidth(true) : this.element.outerWidth(false);
675 var left = offset.left - appendOffset.left;
676 var top = offset.top - appendOffset.top;
678 if (this.o.container !== 'body') {
682 this.picker.removeClass(
683 'datepicker-orient-top datepicker-orient-bottom '+
684 'datepicker-orient-right datepicker-orient-left'
687 if (this.o.orientation.x !== 'auto'){
688 this.picker.addClass('datepicker-orient-' + this.o.orientation.x);
689 if (this.o.orientation.x === 'right')
690 left -= calendarWidth - width;
692 // auto x orientation is best-placement: if it crosses a window
693 // edge, fudge it sideways
695 if (offset.left < 0) {
696 // component is outside the window on the left side. Move it into visible range
697 this.picker.addClass('datepicker-orient-left');
698 left -= offset.left - visualPadding;
699 } else if (left + calendarWidth > windowWidth) {
700 // the calendar passes the widow right edge. Align it to component right side
701 this.picker.addClass('datepicker-orient-right');
702 left += width - calendarWidth;
706 this.picker.addClass('datepicker-orient-right');
709 this.picker.addClass('datepicker-orient-left');
714 // auto y orientation is best-situation: top or bottom, no fudging,
715 // decision based on which shows more of the calendar
716 var yorient = this.o.orientation.y,
718 if (yorient === 'auto'){
719 top_overflow = -scrollTop + top - calendarHeight;
720 yorient = top_overflow < 0 ? 'bottom' : 'top';
723 this.picker.addClass('datepicker-orient-' + yorient);
724 if (yorient === 'top')
725 top -= calendarHeight + parseInt(this.picker.css('padding-top'));
730 var right = windowWidth - (left + width);
748 if (!this._allow_update)
751 var oldDates = this.dates.copy(),
754 if (arguments.length){
755 $.each(arguments, $.proxy(function(i, date){
756 if (date instanceof Date)
757 date = this._local_to_utc(date);
764 : this.element.data('date') || this.inputField.val();
765 if (dates && this.o.multidate)
766 dates = dates.split(this.o.multidateSeparator);
769 delete this.element.data().date;
772 dates = $.map(dates, $.proxy(function(date){
773 return DPGlobal.parseDate(date, this.o.format, this.o.language, this.o.assumeNearbyYear);
775 dates = $.grep(dates, $.proxy(function(date){
777 !this.dateWithinRange(date) ||
781 this.dates.replace(dates);
783 if (this.o.updateViewDate) {
784 if (this.dates.length)
785 this.viewDate = new Date(this.dates.get(-1));
786 else if (this.viewDate < this.o.startDate)
787 this.viewDate = new Date(this.o.startDate);
788 else if (this.viewDate > this.o.endDate)
789 this.viewDate = new Date(this.o.endDate);
791 this.viewDate = this.o.defaultViewDate;
795 // setting date by clicking
797 this.element.change();
799 else if (this.dates.length){
800 // setting date by typing
801 if (String(oldDates) !== String(this.dates) && fromArgs) {
802 this._trigger('changeDate');
803 this.element.change();
806 if (!this.dates.length && oldDates.length) {
807 this._trigger('clearDate');
808 this.element.change();
816 if (this.o.showWeekDays) {
817 var dowCnt = this.o.weekStart,
819 if (this.o.calendarWeeks){
820 html += '<th class="cw"> </th>';
822 while (dowCnt < this.o.weekStart + 7){
823 html += '<th class="dow';
824 if ($.inArray(dowCnt, this.o.daysOfWeekDisabled) !== -1)
826 html += '">'+dates[this.o.language].daysMin[(dowCnt++)%7]+'</th>';
829 this.picker.find('.datepicker-days thead').append(html);
833 fillMonths: function(){
834 var localDate = this._utc_to_local(this.viewDate);
837 for (var i = 0; i < 12; i++){
838 focused = localDate && localDate.getMonth() === i ? ' focused' : '';
839 html += '<span class="month' + focused + '">' + dates[this.o.language].monthsShort[i] + '</span>';
841 this.picker.find('.datepicker-months td').html(html);
844 setRange: function(range){
845 if (!range || !range.length)
848 this.range = $.map(range, function(d){
854 getClassNames: function(date){
856 year = this.viewDate.getUTCFullYear(),
857 month = this.viewDate.getUTCMonth(),
859 if (date.getUTCFullYear() < year || (date.getUTCFullYear() === year && date.getUTCMonth() < month)){
861 } else if (date.getUTCFullYear() > year || (date.getUTCFullYear() === year && date.getUTCMonth() > month)){
864 if (this.focusDate && date.valueOf() === this.focusDate.valueOf())
866 // Compare internal UTC date with UTC today, not local today
867 if (this.o.todayHighlight && isUTCEquals(date, today)) {
870 if (this.dates.contains(date) !== -1)
872 if (!this.dateWithinRange(date)){
873 cls.push('disabled');
875 if (this.dateIsDisabled(date)){
876 cls.push('disabled', 'disabled-date');
878 if ($.inArray(date.getUTCDay(), this.o.daysOfWeekHighlighted) !== -1){
879 cls.push('highlighted');
883 if (date > this.range[0] && date < this.range[this.range.length-1]){
886 if ($.inArray(date.valueOf(), this.range) !== -1){
887 cls.push('selected');
889 if (date.valueOf() === this.range[0]){
890 cls.push('range-start');
892 if (date.valueOf() === this.range[this.range.length-1]){
893 cls.push('range-end');
899 _fill_yearsView: function(selector, cssClass, factor, year, startYear, endYear, beforeFn){
901 var step = factor / 10;
902 var view = this.picker.find(selector);
903 var startVal = Math.floor(year / factor) * factor;
904 var endVal = startVal + step * 9;
905 var focusedVal = Math.floor(this.viewDate.getFullYear() / step) * step;
906 var selected = $.map(this.dates, function(d){
907 return Math.floor(d.getUTCFullYear() / step) * step;
910 var classes, tooltip, before;
911 for (var currVal = startVal - step; currVal <= endVal + step; currVal += step) {
912 classes = [cssClass];
915 if (currVal === startVal - step) {
917 } else if (currVal === endVal + step) {
920 if ($.inArray(currVal, selected) !== -1) {
921 classes.push('active');
923 if (currVal < startYear || currVal > endYear) {
924 classes.push('disabled');
926 if (currVal === focusedVal) {
927 classes.push('focused');
930 if (beforeFn !== $.noop) {
931 before = beforeFn(new Date(currVal, 0, 1));
932 if (before === undefined) {
934 } else if (typeof before === 'boolean') {
935 before = {enabled: before};
936 } else if (typeof before === 'string') {
937 before = {classes: before};
939 if (before.enabled === false) {
940 classes.push('disabled');
942 if (before.classes) {
943 classes = classes.concat(before.classes.split(/\s+/));
945 if (before.tooltip) {
946 tooltip = before.tooltip;
950 html += '<span class="' + classes.join(' ') + '"' + (tooltip ? ' title="' + tooltip + '"' : '') + '>' + currVal + '</span>';
953 view.find('.datepicker-switch').text(startVal + '-' + endVal);
954 view.find('td').html(html);
958 var d = new Date(this.viewDate),
959 year = d.getUTCFullYear(),
960 month = d.getUTCMonth(),
961 startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
962 startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
963 endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
964 endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
965 todaytxt = dates[this.o.language].today || dates['en'].today || '',
966 cleartxt = dates[this.o.language].clear || dates['en'].clear || '',
967 titleFormat = dates[this.o.language].titleFormat || dates['en'].titleFormat,
968 todayDate = UTCToday(),
969 titleBtnVisible = (this.o.todayBtn === true || this.o.todayBtn === 'linked') && todayDate >= this.o.startDate && todayDate <= this.o.endDate && !this.weekOfDateIsDisabled(todayDate),
972 if (isNaN(year) || isNaN(month))
974 this.picker.find('.datepicker-days .datepicker-switch')
975 .text(DPGlobal.formatDate(d, titleFormat, this.o.language));
976 this.picker.find('tfoot .today')
978 .css('display', titleBtnVisible ? 'table-cell' : 'none');
979 this.picker.find('tfoot .clear')
981 .css('display', this.o.clearBtn === true ? 'table-cell' : 'none');
982 this.picker.find('thead .datepicker-title')
984 .css('display', typeof this.o.title === 'string' && this.o.title !== '' ? 'table-cell' : 'none');
985 this.updateNavArrows();
987 var prevMonth = UTCDate(year, month, 0),
988 day = prevMonth.getUTCDate();
989 prevMonth.setUTCDate(day - (prevMonth.getUTCDay() - this.o.weekStart + 7)%7);
990 var nextMonth = new Date(prevMonth);
991 if (prevMonth.getUTCFullYear() < 100){
992 nextMonth.setUTCFullYear(prevMonth.getUTCFullYear());
994 nextMonth.setUTCDate(nextMonth.getUTCDate() + 42);
995 nextMonth = nextMonth.valueOf();
997 var weekDay, clsName;
998 while (prevMonth.valueOf() < nextMonth){
999 weekDay = prevMonth.getUTCDay();
1000 if (weekDay === this.o.weekStart){
1002 if (this.o.calendarWeeks){
1003 // ISO 8601: First week contains first thursday.
1004 // ISO also states week starts on Monday, but we can be more abstract here.
1006 // Start of current week: based on weekstart/current date
1007 ws = new Date(+prevMonth + (this.o.weekStart - weekDay - 7) % 7 * 864e5),
1008 // Thursday of this week
1009 th = new Date(Number(ws) + (7 + 4 - ws.getUTCDay()) % 7 * 864e5),
1010 // First Thursday of year, year from thursday
1011 yth = new Date(Number(yth = UTCDate(th.getUTCFullYear(), 0, 1)) + (7 + 4 - yth.getUTCDay()) % 7 * 864e5),
1012 // Calendar week: ms between thursdays, div ms per day, div 7 days
1013 calWeek = (th - yth) / 864e5 / 7 + 1;
1014 html.push('<td class="cw">'+ calWeek +'</td>');
1017 clsName = this.getClassNames(prevMonth);
1018 clsName.push('day');
1020 var content = prevMonth.getUTCDate();
1022 if (this.o.beforeShowDay !== $.noop){
1023 before = this.o.beforeShowDay(this._utc_to_local(prevMonth));
1024 if (before === undefined)
1026 else if (typeof before === 'boolean')
1027 before = {enabled: before};
1028 else if (typeof before === 'string')
1029 before = {classes: before};
1030 if (before.enabled === false)
1031 clsName.push('disabled');
1033 clsName = clsName.concat(before.classes.split(/\s+/));
1035 tooltip = before.tooltip;
1037 content = before.content;
1040 //Check if uniqueSort exists (supported by jquery >=1.12 and >=2.2)
1041 //Fallback to unique function for older jquery versions
1042 if ($.isFunction($.uniqueSort)) {
1043 clsName = $.uniqueSort(clsName);
1045 clsName = $.unique(clsName);
1048 html.push('<td class="'+clsName.join(' ')+'"' + (tooltip ? ' title="'+tooltip+'"' : '') + ' data-date="' + prevMonth.getTime().toString() + '">' + content + '</td>');
1050 if (weekDay === this.o.weekEnd){
1053 prevMonth.setUTCDate(prevMonth.getUTCDate() + 1);
1055 this.picker.find('.datepicker-days tbody').html(html.join(''));
1057 var monthsTitle = dates[this.o.language].monthsTitle || dates['en'].monthsTitle || 'Months';
1058 var months = this.picker.find('.datepicker-months')
1059 .find('.datepicker-switch')
1060 .text(this.o.maxViewMode < 2 ? monthsTitle : year)
1062 .find('tbody span').removeClass('active');
1064 $.each(this.dates, function(i, d){
1065 if (d.getUTCFullYear() === year)
1066 months.eq(d.getUTCMonth()).addClass('active');
1069 if (year < startYear || year > endYear){
1070 months.addClass('disabled');
1072 if (year === startYear){
1073 months.slice(0, startMonth).addClass('disabled');
1075 if (year === endYear){
1076 months.slice(endMonth+1).addClass('disabled');
1079 if (this.o.beforeShowMonth !== $.noop){
1081 $.each(months, function(i, month){
1082 var moDate = new Date(year, i, 1);
1083 var before = that.o.beforeShowMonth(moDate);
1084 if (before === undefined)
1086 else if (typeof before === 'boolean')
1087 before = {enabled: before};
1088 else if (typeof before === 'string')
1089 before = {classes: before};
1090 if (before.enabled === false && !$(month).hasClass('disabled'))
1091 $(month).addClass('disabled');
1093 $(month).addClass(before.classes);
1095 $(month).prop('title', before.tooltip);
1099 // Generating decade/years picker
1100 this._fill_yearsView(
1101 '.datepicker-years',
1107 this.o.beforeShowYear
1110 // Generating century/decades picker
1111 this._fill_yearsView(
1112 '.datepicker-decades',
1118 this.o.beforeShowDecade
1121 // Generating millennium/centuries picker
1122 this._fill_yearsView(
1123 '.datepicker-centuries',
1129 this.o.beforeShowCentury
1133 updateNavArrows: function(){
1134 if (!this._allow_update)
1137 var d = new Date(this.viewDate),
1138 year = d.getUTCFullYear(),
1139 month = d.getUTCMonth(),
1140 startYear = this.o.startDate !== -Infinity ? this.o.startDate.getUTCFullYear() : -Infinity,
1141 startMonth = this.o.startDate !== -Infinity ? this.o.startDate.getUTCMonth() : -Infinity,
1142 endYear = this.o.endDate !== Infinity ? this.o.endDate.getUTCFullYear() : Infinity,
1143 endMonth = this.o.endDate !== Infinity ? this.o.endDate.getUTCMonth() : Infinity,
1147 switch (this.viewMode){
1158 prevIsDisabled = Math.floor(year / factor) * factor <= startYear;
1159 nextIsDisabled = Math.floor(year / factor) * factor + factor > endYear;
1162 prevIsDisabled = year <= startYear && month <= startMonth;
1163 nextIsDisabled = year >= endYear && month >= endMonth;
1167 this.picker.find('.prev').toggleClass('disabled', prevIsDisabled);
1168 this.picker.find('.next').toggleClass('disabled', nextIsDisabled);
1173 e.stopPropagation();
1175 var target, dir, day, year, month;
1176 target = $(e.target);
1178 // Clicked on the switch
1179 if (target.hasClass('datepicker-switch') && this.viewMode !== this.o.maxViewMode){
1180 this.setViewMode(this.viewMode + 1);
1183 // Clicked on today button
1184 if (target.hasClass('today') && !target.hasClass('day')){
1185 this.setViewMode(0);
1186 this._setDate(UTCToday(), this.o.todayBtn === 'linked' ? null : 'view');
1189 // Clicked on clear button
1190 if (target.hasClass('clear')){
1194 if (!target.hasClass('disabled')){
1195 // Clicked on a month, year, decade, century
1196 if (target.hasClass('month')
1197 || target.hasClass('year')
1198 || target.hasClass('decade')
1199 || target.hasClass('century')) {
1200 this.viewDate.setUTCDate(1);
1203 if (this.viewMode === 1){
1204 month = target.parent().find('span').index(target);
1205 year = this.viewDate.getUTCFullYear();
1206 this.viewDate.setUTCMonth(month);
1209 year = Number(target.text());
1210 this.viewDate.setUTCFullYear(year);
1213 this._trigger(DPGlobal.viewModes[this.viewMode - 1].e, this.viewDate);
1215 if (this.viewMode === this.o.minViewMode){
1216 this._setDate(UTCDate(year, month, day));
1218 this.setViewMode(this.viewMode - 1);
1224 if (this.picker.is(':visible') && this._focused_from){
1225 this._focused_from.focus();
1227 delete this._focused_from;
1230 dayCellClick: function(e){
1231 var $target = $(e.currentTarget);
1232 var timestamp = $target.data('date');
1233 var date = new Date(timestamp);
1235 if (this.o.updateViewDate) {
1236 if (date.getUTCFullYear() !== this.viewDate.getUTCFullYear()) {
1237 this._trigger('changeYear', this.viewDate);
1240 if (date.getUTCMonth() !== this.viewDate.getUTCMonth()) {
1241 this._trigger('changeMonth', this.viewDate);
1244 this._setDate(date);
1247 // Clicked on prev or next
1248 navArrowsClick: function(e){
1249 var $target = $(e.currentTarget);
1250 var dir = $target.hasClass('prev') ? -1 : 1;
1251 if (this.viewMode !== 0){
1252 dir *= DPGlobal.viewModes[this.viewMode].navStep * 12;
1254 this.viewDate = this.moveMonth(this.viewDate, dir);
1255 this._trigger(DPGlobal.viewModes[this.viewMode].e, this.viewDate);
1259 _toggle_multidate: function(date){
1260 var ix = this.dates.contains(date);
1266 if (this.o.multidate === true || this.o.multidate > 1 || this.o.toggleActive){
1267 this.dates.remove(ix);
1269 } else if (this.o.multidate === false) {
1271 this.dates.push(date);
1274 this.dates.push(date);
1277 if (typeof this.o.multidate === 'number')
1278 while (this.dates.length > this.o.multidate)
1279 this.dates.remove(0);
1282 _setDate: function(date, which){
1283 if (!which || which === 'date')
1284 this._toggle_multidate(date && new Date(date));
1285 if ((!which && this.o.updateViewDate) || which === 'view')
1286 this.viewDate = date && new Date(date);
1290 if (!which || which !== 'view') {
1291 this._trigger('changeDate');
1293 this.inputField.trigger('change');
1294 if (this.o.autoclose && (!which || which === 'date')){
1299 moveDay: function(date, dir){
1300 var newDate = new Date(date);
1301 newDate.setUTCDate(date.getUTCDate() + dir);
1306 moveWeek: function(date, dir){
1307 return this.moveDay(date, dir * 7);
1310 moveMonth: function(date, dir){
1311 if (!isValidDate(date))
1312 return this.o.defaultViewDate;
1315 var new_date = new Date(date.valueOf()),
1316 day = new_date.getUTCDate(),
1317 month = new_date.getUTCMonth(),
1318 mag = Math.abs(dir),
1320 dir = dir > 0 ? 1 : -1;
1323 // If going back one month, make sure month is not current month
1324 // (eg, Mar 31 -> Feb 31 == Feb 28, not Mar 02)
1326 return new_date.getUTCMonth() === month;
1328 // If going forward one month, make sure month is as expected
1329 // (eg, Jan 31 -> Feb 31 == Feb 28, not Mar 02)
1331 return new_date.getUTCMonth() !== new_month;
1333 new_month = month + dir;
1334 new_date.setUTCMonth(new_month);
1335 // Dec -> Jan (12) or Jan -> Dec (-1) -- limit expected date to 0-11
1336 new_month = (new_month + 12) % 12;
1339 // For magnitudes >1, move one month at a time...
1340 for (var i=0; i < mag; i++)
1341 // ...which might decrease the day (eg, Jan 31 to Feb 28, etc)...
1342 new_date = this.moveMonth(new_date, dir);
1343 // ...then reset the day, keeping it in the new month
1344 new_month = new_date.getUTCMonth();
1345 new_date.setUTCDate(day);
1347 return new_month !== new_date.getUTCMonth();
1350 // Common date-resetting loop -- if date is beyond end of month, make it
1353 new_date.setUTCDate(--day);
1354 new_date.setUTCMonth(new_month);
1359 moveYear: function(date, dir){
1360 return this.moveMonth(date, dir*12);
1363 moveAvailableDate: function(date, dir, fn){
1365 date = this[fn](date, dir);
1367 if (!this.dateWithinRange(date))
1372 while (this.dateIsDisabled(date));
1377 weekOfDateIsDisabled: function(date){
1378 return $.inArray(date.getUTCDay(), this.o.daysOfWeekDisabled) !== -1;
1381 dateIsDisabled: function(date){
1383 this.weekOfDateIsDisabled(date) ||
1384 $.grep(this.o.datesDisabled, function(d){
1385 return isUTCEquals(date, d);
1390 dateWithinRange: function(date){
1391 return date >= this.o.startDate && date <= this.o.endDate;
1394 keydown: function(e){
1395 if (!this.picker.is(':visible')){
1396 if (e.keyCode === 40 || e.keyCode === 27) { // allow down to re-show picker
1398 e.stopPropagation();
1402 var dateChanged = false,
1404 focusDate = this.focusDate || this.viewDate;
1407 if (this.focusDate){
1408 this.focusDate = null;
1409 this.viewDate = this.dates.get(-1) || this.viewDate;
1415 e.stopPropagation();
1421 if (!this.o.keyboardNavigation || this.o.daysOfWeekDisabled.length === 7)
1423 dir = e.keyCode === 37 || e.keyCode === 38 ? -1 : 1;
1424 if (this.viewMode === 0) {
1426 newViewDate = this.moveAvailableDate(focusDate, dir, 'moveYear');
1429 this._trigger('changeYear', this.viewDate);
1430 } else if (e.shiftKey){
1431 newViewDate = this.moveAvailableDate(focusDate, dir, 'moveMonth');
1434 this._trigger('changeMonth', this.viewDate);
1435 } else if (e.keyCode === 37 || e.keyCode === 39){
1436 newViewDate = this.moveAvailableDate(focusDate, dir, 'moveDay');
1437 } else if (!this.weekOfDateIsDisabled(focusDate)){
1438 newViewDate = this.moveAvailableDate(focusDate, dir, 'moveWeek');
1440 } else if (this.viewMode === 1) {
1441 if (e.keyCode === 38 || e.keyCode === 40) {
1444 newViewDate = this.moveAvailableDate(focusDate, dir, 'moveMonth');
1445 } else if (this.viewMode === 2) {
1446 if (e.keyCode === 38 || e.keyCode === 40) {
1449 newViewDate = this.moveAvailableDate(focusDate, dir, 'moveYear');
1452 this.focusDate = this.viewDate = newViewDate;
1459 if (!this.o.forceParse)
1461 focusDate = this.focusDate || this.dates.get(-1) || this.viewDate;
1462 if (this.o.keyboardNavigation) {
1463 this._toggle_multidate(focusDate);
1466 this.focusDate = null;
1467 this.viewDate = this.dates.get(-1) || this.viewDate;
1470 if (this.picker.is(':visible')){
1472 e.stopPropagation();
1473 if (this.o.autoclose)
1478 this.focusDate = null;
1479 this.viewDate = this.dates.get(-1) || this.viewDate;
1485 if (this.dates.length)
1486 this._trigger('changeDate');
1488 this._trigger('clearDate');
1489 this.inputField.trigger('change');
1493 setViewMode: function(viewMode){
1494 this.viewMode = viewMode;
1498 .filter('.datepicker-' + DPGlobal.viewModes[this.viewMode].clsName)
1500 this.updateNavArrows();
1501 this._trigger('changeViewMode', new Date(this.viewDate));
1505 var DateRangePicker = function(element, options){
1506 $.data(element, 'datepicker', this);
1507 this.element = $(element);
1508 this.inputs = $.map(options.inputs, function(i){
1509 return i.jquery ? i[0] : i;
1511 delete options.inputs;
1513 this.keepEmptyValues = options.keepEmptyValues;
1514 delete options.keepEmptyValues;
1516 datepickerPlugin.call($(this.inputs), options)
1517 .on('changeDate', $.proxy(this.dateUpdated, this));
1519 this.pickers = $.map(this.inputs, function(i){
1520 return $.data(i, 'datepicker');
1524 DateRangePicker.prototype = {
1525 updateDates: function(){
1526 this.dates = $.map(this.pickers, function(i){
1527 return i.getUTCDate();
1529 this.updateRanges();
1531 updateRanges: function(){
1532 var range = $.map(this.dates, function(d){
1535 $.each(this.pickers, function(i, p){
1539 clearDates: function(){
1540 $.each(this.pickers, function(i, p){
1544 dateUpdated: function(e){
1545 // `this.updating` is a workaround for preventing infinite recursion
1546 // between `changeDate` triggering and `setUTCDate` calling. Until
1547 // there is a better mechanism.
1550 this.updating = true;
1552 var dp = $.data(e.target, 'datepicker');
1554 if (dp === undefined) {
1558 var new_date = dp.getUTCDate(),
1559 keep_empty_values = this.keepEmptyValues,
1560 i = $.inArray(e.target, this.inputs),
1563 l = this.inputs.length;
1567 $.each(this.pickers, function(i, p){
1568 if (!p.getUTCDate() && (p === dp || !keep_empty_values))
1569 p.setUTCDate(new_date);
1572 if (new_date < this.dates[j]){
1573 // Date being moved earlier/left
1574 while (j >= 0 && new_date < this.dates[j]){
1575 this.pickers[j--].setUTCDate(new_date);
1577 } else if (new_date > this.dates[k]){
1578 // Date being moved later/right
1579 while (k < l && new_date > this.dates[k]){
1580 this.pickers[k++].setUTCDate(new_date);
1585 delete this.updating;
1587 destroy: function(){
1588 $.map(this.pickers, function(p){ p.destroy(); });
1589 $(this.inputs).off('changeDate', this.dateUpdated);
1590 delete this.element.data().datepicker;
1592 remove: alias('destroy', 'Method `remove` is deprecated and will be removed in version 2.0. Use `destroy` instead')
1595 function opts_from_el(el, prefix){
1596 // Derive options from element data-attrs
1597 var data = $(el).data(),
1599 replace = new RegExp('^' + prefix.toLowerCase() + '([A-Z])');
1600 prefix = new RegExp('^' + prefix.toLowerCase());
1601 function re_lower(_,a){
1602 return a.toLowerCase();
1604 for (var key in data)
1605 if (prefix.test(key)){
1606 inkey = key.replace(replace, re_lower);
1607 out[inkey] = data[key];
1612 function opts_from_locale(lang){
1613 // Derive options from locale plugins
1615 // Check if "de-DE" style date is available, if not language should
1616 // fallback to 2 letter code eg "de"
1618 lang = lang.split('-')[0];
1622 var d = dates[lang];
1623 $.each(locale_opts, function(i,k){
1630 var old = $.fn.datepicker;
1631 var datepickerPlugin = function(option){
1632 var args = Array.apply(null, arguments);
1634 var internal_return;
1635 this.each(function(){
1636 var $this = $(this),
1637 data = $this.data('datepicker'),
1638 options = typeof option === 'object' && option;
1640 var elopts = opts_from_el(this, 'date'),
1641 // Preliminary otions
1642 xopts = $.extend({}, defaults, elopts, options),
1643 locopts = opts_from_locale(xopts.language),
1644 // Options priority: js args, data-attrs, locales, defaults
1645 opts = $.extend({}, defaults, locopts, elopts, options);
1646 if ($this.hasClass('input-daterange') || opts.inputs){
1648 inputs: opts.inputs || $this.find('input').toArray()
1650 data = new DateRangePicker(this, opts);
1653 data = new Datepicker(this, opts);
1655 $this.data('datepicker', data);
1657 if (typeof option === 'string' && typeof data[option] === 'function'){
1658 internal_return = data[option].apply(data, args);
1663 internal_return === undefined ||
1664 internal_return instanceof Datepicker ||
1665 internal_return instanceof DateRangePicker
1669 if (this.length > 1)
1670 throw new Error('Using only allowed for the collection of a single element (' + option + ' function)');
1672 return internal_return;
1674 $.fn.datepicker = datepickerPlugin;
1676 var defaults = $.fn.datepicker.defaults = {
1677 assumeNearbyYear: false,
1679 beforeShowDay: $.noop,
1680 beforeShowMonth: $.noop,
1681 beforeShowYear: $.noop,
1682 beforeShowDecade: $.noop,
1683 beforeShowCentury: $.noop,
1684 calendarWeeks: false,
1686 toggleActive: false,
1687 daysOfWeekDisabled: [],
1688 daysOfWeekHighlighted: [],
1692 format: 'mm/dd/yyyy',
1693 keepEmptyValues: false,
1694 keyboardNavigation: true,
1699 multidateSeparator: ',',
1700 orientation: "auto",
1702 startDate: -Infinity,
1705 todayHighlight: false,
1706 updateViewDate: true,
1708 disableTouchKeyboard: false,
1709 enableOnReadonly: true,
1713 immediateUpdates: false,
1716 leftArrow: '«',
1717 rightArrow: '»'
1721 var locale_opts = $.fn.datepicker.locale_opts = [
1726 $.fn.datepicker.Constructor = Datepicker;
1727 var dates = $.fn.datepicker.dates = {
1729 days: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
1730 daysShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
1731 daysMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
1732 months: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
1733 monthsShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
1736 titleFormat: "MM yyyy"
1743 names: ['days', 'month'],
1748 names: ['months', 'year'],
1754 names: ['years', 'decade'],
1760 names: ['decades', 'century'],
1766 names: ['centuries', 'millennium'],
1767 clsName: 'centuries',
1768 e: 'changeMillennium',
1772 validParts: /dd?|DD?|mm?|MM?|yy(?:yy)?/g,
1773 nonpunctuation: /[^ -\/:-@\u5e74\u6708\u65e5\[-`{-~\t\n\r]+/g,
1774 parseFormat: function(format){
1775 if (typeof format.toValue === 'function' && typeof format.toDisplay === 'function')
1777 // IE treats \0 as a string end in inputs (truncating the value),
1778 // so it's a bad format delimiter, anyway
1779 var separators = format.replace(this.validParts, '\0').split('\0'),
1780 parts = format.match(this.validParts);
1781 if (!separators || !separators.length || !parts || parts.length === 0){
1782 throw new Error("Invalid date format.");
1784 return {separators: separators, parts: parts};
1786 parseDate: function(date, format, language, assumeNearby){
1789 if (date instanceof Date)
1791 if (typeof format === 'string')
1792 format = DPGlobal.parseFormat(format);
1794 return format.toValue(date, format, language);
1806 parts, part, dir, i, fn;
1807 if (date in dateAliases){
1808 date = dateAliases[date];
1810 if (/^[\-+]\d+[dmwy]([\s,]+[\-+]\d+[dmwy])*$/i.test(date)){
1811 parts = date.match(/([\-+]\d+)([dmwy])/gi);
1813 for (i=0; i < parts.length; i++){
1814 part = parts[i].match(/([\-+]\d+)([dmwy])/i);
1815 dir = Number(part[1]);
1816 fn = fn_map[part[2].toLowerCase()];
1817 date = Datepicker.prototype[fn](date, dir);
1819 return Datepicker.prototype._zero_utc_time(date);
1822 parts = date && date.match(this.nonpunctuation) || [];
1824 function applyNearbyYear(year, threshold){
1825 if (threshold === true)
1828 // if year is 2 digits or less, than the user most likely is trying to get a recent century
1831 // if the new year is more than threshold years in advance, use last century
1832 if (year > ((new Date()).getFullYear()+threshold)){
1841 setters_order = ['yyyy', 'yy', 'M', 'MM', 'm', 'mm', 'd', 'dd'],
1843 yyyy: function(d,v){
1844 return d.setUTCFullYear(assumeNearby ? applyNearbyYear(v, assumeNearby) : v);
1850 while (v < 0) v += 12;
1853 while (d.getUTCMonth() !== v)
1854 d.setUTCDate(d.getUTCDate()-1);
1858 return d.setUTCDate(v);
1862 setters_map['yy'] = setters_map['yyyy'];
1863 setters_map['M'] = setters_map['MM'] = setters_map['mm'] = setters_map['m'];
1864 setters_map['dd'] = setters_map['d'];
1866 var fparts = format.parts.slice();
1867 // Remove noop parts
1868 if (parts.length !== fparts.length){
1869 fparts = $(fparts).filter(function(i,p){
1870 return $.inArray(p, setters_order) !== -1;
1873 // Process remainder
1874 function match_part(){
1875 var m = this.slice(0, parts[i].length),
1876 p = parts[i].slice(0, m.length);
1877 return m.toLowerCase() === p.toLowerCase();
1879 if (parts.length === fparts.length){
1881 for (i=0, cnt = fparts.length; i < cnt; i++){
1882 val = parseInt(parts[i], 10);
1887 filtered = $(dates[language].months).filter(match_part);
1888 val = $.inArray(filtered[0], dates[language].months) + 1;
1891 filtered = $(dates[language].monthsShort).filter(match_part);
1892 val = $.inArray(filtered[0], dates[language].monthsShort) + 1;
1899 for (i=0; i < setters_order.length; i++){
1900 s = setters_order[i];
1901 if (s in parsed && !isNaN(parsed[s])){
1902 _date = new Date(date);
1903 setters_map[s](_date, parsed[s]);
1911 formatDate: function(date, format, language){
1914 if (typeof format === 'string')
1915 format = DPGlobal.parseFormat(format);
1916 if (format.toDisplay)
1917 return format.toDisplay(date, format, language);
1919 d: date.getUTCDate(),
1920 D: dates[language].daysShort[date.getUTCDay()],
1921 DD: dates[language].days[date.getUTCDay()],
1922 m: date.getUTCMonth() + 1,
1923 M: dates[language].monthsShort[date.getUTCMonth()],
1924 MM: dates[language].months[date.getUTCMonth()],
1925 yy: date.getUTCFullYear().toString().substring(2),
1926 yyyy: date.getUTCFullYear()
1928 val.dd = (val.d < 10 ? '0' : '') + val.d;
1929 val.mm = (val.m < 10 ? '0' : '') + val.m;
1931 var seps = $.extend([], format.separators);
1932 for (var i=0, cnt = format.parts.length; i <= cnt; i++){
1934 date.push(seps.shift());
1935 date.push(val[format.parts[i]]);
1937 return date.join('');
1939 headTemplate: '<thead>'+
1941 '<th colspan="7" class="datepicker-title"></th>'+
1944 '<th class="prev">'+defaults.templates.leftArrow+'</th>'+
1945 '<th colspan="5" class="datepicker-switch"></th>'+
1946 '<th class="next">'+defaults.templates.rightArrow+'</th>'+
1949 contTemplate: '<tbody><tr><td colspan="7"></td></tr></tbody>',
1950 footTemplate: '<tfoot>'+
1952 '<th colspan="7" class="today"></th>'+
1955 '<th colspan="7" class="clear"></th>'+
1959 DPGlobal.template = '<div class="datepicker">'+
1960 '<div class="datepicker-days">'+
1961 '<table class="table-condensed">'+
1962 DPGlobal.headTemplate+
1964 DPGlobal.footTemplate+
1967 '<div class="datepicker-months">'+
1968 '<table class="table-condensed">'+
1969 DPGlobal.headTemplate+
1970 DPGlobal.contTemplate+
1971 DPGlobal.footTemplate+
1974 '<div class="datepicker-years">'+
1975 '<table class="table-condensed">'+
1976 DPGlobal.headTemplate+
1977 DPGlobal.contTemplate+
1978 DPGlobal.footTemplate+
1981 '<div class="datepicker-decades">'+
1982 '<table class="table-condensed">'+
1983 DPGlobal.headTemplate+
1984 DPGlobal.contTemplate+
1985 DPGlobal.footTemplate+
1988 '<div class="datepicker-centuries">'+
1989 '<table class="table-condensed">'+
1990 DPGlobal.headTemplate+
1991 DPGlobal.contTemplate+
1992 DPGlobal.footTemplate+
1997 $.fn.datepicker.DPGlobal = DPGlobal;
2000 /* DATEPICKER NO CONFLICT
2001 * =================== */
2003 $.fn.datepicker.noConflict = function(){
2004 $.fn.datepicker = old;
2008 /* DATEPICKER VERSION
2009 * =================== */
2010 $.fn.datepicker.version = '1.9.0';
2012 $.fn.datepicker.deprecated = function(msg){
2013 var console = window.console;
2014 if (console && console.warn) {
2015 console.warn('DEPRECATED: ' + msg);
2020 /* DATEPICKER DATA-API
2021 * ================== */
2024 'focus.datepicker.data-api click.datepicker.data-api',
2025 '[data-provide="datepicker"]',
2027 var $this = $(this);
2028 if ($this.data('datepicker'))
2031 // component click requires us to explicitly show it
2032 datepickerPlugin.call($this, 'show');
2036 datepickerPlugin.call($('[data-provide="datepicker-inline"]'));