summaryrefslogtreecommitdiffstats
path: root/jquery-ui-timepicker-addon.js
diff options
context:
space:
mode:
authorAlexander Pepper <alexander.pepper@infopark.de>2012-03-20 17:53:39 +0100
committerAlexander Pepper <alexander.pepper@infopark.de>2012-03-20 17:53:39 +0100
commit313e55d76a668a8faa6741fad97e0a996b553069 (patch)
tree90c2497dd379fddf65f22bdd92acb357eb1d8bd6 /jquery-ui-timepicker-addon.js
parent704c0b9d33d4f8a675f3802a63fddcb3f9186f90 (diff)
downloadjQuery-Timepicker-Addon-313e55d76a668a8faa6741fad97e0a996b553069.zip
jQuery-Timepicker-Addon-313e55d76a668a8faa6741fad97e0a996b553069.tar.gz
jQuery-Timepicker-Addon-313e55d76a668a8faa6741fad97e0a996b553069.tar.bz2
Pick the current timezone of the browser by default.
Diffstat (limited to 'jquery-ui-timepicker-addon.js')
-rw-r--r--jquery-ui-timepicker-addon.js38
1 files changed, 25 insertions, 13 deletions
diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js
index 46260fb..3962961 100644
--- a/jquery-ui-timepicker-addon.js
+++ b/jquery-ui-timepicker-addon.js
@@ -110,7 +110,6 @@ $.extend(Timepicker.prototype, {
minute: 0,
second: 0,
millisec: 0,
- timezone: '+0000',
hourMinOriginal: null,
minuteMinOriginal: null,
secondMinOriginal: null,
@@ -444,7 +443,11 @@ $.extend(Timepicker.prototype, {
.text(typeof val == "object" ? val.label : val);
})
);
- this.timezone_select.val((typeof this.timezone != "undefined" && this.timezone != null && this.timezone != "") ? this.timezone : o.timezone);
+ if (typeof this.timezone != "undefined" && this.timezone != null && this.timezone != "") {
+ this.timezone_select.val(this.timezone);
+ } else {
+ selectLocalTimeZone(tp_inst);
+ }
this.timezone_select.change(function() {
tp_inst._onTimeChange();
});
@@ -1125,18 +1128,9 @@ $.datepicker._gotoToday = function(id) {
var inst = this._getInst($(id)[0]),
$dp = inst.dpDiv;
this._base_gotoToday(id);
- var now = new Date();
var tp_inst = this._get(inst, 'timepicker');
- if (tp_inst && tp_inst._defaults.showTimezone && tp_inst.timezone_select) {
- var tzoffset = now.getTimezoneOffset(); // If +0100, returns -60
- var tzsign = tzoffset > 0 ? '-' : '+';
- tzoffset = Math.abs(tzoffset);
- var tzmin = tzoffset % 60;
- tzoffset = tzsign + ('0' + (tzoffset - tzmin) / 60).slice(-2) + ('0' + tzmin).slice(-2);
- if (tp_inst._defaults.timezoneIso8601)
- tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
- tp_inst.timezone_select.val(tzoffset);
- }
+ selectLocalTimeZone(tp_inst);
+ var now = new Date();
this._setTime(inst, now);
$( '.ui-datepicker-today', $dp).click();
};
@@ -1403,6 +1397,24 @@ var parseDateTimeInternal = function(dateFormat, timeFormat, dateTimeString, dat
return {date: date};
}
+//#######################################################################################
+// Internal function to set timezone_select to the local timezone
+//#######################################################################################
+var selectLocalTimeZone = function(tp_inst)
+{
+ if (tp_inst && tp_inst._defaults.showTimezone && tp_inst.timezone_select) {
+ var now = new Date();
+ var tzoffset = now.getTimezoneOffset(); // If +0100, returns -60
+ var tzsign = tzoffset > 0 ? '-' : '+';
+ tzoffset = Math.abs(tzoffset);
+ var tzmin = tzoffset % 60;
+ tzoffset = tzsign + ('0' + (tzoffset - tzmin) / 60).slice(-2) + ('0' + tzmin).slice(-2);
+ if (tp_inst._defaults.timezoneIso8601)
+ tzoffset = tzoffset.substring(0, 3) + ':' + tzoffset.substring(3);
+ tp_inst.timezone_select.val(tzoffset);
+ }
+}
+
$.timepicker = new Timepicker(); // singleton instance
$.timepicker.version = "1.0.1";