diff options
-rw-r--r-- | jquery-ui-timepicker-addon.js | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 91c52c4..252a344 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -69,6 +69,7 @@ function Timepicker() { second: 0, millisec: 0, timezone: null, + defaultTimezone: "+0000", hourMin: 0, minuteMin: 0, secondMin: 0, @@ -111,6 +112,8 @@ $.extend(Timepicker.prototype, { second: 0, millisec: 0, timezone: null, + useLocalTimezone: false, + defaultTimezone: "+0000", hourMinOriginal: null, minuteMinOriginal: null, secondMinOriginal: null, @@ -448,9 +451,14 @@ $.extend(Timepicker.prototype, { if (typeof this.timezone != "undefined" && this.timezone != null && this.timezone != "") { this.timezone_select.val(this.timezone); } else { - selectLocalTimeZone(tp_inst); + if (typeof this.hour != "undefined" && this.hour != null && this.hour != "") { + this.timezone_select.val(o.defaultTimezone); + } else { + selectLocalTimeZone(tp_inst); + } } this.timezone_select.change(function() { + tp_inst.useLocalTimezone = false; tp_inst._onTimeChange(); }); @@ -1061,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(); + } + } } }; @@ -1402,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); |