summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--jquery-ui-timepicker-addon.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js
index e231bba..252a344 100644
--- a/jquery-ui-timepicker-addon.js
+++ b/jquery-ui-timepicker-addon.js
@@ -112,6 +112,7 @@ $.extend(Timepicker.prototype, {
second: 0,
millisec: 0,
timezone: null,
+ useLocalTimezone: false,
defaultTimezone: "+0000",
hourMinOriginal: null,
minuteMinOriginal: null,
@@ -457,6 +458,7 @@ $.extend(Timepicker.prototype, {
}
}
this.timezone_select.change(function() {
+ tp_inst.useLocalTimezone = false;
tp_inst._onTimeChange();
});
@@ -1067,7 +1069,15 @@ $.datepicker._updateDatepicker = function(inst) {
// Reload the time control when changing something in the input text field.
var tp_inst = this._get(inst, 'timepicker');
- if(tp_inst) tp_inst._addTimePicker(inst);
+ if(tp_inst) {
+ tp_inst._addTimePicker(inst);
+
+ if (tp_inst.useLocalTimezone) { //checks daylight saving with the new date.
+ var date = new Date(inst.selectedYear, inst.selectedMonth, inst.selectedDay, 12);
+ selectLocalTimeZone(tp_inst, date);
+ tp_inst._onTimeChange();
+ }
+ }
}
};
@@ -1408,10 +1418,11 @@ var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dat
//#######################################################################################
// Internal function to set timezone_select to the local timezone
//#######################################################################################
-var selectLocalTimeZone = function(tp_inst)
+var selectLocalTimeZone = function(tp_inst, date)
{
if (tp_inst && tp_inst._defaults.showTimezone && tp_inst.timezone_select) {
- var now = new Date();
+ tp_inst.useLocalTimezone = true;
+ var now = typeof date !== 'undefined' ? date : new Date();
var tzoffset = now.getTimezoneOffset(); // If +0100, returns -60
var tzsign = tzoffset > 0 ? '-' : '+';
tzoffset = Math.abs(tzoffset);