Skip to content

Commit d97c3a3

Browse files
1 parent a0302fa commit d97c3a3

File tree

2 files changed

+63
-15
lines changed

2 files changed

+63
-15
lines changed

index.html

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -423,16 +423,62 @@ <h2>Some Examples</h2>
423423
});
424424
</pre>
425425
</div>
426+
427+
428+
<!-- ============= example -->
429+
<div class="example-container">
430+
<p>Use the utility function to format your own time. $.datepicker.formatTime(format, time, options)</p>
431+
<dl>
432+
<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+
</dl>
435+
436+
<div>
437+
<input type="text" name="example15a" id="example15a" value="" />
438+
<input type="text" name="example15b" id="example15b" value="" />
439+
<input type="text" name="example15c" id="example15c" value="" />
440+
</div>
426441

442+
<pre>
443+
$('#example15a').datetimepicker({
444+
timeFormat: 'hh:mm z',
445+
showTimezone: true
446+
});
447+
448+
$('#example15b').datetimepicker({
449+
timeFormat: 'hh:mm z',
450+
showTimezone: true,
451+
timezoneList: [
452+
{ value: '-0500', label: 'Eastern'},
453+
{ value: '-0600', label: 'Central' },
454+
{ value: '-0700', label: 'Mountain' },
455+
{ value: '-0800', label: 'Pacific' }
456+
]
457+
});
458+
459+
$('#example15c').datetimepicker({
460+
timeFormat: 'hh:mm z',
461+
showTimezone: true,
462+
timezone: 'MT',
463+
timezoneList: [
464+
{ value: 'ET', label: 'Eastern'},
465+
{ value: 'CT', label: 'Central' },
466+
{ value: 'MT', label: 'Mountain' },
467+
{ value: 'PT', label: 'Pacific' }
468+
]
469+
});
470+
</pre>
471+
</div>
472+
427473
<!-- ============= example -->
428474
<div class="example-container">
429475
<p>Connect to the onSelect event (Use your browser's js console for this example).</p>
430476
<div>
431-
<input type="text" name="example15" id="example15" value="" />
477+
<input type="text" name="example16" id="example15" value="" />
432478
</div>
433479

434480
<pre>
435-
$('#example15').datetimepicker({
481+
$('#example16').datetimepicker({
436482
showSecond: true,
437483
showMillisec: true,
438484
timeFormat: 'hh:mm:ss:l',
@@ -448,12 +494,12 @@ <h2>Some Examples</h2>
448494
<div class="example-container">
449495
<p>Create a datetime range with a start and end date.</p>
450496
<div>
451-
<input type="text" name="example16_start" id="example16_start" value="" /> <input type="text" name="example16_end" id="example16_end" value="" />
497+
<input type="text" name="example17_start" id="example17_start" value="" /> <input type="text" name="example17_end" id="example17_end" value="" />
452498
</div>
453499

454500
<pre>
455-
var startDateTextBox = $('#example16_start');
456-
var endDateTextBox = $('#example16_end');
501+
var startDateTextBox = $('#example17_start');
502+
var endDateTextBox = $('#example17_end');
457503

458504
startDateTextBox.datetimepicker({
459505
onClose: function(dateText, inst) {
@@ -494,11 +540,11 @@ <h2>Some Examples</h2>
494540
<div class="example-container">
495541
<p>Use the <a href="http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/" title="jQueryUI Slider Accessibility Addon">sliderAccess addon</a> to allow timepicker sliders to work on touch devices.</p>
496542
<div>
497-
<div id="example17"></div>
543+
<div id="example18"></div>
498544
</div>
499545

500546
<pre>
501-
$('#example17').datetimepicker({
547+
$('#example18').datetimepicker({
502548
addSliderAccess: true,
503549
sliderAccessArgs: { touchonly: false }
504550
});
@@ -516,15 +562,17 @@ <h2>Some Examples</h2>
516562
</dl>
517563

518564
<div>
519-
<div id="example18"></div>
565+
<div id="example19"></div>
520566
</div>
521567

522568
<pre>
523-
$('#example18').text(
569+
$('#example19').text(
524570
$.datepicker.formatTime('hh:mm z', { hour: 14, minute: 36, timezone: '+2000' }, { ampm: false })
525571
);
526572
</pre>
527573
</div>
574+
575+
528576

529577
<h2>Version</h2>
530578
<p>Version 1.0.2</p>

jquery-ui-timepicker-addon.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ function Timepicker() {
4141
currentText: 'Now',
4242
closeText: 'Done',
4343
ampm: false,
44-
amNames: ['AM', 'A'],
45-
pmNames: ['PM', 'P'],
44+
amNames: ['am', 'a'],
45+
pmNames: ['pm', 'p'],
4646
timeFormat: 'hh:mm tt',
4747
timeSuffix: '',
4848
timeOnlyTitle: 'Choose Time',
@@ -185,12 +185,12 @@ $.extend(Timepicker.prototype, {
185185
var timezoneList = [];
186186
for (var i = -11; i <= 12; i++) {
187187
timezoneList.push((i >= 0 ? '+' : '-') + ('0' + Math.abs(i).toString()).slice(-2) + '00');
188-
}
188+
}
189189
if (tp_inst._defaults.timezoneIso8601) {
190190
timezoneList = $.map(timezoneList, function(val) {
191191
return val == '+0000' ? 'Z' : (val.substring(0, 3) + ':' + val.substring(3));
192192
});
193-
}
193+
}
194194
tp_inst._defaults.timezoneList = timezoneList;
195195
}
196196

@@ -952,7 +952,7 @@ $.datepicker.parseTime = function(timeFormat, timeString, options) {
952952
.replace(/s{1,2}/ig, '(\\d?\\d)')
953953
.replace(/l{1}/ig, '(\\d?\\d?\\d)')
954954
.replace(/t{1,2}/ig, getPatternAmpm(o.amNames, o.pmNames))
955-
.replace(/z{1}/ig, '(z|[-+]\\d\\d:?\\d\\d)?')
955+
.replace(/z{1}/ig, '(z|[-+]\\d\\d:?\\d\\d|\\S+)?')
956956
.replace(/\s/g, '\\s?') + o.timeSuffix + '$',
957957
order = getFormatPositions(timeFormat),
958958
ampm = '',
@@ -1063,7 +1063,7 @@ $.datepicker.formatTime = function(format, time, options) {
10631063
if (match.length == 1) {
10641064
ampmName = ampmName.charAt(0);
10651065
}
1066-
return match.charAt(0) == 'T' ? ampmName.toUpperCase() : ampmName.toLowerCase();
1066+
return match.charAt(0) === 'T' ? ampmName.toUpperCase() : ampmName.toLowerCase();
10671067
}
10681068
return '';
10691069
}

0 commit comments

Comments
 (0)