Skip to content

Commit 19e6e67

Browse files
Fixes Issue trentrichardson#385 - some timezones have 30 and 45 minute offsets
1 parent d97c3a3 commit 19e6e67

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

index.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
.example-container{ background-color: #f4f4f4; border-bottom: solid 2px #777777; margin: 0 0 40px 0; padding: 20px; }
2222
.example-container p{ font-weight: bold; }
2323
.example-container > dl dt{ font-weight: bold; height: 20px; }
24-
.example-container > dl dd{ margin: -20px 0 10px 100px; border-bottom: solid 1px #fff; }
24+
.example-container > dl dd{ margin: -20px 0 10px 140px; border-bottom: solid 1px #fff; }
2525
.example-container input{ width: 150px; }
2626
.clear{ clear: both; }
2727
#ui-datepicker-div, .ui-datepicker{ font-size: 80%; }
@@ -164,6 +164,7 @@ <h2>Some Examples</h2>
164164
<dt>showMinute</dt><dd>Show the minute, default=true</dd>
165165
<dt>showSecond</dt><dd>Show the second, default=false</dd>
166166
<dt>showMillisec</dt><dd>Show the millisecond, default=false</dd>
167+
<dt>showTimezone</dt><dd>Show the timezone, default=false</dd>
167168
</dl>
168169
<div>
169170
<input type="text" name="example5" id="example5" value="" />
@@ -427,12 +428,15 @@ <h2>Some Examples</h2>
427428

428429
<!-- ============= example -->
429430
<div class="example-container">
430-
<p>Use the utility function to format your own time. $.datepicker.formatTime(format, time, options)</p>
431+
<p>The following demonstrates how to use timezones and timezone options.</p>
431432
<dl>
432433
<dt>timezoneList</dt><dd>An array of timezones, either with strings ['-0500','-0600',..] or objects [ { value: '-0500', label: 'EST'}, { value: '-0600', label: 'CST' },..]</dd>
433-
<dt>timezoneIso8601</dt><dd>Formats the timezones in the timezone list in 8601 format
434+
<dt>defaultTimezone</dt><dd>The default selected timezone in the dropdown. default='+0000'</dd>
435+
<dt>useLocalTimezone</dt><dd>Use the local timezone of the client's browser. default=false</dd>
436+
<dt>timezoneIso8601</dt><dd>Formats the timezones in the timezone list in 8601 format</dd>
434437
</dl>
435-
438+
<p>The third example here demonstrates using the abbreviation for timezones. If this is used defaultTimezone must match the value (abbreviation). Do note that useLocalTimezone may not function properly when using abbreviations as it will only work with '+0000' formats.</p>
439+
<p>Daylight savings time may be interpreted as a timezone. Create your own timezoneList and specify entries for Daylight Savings or use useLocalTimezone to help get the correct offset.</p>
436440
<div>
437441
<input type="text" name="example15a" id="example15a" value="" />
438442
<input type="text" name="example15b" id="example15b" value="" />

jquery-ui-timepicker-addon.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,12 @@ $.extend(Timepicker.prototype, {
182182
tp_inst.pmNames = $.map(tp_inst._defaults.pmNames, function(val) { return val.toUpperCase(); });
183183

184184
if (tp_inst._defaults.timezoneList === null) {
185-
var timezoneList = [];
186-
for (var i = -11; i <= 12; i++) {
187-
timezoneList.push((i >= 0 ? '+' : '-') + ('0' + Math.abs(i).toString()).slice(-2) + '00');
188-
}
185+
var timezoneList = ['-1200','-1100','-1000','-0930','-0900','-0800','-0700','-0600','-0500','-0430','-0400','-0330','-0300','-0200','-0100','+0000','+0100','+0200','+0300',
186+
'+0330','+0400','+0430','+0500','+0530','+0545','+0600','+0630','+0700','+0800','+0845','+0900','+0930','+1000','+1030','+1100','+1130','+1200','+1245','+1300','+1400'];
187+
// var timezoneList = [];
188+
// for (var i = -11; i <= 12; i++) {
189+
// timezoneList.push((i >= 0 ? '+' : '-') + ('0' + Math.abs(i).toString()).slice(-2) + '00');
190+
// }
189191
if (tp_inst._defaults.timezoneIso8601) {
190192
timezoneList = $.map(timezoneList, function(val) {
191193
return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
@@ -307,7 +309,7 @@ $.extend(Timepicker.prototype, {
307309
millisecGridSize = 0,
308310
size = null;
309311

310-
// Hours
312+
// Hours
311313
html += '<dd class="ui_tpicker_hour"><div class="ui_tpicker_hour_slider"' +
312314
((o.showHour) ? '' : noDisplay) + '></div>';
313315
if (o.showHour && o.hourGrid > 0) {

0 commit comments

Comments
 (0)