|
42 | 42 | this.regional[''] = { // Default regional settings
|
43 | 43 | currentText: 'Now',
|
44 | 44 | closeText: 'Done',
|
45 |
| - //ampm: false, |
46 | 45 | amNames: ['AM', 'A'],
|
47 | 46 | pmNames: ['PM', 'P'],
|
48 | 47 | timeFormat: 'HH:mm',
|
|
95 | 94 | separator: ' ',
|
96 | 95 | altFieldTimeOnly: true,
|
97 | 96 | altTimeFormat: null,
|
98 |
| - //altAmpm: null, |
99 | 97 | altSeparator: null,
|
100 | 98 | altTimeSuffix: null,
|
101 | 99 | pickerTimeFormat: null,
|
|
363 | 361 | if(litem == 'hour'){
|
364 | 362 | for (var h = o[litem+'Min']; h <= max[litem]; h += parseInt(o[litem+'Grid'], 10)) {
|
365 | 363 | gridSize[litem]++;
|
366 |
| - var tmph = $.datepicker.formatTime(_useAmpm(o.pickerTimeFormat || o.timeFormat)? 'hht':'HH', {hour:h}, o); |
| 364 | + var tmph = $.datepicker.formatTime(useAmpm(o.pickerTimeFormat || o.timeFormat)? 'hht':'HH', {hour:h}, o); |
367 | 365 | html += '<td data-for="'+litem+'">' + tmph + '</td>';
|
368 | 366 | }
|
369 | 367 | }
|
|
650 | 648 | second = (this.second_slider) ? this.control.value(this, this.second_slider, 'second') : false,
|
651 | 649 | millisec = (this.millisec_slider) ? this.control.value(this, this.millisec_slider, 'millisec') : false,
|
652 | 650 | timezone = (this.timezone_select) ? this.timezone_select.val() : false,
|
653 |
| - o = this._defaults; |
| 651 | + o = this._defaults, |
| 652 | + pickerTimeFormat = o.pickerTimeFormat || o.timeFormat, |
| 653 | + pickerTimeSuffix = o.pickerTimeSuffix || o.timeSuffix; |
654 | 654 |
|
655 | 655 | if (typeof(hour) == 'object') {
|
656 | 656 | hour = false;
|
|
713 | 713 |
|
714 | 714 | this._limitMinMaxDateTime(this.inst, true);
|
715 | 715 | }
|
716 |
| - if (o.ampm) { |
| 716 | + if (useAmpm(o.timeFormat)) { |
717 | 717 | this.ampm = ampm;
|
718 | 718 | }
|
719 | 719 |
|
720 | 720 | // Updates the time within the timepicker
|
721 |
| - this.formattedTime = $.datepicker.formatTime(this._defaults.timeFormat, this, this._defaults); |
| 721 | + this.formattedTime = $.datepicker.formatTime(o.timeFormat, this, o); |
722 | 722 | if (this.$timeObj) {
|
723 |
| - var pickerTimeFormat = this._defaults.pickerTimeFormat || this._defaults.timeFormat, |
724 |
| - pickerTimeSuffix = this._defaults.pickerTimeSuffix || this._defaults.timeSuffix; |
725 |
| - if(pickerTimeFormat === this._defaults.timeFormat){ |
| 723 | + if(pickerTimeFormat === o.timeFormat){ |
726 | 724 | this.$timeObj.text(this.formattedTime + pickerTimeSuffix);
|
727 | 725 | }
|
728 | 726 | else{
|
729 |
| - this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, this._defaults) + pickerTimeSuffix); |
| 727 | + this.$timeObj.text($.datepicker.formatTime(pickerTimeFormat, this, o) + pickerTimeSuffix); |
730 | 728 | }
|
731 | 729 | }
|
732 | 730 |
|
|
885 | 883 |
|
886 | 884 | for(var i=min; i<=max; i+=step){
|
887 | 885 | sel += '<option value="'+ i +'"'+ (i==val? ' selected':'') +'>';
|
888 |
| - if(unit == 'hour' && _useAmpm(tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat)) |
| 886 | + if(unit == 'hour' && useAmpm(tp_inst._defaults.pickerTimeFormat || tp_inst._defaults.timeFormat)) |
889 | 887 | sel += $.datepicker.formatTime("hh TT", {hour:i}, tp_inst._defaults);
|
890 | 888 | else if(unit == 'millisec' || i >= 10) sel += i;
|
891 | 889 | else sel += '0'+ i.toString();
|
|
1026 | 1024 | var o = extendRemove(extendRemove({}, $.timepicker._defaults), options || {});
|
1027 | 1025 |
|
1028 | 1026 | var regstr = '^' + timeFormat.toString()
|
1029 |
| - .replace(/(hh?|mm?|ss?|[tT]{1,2}|[lz]|'.*?')/g, function (match) { |
| 1027 | + .replace(/([hH]{1,2}|mm?|ss?|[tT]{1,2}|[lz]|'.*?')/g, function (match) { |
1030 | 1028 | switch (match.charAt(0).toLowerCase()) {
|
1031 | 1029 | case 'h': return '(\\d?\\d)';
|
1032 | 1030 | case 'm': return '(\\d?\\d)';
|
|
1151 | 1149 | case 'H':
|
1152 | 1150 | return hour;
|
1153 | 1151 | case 'hh':
|
1154 |
| - return _convert24to12(hour).slice(-2); |
| 1152 | + return convert24to12(hour).slice(-2); |
1155 | 1153 | case 'h':
|
1156 |
| - return _convert24to12(hour); |
| 1154 | + return convert24to12(hour); |
1157 | 1155 | case 'mm':
|
1158 | 1156 | return ('0' + time.minute).slice(-2);
|
1159 | 1157 | case 'm':
|
|
1246 | 1244 |
|
1247 | 1245 | if (tp_inst) {
|
1248 | 1246 | if ($.datepicker._get(inst, 'constrainInput')) {
|
1249 |
| - var ampm = tp_inst._defaults.ampm, |
| 1247 | + var ampm = useAmpm(tp_inst._defaults.timeFormat), |
1250 | 1248 | dateChars = $.datepicker._possibleChars($.datepicker._get(inst, 'dateFormat')),
|
1251 | 1249 | datetimeChars = tp_inst._defaults.timeFormat.toString()
|
1252 | 1250 | .replace(/[hms]/g, '')
|
|
1584 | 1582 | * jQuery isEmptyObject does not check hasOwnProperty - if someone has added to the object prototype,
|
1585 | 1583 | * it will return false for all objects
|
1586 | 1584 | */
|
1587 |
| - function isEmptyObject (obj) { |
| 1585 | + var isEmptyObject = function(obj) { |
1588 | 1586 | var prop;
|
1589 | 1587 | for (prop in obj) {
|
1590 | 1588 | if (obj.hasOwnProperty(obj)) {
|
1591 | 1589 | return false;
|
1592 | 1590 | }
|
1593 | 1591 | }
|
1594 | 1592 | return true;
|
1595 |
| - } |
| 1593 | + }; |
| 1594 | + |
1596 | 1595 | /*
|
1597 | 1596 | * jQuery extend now ignores nulls!
|
1598 | 1597 | */
|
1599 |
| - function extendRemove(target, props) { |
| 1598 | + var extendRemove = function(target, props) { |
1600 | 1599 | $.extend(target, props);
|
1601 | 1600 | for (var name in props) {
|
1602 | 1601 | if (props[name] === null || props[name] === undefined) {
|
1603 | 1602 | target[name] = props[name];
|
1604 | 1603 | }
|
1605 | 1604 | }
|
1606 | 1605 | return target;
|
1607 |
| - } |
| 1606 | + }; |
1608 | 1607 |
|
1609 | 1608 | /*
|
1610 | 1609 | * Determine by the time format if should use ampm
|
1611 | 1610 | * Returns true if should use ampm, false if not
|
1612 | 1611 | */
|
1613 |
| - var _useAmpm = function(timeFormat){ |
| 1612 | + var useAmpm = function(timeFormat){ |
1614 | 1613 | return (timeFormat.indexOf('t') !== -1 && timeFormat.indexOf('h') !== -1);
|
1615 |
| - } |
| 1614 | + }; |
1616 | 1615 |
|
1617 | 1616 | /*
|
1618 | 1617 | * Converts 24 hour format into 12 hour
|
1619 | 1618 | * Returns 12 hour with leading 0
|
1620 | 1619 | */
|
1621 |
| - var _convert24to12 = function(hour) { |
| 1620 | + var convert24to12 = function(hour) { |
1622 | 1621 | if (hour > 12) {
|
1623 | 1622 | hour = hour - 12;
|
1624 | 1623 | }
|
|
1645 | 1644 | // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split.
|
1646 | 1645 | var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator,
|
1647 | 1646 | format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat,
|
1648 |
| - ampm = timeSettings && timeSettings.ampm ? timeSettings.ampm : $.timepicker._defaults.ampm, |
1649 | 1647 | timeParts = format.split(separator), // how many occurances of separator may be in our format?
|
1650 | 1648 | timePartsLen = timeParts.length,
|
1651 | 1649 | allParts = dateTimeString.split(separator),
|
1652 | 1650 | allPartsLen = allParts.length;
|
1653 | 1651 |
|
1654 |
| - // because our default ampm=false, but our default format has tt, we need to filter this out |
1655 |
| - if(!ampm){ |
1656 |
| - timeParts = $.trim(format.replace(/t/gi,'')).split(separator); |
1657 |
| - timePartsLen = timeParts.length; |
1658 |
| - } |
1659 |
| - |
1660 | 1652 | if (allPartsLen > 1) {
|
1661 | 1653 | return [
|
1662 | 1654 | allParts.splice(0,allPartsLen-timePartsLen).join(separator),
|
|
1670 | 1662 | "\ndateTimeString" + dateTimeString +
|
1671 | 1663 | "\ndateFormat = " + dateFormat +
|
1672 | 1664 | "\nseparator = " + timeSettings.separator +
|
1673 |
| - "\ntimeFormat = " + timeSettings.timeFormat + |
1674 |
| - "\nampm = " + timeSettings.ampm); |
| 1665 | + "\ntimeFormat = " + timeSettings.timeFormat); |
1675 | 1666 |
|
1676 | 1667 | if (err.indexOf(":") >= 0) {
|
1677 | 1668 | // Hack! The error message ends with a colon, a space, and
|
|
0 commit comments