51 dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting |
51 dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], // For formatting |
52 dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting |
52 dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], // For formatting |
53 dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday |
53 dayNamesMin: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Column headings for days starting at Sunday |
54 dayStatus: 'Set DD as first week day', // Status text for the day of the week selection |
54 dayStatus: 'Set DD as first week day', // Status text for the day of the week selection |
55 dateStatus: 'Select DD, M d', // Status text for the date selection |
55 dateStatus: 'Select DD, M d', // Status text for the date selection |
56 dateFormat: 'mm/dd/yy', // See format options on parseDate |
56 dateFormats: ['yy-mm-dd', 'mm/dd/yy'], // All date formats accepted by the input fields |
57 timeFormat: 'hh:ii', |
57 timeFormat: 'hh:ii', |
58 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... |
58 firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... |
59 initStatus: 'Select a date', // Initial Status text on opening |
59 initStatus: 'Select a date', // Initial Status text on opening |
60 isRTL: false // True if right-to-left language, false if left-to-right |
60 isRTL: false // True if right-to-left language, false if left-to-right |
61 }; |
61 }; |
101 onSelect: null, // Define a callback function when a date is selected |
101 onSelect: null, // Define a callback function when a date is selected |
102 onClose: null, // Define a callback function when the datetimepicker is closed |
102 onClose: null, // Define a callback function when the datetimepicker is closed |
103 numberOfMonths: 1, // Number of months to show at a time |
103 numberOfMonths: 1, // Number of months to show at a time |
104 stepMonths: 1, // Number of months to step back/forward |
104 stepMonths: 1, // Number of months to step back/forward |
105 rangeSelect: false, // Allows for selecting a date range on one date picker |
105 rangeSelect: false, // Allows for selecting a date range on one date picker |
106 rangeSeparator: ' - ' // Text between two dates in a range |
106 rangeSeparator: ' - ', // Text between two dates in a range |
|
107 dateFormat: 'yy-mm-dd' // A default date format. See format options on parseDate |
107 }; |
108 }; |
108 $.extend(this._defaults, this.regional['']); |
109 $.extend(this._defaults, this.regional['']); |
109 this._datetimepickerDiv = $('<div id="datetimepicker_div"></div>'); |
110 this._datetimepickerDiv = $('<div id="datetimepicker_div"></div>'); |
110 } |
111 } |
111 |
112 |
301 }, |
302 }, |
302 |
303 |
303 /* Filter entered characters - based on date format. */ |
304 /* Filter entered characters - based on date format. */ |
304 _doKeyPress: function(e) { |
305 _doKeyPress: function(e) { |
305 var inst = $.datetimepicker._getInst(this._calId); |
306 var inst = $.datetimepicker._getInst(this._calId); |
306 var chars = $.datetimepicker._possibleChars(inst._get('dateFormat')+' '+inst._get('timeFormat')); |
307 var formats = ' '+ inst._get('timeFormat'); |
|
308 var dateFormats = inst._get('dateFormats'); |
|
309 for (var i = 0; i < dateFormats.length; i++) |
|
310 formats += dateFormats[i]; |
|
311 var chars = $.datetimepicker._possibleChars(formats); |
307 var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); |
312 var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); |
308 return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); |
313 return e.ctrlKey || (chr < ' ' || !chars || chars.indexOf(chr) > -1); |
309 }, |
314 }, |
310 |
315 |
311 /* Attach the date picker to an input field. */ |
316 /* Attach the date picker to an input field. */ |
822 iFormat++; |
827 iFormat++; |
823 return matches; |
828 return matches; |
824 }; |
829 }; |
825 // Extract a number from the string value |
830 // Extract a number from the string value |
826 var getNumber = function(match) { |
831 var getNumber = function(match) { |
827 lookAhead(match); |
832 matches = lookAhead(match); |
828 var size = (match == 'y' ? 4 : 2); |
833 var size = ((match == 'y' && matches) ? 4 : 2); |
829 var num = 0; |
834 var num = 0; |
830 while (size > 0 && iValue < value.length && |
835 while (size > 0 && iValue < value.length && |
831 value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') { |
836 value.charAt(iValue) >= '0' && value.charAt(iValue) <= '9') { |
832 num = num * 10 + (value.charAt(iValue++) - 0); |
837 num = num * 10 + (value.charAt(iValue++) - '0'); |
833 size--; |
838 size--; |
834 } |
839 } |
835 if (size == (match == 'y' ? 4 : 2)) |
840 if (size == (match == 'y' ? 4 : 2)) |
836 throw 'Missing number at position ' + iValue; |
841 throw 'Missing number at position ' + iValue; |
837 return num; |
842 return num; |
853 } |
858 } |
854 throw 'Unknown name at position ' + iInit; |
859 throw 'Unknown name at position ' + iInit; |
855 }; |
860 }; |
856 // Confirm that a literal character matches the string value |
861 // Confirm that a literal character matches the string value |
857 var checkLiteral = function() { |
862 var checkLiteral = function() { |
858 if (value.charAt(iValue) != format.charAt(iFormat)) |
863 if (iValue < value.length && (value.charAt(iValue) != format.charAt(iFormat))) |
859 throw 'Unexpected literal at position ' + iValue; |
864 throw 'Unexpected literal at position ' + iValue; |
860 iValue++; |
865 iValue++; |
861 }; |
866 }; |
862 var iValue = 0; |
867 var iValue = 0; |
863 for (var iFormat = 0; iFormat < format.length; iFormat++) { |
868 for (var iFormat = 0; iFormat < format.length; iFormat++) { |
1060 }, |
1065 }, |
1061 |
1066 |
1062 /* Parse existing date and initialise date picker. */ |
1067 /* Parse existing date and initialise date picker. */ |
1063 _setDateFromField: function(input) { |
1068 _setDateFromField: function(input) { |
1064 this._input = $(input); |
1069 this._input = $(input); |
1065 var dateFormat = this._get('dateFormat')+' '+this._get('timeFormat'); |
|
1066 var dates = this._input ? this._input.val().split(this._get('rangeSeparator')) : null; |
1070 var dates = this._input ? this._input.val().split(this._get('rangeSeparator')) : null; |
1067 this._endDay = this._endMonth = this._endYear = null; |
1071 this._endDay = this._endMonth = this._endYear = null; |
1068 var date = defaultDate = this._getDefaultDate(); |
1072 var date = defaultDate = this._getDefaultDate(); |
1069 if (dates.length > 0) { |
1073 if (dates.length > 0) { |
1070 var settings = this._getFormatConfig(); |
1074 var settings = this._getFormatConfig(); |
1071 if (dates.length > 1) { |
1075 if (dates.length > 1) { |
|
1076 var dateFormat = this._get('dateFormat') +' '+this._get('timeFormat'); |
1072 date = $.datetimepicker.parseDate(dateFormat, dates[1], settings) || defaultDate; |
1077 date = $.datetimepicker.parseDate(dateFormat, dates[1], settings) || defaultDate; |
1073 this._endDay = date.getDate(); |
1078 this._endDay = date.getDate(); |
1074 this._endMonth = date.getMonth(); |
1079 this._endMonth = date.getMonth(); |
1075 this._endYear = date.getFullYear(); |
1080 this._endYear = date.getFullYear(); |
1076 } |
1081 } |
1077 try { |
1082 date = null; |
|
1083 var dateFormats = this._get('dateFormats'); |
|
1084 for (var i = 0; i < dateFormats.length; i++) { |
|
1085 var dateFormat = dateFormats[i] +' '+this._get('timeFormat'); |
|
1086 try { |
1078 date = $.datetimepicker.parseDate(dateFormat, dates[0], settings) || defaultDate; |
1087 date = $.datetimepicker.parseDate(dateFormat, dates[0], settings) || defaultDate; |
1079 } catch (e) { |
1088 } catch (e) {} |
1080 $.datetimepicker.log(e); |
1089 if (date != null) { |
1081 date = defaultDate; |
1090 $.datetimepicker._defaults['dateFormat'] = dateFormats[i]; |
1082 } |
1091 break; |
|
1092 } |
|
1093 } |
|
1094 if (date == null) date = defaultDate; |
1083 } |
1095 } |
1084 this._selectedDay = date.getDate(); |
1096 this._selectedDay = date.getDate(); |
1085 this._drawMonth = this._selectedMonth = date.getMonth(); |
1097 this._drawMonth = this._selectedMonth = date.getMonth(); |
1086 this._drawYear = this._selectedYear = date.getFullYear(); |
1098 this._drawYear = this._selectedYear = date.getFullYear(); |
1087 this._drawHour = this._selectedHour = date.getHours(); |
1099 this._drawHour = this._selectedHour = date.getHours(); |