Skip to content

Commit 9a28b91

Browse files
Fixes trentrichardson#706 altTimeFormat, altSeparator, altTimeSuffix doesnt allow empty value
1 parent c63c257 commit 9a28b91

File tree

3 files changed

+16
-14
lines changed

3 files changed

+16
-14
lines changed

dist/jquery-ui-timepicker-addon.js

+11-9
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,8 @@
914914
} else if (this.$altInput) {
915915
this.$input.val(formattedDateTime);
916916
var altFormattedDateTime = '',
917-
altSeparator = this._defaults.altSeparator ? this._defaults.altSeparator : this._defaults.separator,
918-
altTimeSuffix = this._defaults.altTimeSuffix ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
917+
altSeparator = this._defaults.altSeparator !== null ? this._defaults.altSeparator : this._defaults.separator,
918+
altTimeSuffix = this._defaults.altTimeSuffix !== null ? this._defaults.altTimeSuffix : this._defaults.timeSuffix;
919919

920920
if (!this._defaults.timeOnly) {
921921
if (this._defaults.altFormat) {
@@ -930,7 +930,7 @@
930930
}
931931
}
932932

933-
if (this._defaults.altTimeFormat) {
933+
if (this._defaults.altTimeFormat !== null) {
934934
altFormattedDateTime += $.datepicker.formatTime(this._defaults.altTimeFormat, this, this._defaults) + altTimeSuffix;
935935
}
936936
else {
@@ -1484,11 +1484,11 @@
14841484
altFormattedDateTime = tp_inst.formattedDate + altSeparator + altFormattedDateTime;
14851485
}
14861486
}
1487-
$(altField).val(altFormattedDateTime);
1487+
$(altField).val( inst.input.val() ? altFormattedDateTime : "");
14881488
}
14891489
}
14901490
else {
1491-
$.datepicker._base_updateAlternate(inst);
1491+
$.datepicker._base_updateAlternate(inst);
14921492
}
14931493
};
14941494

@@ -1622,16 +1622,18 @@
16221622
* override setDate() to allow setting time too within Date object
16231623
*/
16241624
$.datepicker._base_setDateDatepicker = $.datepicker._setDateDatepicker;
1625-
$.datepicker._setDateDatepicker = function (target, date) {
1625+
$.datepicker._setDateDatepicker = function (target, _date) {
16261626
var inst = this._getInst(target);
1627+
var date = _date;
16271628
if (!inst) {
16281629
return;
16291630
}
16301631

1631-
if (typeof(date) === 'string') {
1632-
date = new Date(date);
1632+
if (typeof(_date) === 'string') {
1633+
date = new Date(_date);
16331634
if (!date.getTime()) {
1634-
$.timepicker.log("Error creating Date object from string.");
1635+
this._base_setDateDatepicker.apply(this, arguments);
1636+
date = $(target).datepicker('getDate');
16351637
}
16361638
}
16371639

0 commit comments

Comments
 (0)