Skip to content

Commit db9e0cd

Browse files
Merge pull request trentrichardson#859 from ejazrasool/dev
Issue trentrichardson#89 Fix: getDate() returns time (hh:mm) even when plugin is applied on "non-input" elements
2 parents d6b3b42 + 5052dbb commit db9e0cd

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/jquery-ui-timepicker-addon.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -1735,7 +1735,26 @@
17351735
}
17361736

17371737
var date = this._getDate(inst);
1738-
var currDT = $.trim((tp_inst.$altInput && tp_inst._defaults.altFieldTimeOnly) ? tp_inst.$input.val() + ' ' + tp_inst.$altInput.val() : tp_inst.$input.val());
1738+
1739+
var currDT = null;
1740+
1741+
if (tp_inst.$altInput && tp_inst._defaults.altFieldTimeOnly) {
1742+
currDT = tp_inst.$input.val() + ' ' + tp_inst.$altInput.val();
1743+
}
1744+
else if (tp_inst.$input.get(0).tagName != 'INPUT' && tp_inst.$altInput) {
1745+
/**
1746+
* in case the datetimepicker has been applied to a non-input tag for inline UI,
1747+
* and the user has not configured the plugin to display only time in altInput,
1748+
* pick current date time from the altInput (and hope for the best, for now, until "ER1" is applied)
1749+
*
1750+
* @todo ER1. Since altInput can have a totally difference format, convert it to standard format by reading input format from "altFormat" and "altTimeFormat" option values
1751+
*/
1752+
currDT = tp_inst.$altInput.val();
1753+
}
1754+
else {
1755+
currDT = tp_inst.$input.val();
1756+
}
1757+
17391758
if (date && tp_inst._parseTime(currDT, !inst.settings.timeOnly)) {
17401759
date.setHours(tp_inst.hour, tp_inst.minute, tp_inst.second, tp_inst.millisec);
17411760
date.setMicroseconds(tp_inst.microsec);

0 commit comments

Comments
 (0)