Skip to content

Commit 8c229ad

Browse files
Fixes ampm issue and parsing string literals, issues trentrichardson#383 and trentrichardson#394
1 parent c685a06 commit 8c229ad

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

jquery-ui-timepicker-addon.js

Lines changed: 6 additions & 4 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',
@@ -975,7 +975,7 @@ $.datepicker.parseTime = function(timeFormat, timeString, options) {
975975
ampm = '';
976976
resTime.ampm = '';
977977
} else {
978-
ampm = $.inArray(treg[order.t], o.amNames) !== -1 ? 'AM' : 'PM';
978+
ampm = $.inArray(treg[order.t].toUpperCase(), o.amNames) !== -1 ? 'AM' : 'PM';
979979
resTime.ampm = o[ampm == 'AM' ? 'amNames' : 'pmNames'][0];
980980
}
981981
}
@@ -1055,7 +1055,7 @@ $.datepicker.formatTime = function(format, time, options) {
10551055
hour = 12;
10561056
}
10571057
}
1058-
tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz])/g, function(match) {
1058+
tmptime = tmptime.replace(/(?:hh?|mm?|ss?|[tT]{1,2}|[lz]|('.*?'|".*?"))/g, function(match) {
10591059
switch (match.toLowerCase()) {
10601060
case 'hh': return ('0' + hour).slice(-2);
10611061
case 'h': return hour;
@@ -1073,6 +1073,8 @@ $.datepicker.formatTime = function(format, time, options) {
10731073
return match.charAt(0) === 'T' ? ampmName.toUpperCase() : ampmName.toLowerCase();
10741074
}
10751075
return '';
1076+
default:
1077+
return match.replace(/\'/g, "") || "'";
10761078
}
10771079
});
10781080

0 commit comments

Comments
 (0)