summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrent Richardson <trentdrichardson@gmail.com>2012-03-23 08:05:01 -0700
committerTrent Richardson <trentdrichardson@gmail.com>2012-03-23 08:05:01 -0700
commit64ada98d71ae988a7dbf269a5f8b0ffae1a17569 (patch)
treedb096e2ca96adb76701c777b3b20b0fe548994a8
parentd28b5db6c00dfbb66e785145e6a687b120e5a066 (diff)
parentab26e51171d923e94a4d021bc4336d9bff078cd5 (diff)
downloadjQuery-Timepicker-Addon-64ada98d71ae988a7dbf269a5f8b0ffae1a17569.zip
jQuery-Timepicker-Addon-64ada98d71ae988a7dbf269a5f8b0ffae1a17569.tar.gz
jQuery-Timepicker-Addon-64ada98d71ae988a7dbf269a5f8b0ffae1a17569.tar.bz2
Merge pull request #343 from apepper/timezone_default
Use defaultTimezone, when a time is already set.
-rw-r--r--jquery-ui-timepicker-addon.js25
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);