From 5ab6e7bc7dd22b4c5704c6c4eb1af498a0627241 Mon Sep 17 00:00:00 2001 From: Jun Omae Date: Thu, 11 Aug 2011 15:55:47 +0900 Subject: [PATCH] Now button sets the current timezone. --- jquery-ui-timepicker-addon.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 1b17233..6973632 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -989,7 +989,17 @@ $.datepicker._gotoToday = function(id) { var inst = this._getInst($(id)[0]), $dp = inst.dpDiv; this._base_gotoToday(id); - this._setTime(this._getInst($(id)[0]), new Date()); + var now = new Date(); + var tp_inst = this._get(inst, 'timepicker'); + if (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); + tp_inst.timezone_select.val(tzoffset); + } + this._setTime(inst, now); $( '.ui-datepicker-today', $dp).click(); };