|
1426 | 1426 | var tp_inst = this._get(inst, 'timepicker'); |
1427 | 1427 |
|
1428 | 1428 | if (tp_inst) { |
1429 | | - this._setDateFromField(inst, noDefault); |
| 1429 | + //this._setDateFromField(inst, noDefault); // This keeps setting to today when it shouldn't |
1430 | 1430 | var date = this._getDate(inst); |
1431 | 1431 | if (date && tp_inst._parseTime($(target).val(), tp_inst.timeOnly)) { |
1432 | 1432 | date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec); |
|
1548 | 1548 | /* |
1549 | 1549 | * Splits datetime string into date ans time substrings. |
1550 | 1550 | * Throws exception when date can't be parsed |
1551 | | - * If only date is present, time substring eill be '' |
| 1551 | + * Returns [dateString, timeString] |
1552 | 1552 | */ |
1553 | 1553 | var splitDateTime = function(dateFormat, dateTimeString, dateSettings, timeSettings) { |
1554 | 1554 | try { |
| 1555 | + // The idea is to get the number separator occurances in datetime and the time format requested (since time has |
| 1556 | + // fewer unknowns, mostly numbers and am/pm). We will use the time pattern to split. |
1555 | 1557 | var separator = timeSettings && timeSettings.separator ? timeSettings.separator : $.timepicker._defaults.separator, |
1556 | 1558 | format = timeSettings && timeSettings.timeFormat ? timeSettings.timeFormat : $.timepicker._defaults.timeFormat, |
| 1559 | + ampm = timeSettings && timeSettings.ampm ? timeSettings.ampm : $.timepicker._defaults.ampm, |
1557 | 1560 | timeParts = format.split(separator), // how many occurances of separator may be in our format? |
1558 | 1561 | timePartsLen = timeParts.length, |
1559 | 1562 | allParts = dateTimeString.split(separator), |
1560 | 1563 | allPartsLen = allParts.length; |
1561 | 1564 |
|
| 1565 | + // because our default ampm=false, but our default format has tt, we need to filter this out |
| 1566 | + if(!ampm){ |
| 1567 | + timeParts = $.trim(format.replace(/t/gi,'')).split(separator); |
| 1568 | + timePartsLen = timeParts.length; |
| 1569 | + } |
| 1570 | + |
1562 | 1571 | if (allPartsLen > 0) { |
1563 | 1572 | return [ |
1564 | 1573 | allParts.splice(0,allPartsLen-timePartsLen).join(separator), |
|
0 commit comments