Skip to content

Commit baaa834

Browse files
authored
Manage hours-only timezones (e.g. +10)
Some databases (e.g. PostgreSQL) yield timezones as +/-hh rather than +/-hhmm. This change allows that format.
1 parent f9415cd commit baaa834

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/jquery-ui-timepicker-addon.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@
12461246
case 'c':
12471247
return '(\\d?\\d?\\d)';
12481248
case 'z':
1249-
return '(z|[-+]\\d\\d:?\\d\\d|\\S+)?';
1249+
return '(z|[-+]\\d\\d(:?\\d\\d)?|\\S+)?';
12501250
case 't':
12511251
return getPatternAmpm(o.amNames, o.pmNames);
12521252
default: // literal escaped in quotes
@@ -2089,6 +2089,10 @@
20892089
if (normalized.toUpperCase() === 'Z') { // if iso8601 with Z, its 0 minute offset
20902090
return 0;
20912091
}
2092+
2093+
if (/^(\-|\+)\d{2}$/.test(normalized)) {
2094+
normalized += "00"; // hours-only string - add the minutes
2095+
}
20922096

20932097
if (!/^(\-|\+)\d{4}$/.test(normalized)) { // possibly a user defined tz, so just give it back
20942098
return parseInt(tzString, 10);

0 commit comments

Comments
 (0)