diff --git a/example-timezone.html b/example-timezone.html new file mode 100644 index 0000000..854b89d --- /dev/null +++ b/example-timezone.html @@ -0,0 +1,42 @@ + + +
+ + + + + + + + + + + + diff --git a/jquery-ui-timepicker-addon.js b/jquery-ui-timepicker-addon.js index 16a636b..22aab61 100644 --- a/jquery-ui-timepicker-addon.js +++ b/jquery-ui-timepicker-addon.js @@ -37,7 +37,8 @@ function Timepicker() { timeText: 'Time', hourText: 'Hour', minuteText: 'Minute', - secondText: 'Second' + secondText: 'Second', + timezoneText: 'Time Zone' }; this._defaults = { // Global defaults for all the datetime picker instances showButtonPanel: true, @@ -45,6 +46,7 @@ function Timepicker() { showHour: true, showMinute: true, showSecond: false, + showTimezone: false, showTime: true, stepHour: 0.05, stepMinute: 0.05, @@ -52,6 +54,7 @@ function Timepicker() { hour: 0, minute: 0, second: 0, + timezone: '+0000', hourMin: 0, minuteMin: 0, secondMin: 0, @@ -66,7 +69,11 @@ function Timepicker() { alwaysSetTime: true, separator: ' ', altFieldTimeOnly: true, - showTimepicker: true + showTimepicker: true, + timezoneList: ["-1100", "-1000", "-0900", "-0800", "-0700", "-0600", + "-0500", "-0400", "-0300", "-0200", "-0100", "+0000", + "+0100", "+0200", "+0300", "+0400", "+0500", "+0600", + "+0700", "+0800", "+0900", "+1000", "+1100", "+1200"] }; $.extend(this._defaults, this.regional['']); } @@ -79,9 +86,11 @@ $.extend(Timepicker.prototype, { hour_slider: null, minute_slider: null, second_slider: null, + timezone_select: null, hour: 0, minute: 0, second: 0, + timezone: '+0000', hourMinOriginal: null, minuteMinOriginal: null, secondMinOriginal: null, @@ -92,6 +101,10 @@ $.extend(Timepicker.prototype, { formattedDate: '', formattedTime: '', formattedDateTime: '', + timezoneList: ["-1100", "-1000", "-0900", "-0800", "-0700", "-0600", + "-0500", "-0400", "-0300", "-0200", "-0100", "+0000", + "+0100", "+0200", "+0300", "+0400", "+0500", "+0600", + "+0700", "+0800", "+0900", "+1000", "+1100", "+1200"], /* Override the default settings for all instances of the time picker. @param settings object - the new settings to use as defaults (anonymous object) @@ -184,6 +197,7 @@ $.extend(Timepicker.prototype, { .replace(/m{1,2}/ig, '(\\d?\\d)') .replace(/s{1,2}/ig, '(\\d?\\d)') .replace(/t{1,2}/ig, '(am|pm|a|p)?') + .replace(/z{1}/ig, '((\\+|-)\\d\\d\\d\\d)?') .replace(/\s/g, '\\s?') + '$', order = this._getFormatPositions(), treg; @@ -196,7 +210,7 @@ $.extend(Timepicker.prototype, { var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat'); regstr = '.{' + dp_dateFormat.length + ',}' + this._defaults.separator + regstr; } - + treg = timeString.match(new RegExp(regstr, 'i')); if (treg) { @@ -215,6 +229,7 @@ $.extend(Timepicker.prototype, { if (order.m !== -1) this.minute = Number(treg[order.m]); if (order.s !== -1) this.second = Number(treg[order.s]); + if (order.z !== -1) this.timezone = treg[order.z]; return true; @@ -226,8 +241,8 @@ $.extend(Timepicker.prototype, { // figure out position of time elements.. cause js cant do named captures //######################################################################## _getFormatPositions: function() { - var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2})/g), - orders = { h: -1, m: -1, s: -1, t: -1 }; + var finds = this._defaults.timeFormat.toLowerCase().match(/(h{1,2}|m{1,2}|s{1,2}|t{1,2}|z)/g), + orders = { h: -1, m: -1, s: -1, t: -1, z: -1 }; if (finds) for (var i = 0; i < finds.length; i++) @@ -327,6 +342,11 @@ $.extend(Timepicker.prototype, { ''; } else html += ''; + + html += '