Skip to content

Commit ab26e51

Browse files
committed
Check local timezone again, when changing the date (e.g. daylight savings).
* Only do this, when using the localTimezone.
1 parent 4378827 commit ab26e51

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ $.extend(Timepicker.prototype, {
112112
second: 0,
113113
millisec: 0,
114114
timezone: null,
115+
useLocalTimezone: false,
115116
defaultTimezone: "+0000",
116117
hourMinOriginal: null,
117118
minuteMinOriginal: null,
@@ -457,6 +458,7 @@ $.extend(Timepicker.prototype, {
457458
}
458459
}
459460
this.timezone_select.change(function() {
461+
tp_inst.useLocalTimezone = false;
460462
tp_inst._onTimeChange();
461463
});
462464

@@ -1067,7 +1069,15 @@ $.datepicker._updateDatepicker = function(inst) {
10671069

10681070
// Reload the time control when changing something in the input text field.
10691071
var tp_inst = this._get(inst, 'timepicker');
1070-
if(tp_inst) tp_inst._addTimePicker(inst);
1072+
if(tp_inst) {
1073+
tp_inst._addTimePicker(inst);
1074+
1075+
if (tp_inst.useLocalTimezone) { //checks daylight saving with the new date.
1076+
var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
1077+
selectLocalTimeZone(tp_inst, date);
1078+
tp_inst._onTimeChange();
1079+
}
1080+
}
10711081
}
10721082
};
10731083

@@ -1408,10 +1418,11 @@ var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dat
14081418
//#######################################################################################
14091419
// Internal function to set timezone_select to the local timezone
14101420
//#######################################################################################
1411-
var selectLocalTimeZone = function(tp_inst)
1421+
var selectLocalTimeZone = function(tp_inst, date)
14121422
{
14131423
if (tp_inst && tp_inst._defaults.showTimezone && tp_inst.timezone_select) {
1414-
var now = new Date();
1424+
tp_inst.useLocalTimezone = true;
1425+
var now = typeof date !== 'undefined' ? date : new Date();
14151426
var tzoffset = now.getTimezoneOffset(); // If +0100, returns -60
14161427
var tzsign = tzoffset > 0 ? '-' : '+';
14171428
tzoffset = Math.abs(tzoffset);

0 commit comments

Comments
 (0)