Skip to content

Commit a8c575a

Browse files
Added support for a date/time separator
1 parent 2781508 commit a8c575a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

jquery-ui-timepicker-addon.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ function Timepicker() {
6161
hourGrid: 0,
6262
minuteGrid: 0,
6363
secondGrid: 0,
64-
alwaysSetTime: true
64+
alwaysSetTime: true,
65+
separator: ' '
6566
};
6667
$.extend(this._defaults, this.regional['']);
6768
}
@@ -159,7 +160,7 @@ $.extend(Timepicker.prototype, {
159160
// parse the time string from input value or _setTime
160161
//########################################################################
161162
_parseTime: function(timeString, withDate) {
162-
var regstr = this._defaults.timeFormat.toString()
163+
var regstr = this._defaults.separator + this._defaults.timeFormat.toString()
163164
.replace(/h{1,2}/ig, '(\\d?\\d)')
164165
.replace(/m{1,2}/ig, '(\\d?\\d)')
165166
.replace(/s{1,2}/ig, '(\\d?\\d)')
@@ -173,7 +174,7 @@ $.extend(Timepicker.prototype, {
173174
// the time should come after x number of characters and a space.
174175
// x = at least the length of text specified by the date format
175176
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
176-
regstr = '.{' + dp_dateFormat.length + ',}\\s+' + regstr;
177+
regstr = '.{' + dp_dateFormat.length + ',}\\s*?' + regstr;
177178
}
178179

179180
if (treg) {
@@ -519,7 +520,7 @@ $.extend(Timepicker.prototype, {
519520
if (this._defaults.timeOnly === true) formattedDateTime = this.formattedTime;
520521
else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
521522
if (this.$altInput) this.$altInput.val(this.formattedTime);
522-
else formattedDateTime += ' ' + this.formattedTime;
523+
else formattedDateTime += this._defaults.separator + this.formattedTime;
523524
}
524525

525526
this.formattedDateTime = formattedDateTime;

0 commit comments

Comments
 (0)