Skip to content

Commit 81e325d

Browse files
author
Ing. Jan Novotný
committed
Issue when specifying stepHour/stepMinute/stepSecond along with min and max limits. Modulo was computed in relation with midnight instead of min limit. Error usecase:
$('#example1').datetimepicker({ stepHour: 4, hourMin: 9, hourMax: 18 }); Would make steps 9-13-16 instead of 9-13-17.
1 parent 4496926 commit 81e325d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ $.extend(Timepicker.prototype, {
265265
// Added by Peter Medeiros:
266266
// - Figure out what the hour/minute/second max should be based on the step values.
267267
// - Example: if stepMinute is 15, then minMax is 45.
268-
hourMax = (o.hourMax - (o.hourMax % o.stepHour)).toFixed(0),
269-
minMax = (o.minuteMax - (o.minuteMax % o.stepMinute)).toFixed(0),
270-
secMax = (o.secondMax - (o.secondMax % o.stepSecond)).toFixed(0),
268+
hourMax = (o.hourMax - ((o.hourMax - o.hourMin) % o.stepHour)).toFixed(0),
269+
minMax = (o.minuteMax - ((o.minuteMax - o.minuteMin) % o.stepMinute)).toFixed(0),
270+
secMax = (o.secondMax - ((o.secondMax - o.secondMin) % o.stepSecond)).toFixed(0),
271271
dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
272272

273273
// Prevent displaying twice
@@ -285,7 +285,7 @@ $.extend(Timepicker.prototype, {
285285
minuteGridSize = 0,
286286
secondGridSize = 0,
287287
size;
288-
288+
289289
if (o.showHour && o.hourGrid > 0) {
290290
html += '<dd class="ui_tpicker_hour">' +
291291
'<div id="ui_tpicker_hour_' + dp_id + '"' + ((o.showHour) ? '' : noDisplay) + '></div>' +
@@ -586,9 +586,9 @@ $.extend(Timepicker.prototype, {
586586
}
587587

588588
if(adjustSliders !== undefined && adjustSliders === true){
589-
var hourMax = (this._defaults.hourMax - (this._defaults.hourMax % this._defaults.stepHour)).toFixed(0),
590-
minMax = (this._defaults.minuteMax - (this._defaults.minuteMax % this._defaults.stepMinute)).toFixed(0),
591-
secMax = (this._defaults.secondMax - (this._defaults.secondMax % this._defaults.stepSecond)).toFixed(0);
589+
var hourMax = (this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)).toFixed(0),
590+
minMax = (this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)).toFixed(0),
591+
secMax = (this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)).toFixed(0);
592592

593593
if(this.hour_slider)
594594
this.hour_slider.slider("option", { min: this._defaults.hourMin, max: hourMax }).slider('value', this.hour);

0 commit comments

Comments
 (0)