Skip to content

Commit 2be272b

Browse files
author
Alexander Gitter
committed
Fix issue trentrichardson#135, time was set to NaN in some rare cases
1 parent 607577c commit 2be272b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -607,13 +607,18 @@ $.extend(Timepicker.prototype, {
607607
minute = (this.minute_slider) ? this.minute_slider.slider('value') : false,
608608
second = (this.second_slider) ? this.second_slider.slider('value') : false,
609609
timezone = (this.timezone_select) ? this.timezone_select.val() : false;
610-
610+
611+
if (typeof(hour) == 'object') hour = false;
612+
if (typeof(minute) == 'object') minute = false;
613+
if (typeof(second) == 'object') second = false;
614+
if (typeof(timezone) == 'object') timezone = false;
615+
611616
if (hour !== false) hour = parseInt(hour,10);
612617
if (minute !== false) minute = parseInt(minute,10);
613618
if (second !== false) second = parseInt(second,10);
614619

615620
var ampm = (hour < 12) ? 'AM' : 'PM';
616-
621+
617622
// If the update was done in the input field, the input field should not be updated.
618623
// If the update was done using the sliders, update the input field.
619624
var hasChanged = (hour != this.hour || minute != this.minute || second != this.second || (this.ampm.length > 0 && this.ampm != ampm) || timezone != this.timezone);
@@ -909,12 +914,13 @@ $.datepicker._setTime = function(inst, date) {
909914
second = defaults.secondMin;
910915
}
911916

917+
tp_inst.hour = hour;
918+
tp_inst.minute = minute;
919+
tp_inst.second = second;
920+
912921
if (tp_inst.hour_slider) tp_inst.hour_slider.slider('value', hour);
913-
else tp_inst.hour = hour;
914922
if (tp_inst.minute_slider) tp_inst.minute_slider.slider('value', minute);
915-
else tp_inst.minute = minute;
916923
if (tp_inst.second_slider) tp_inst.second_slider.slider('value', second);
917-
else tp_inst.second = second;
918924

919925
tp_inst._onTimeChange();
920926
tp_inst._updateDateTime(inst);

0 commit comments

Comments
 (0)