Added support for a date/time separator

This commit is contained in:
Michael J. Simons 2010-12-16 22:33:53 +01:00
parent 27815082b5
commit a8c575a163

View file

@ -61,7 +61,8 @@ function Timepicker() {
hourGrid: 0, hourGrid: 0,
minuteGrid: 0, minuteGrid: 0,
secondGrid: 0, secondGrid: 0,
alwaysSetTime: true alwaysSetTime: true,
separator: ' '
}; };
$.extend(this._defaults, this.regional['']); $.extend(this._defaults, this.regional['']);
} }
@ -159,7 +160,7 @@ $.extend(Timepicker.prototype, {
// parse the time string from input value or _setTime // parse the time string from input value or _setTime
//######################################################################## //########################################################################
_parseTime: function(timeString, withDate) { _parseTime: function(timeString, withDate) {
var regstr = this._defaults.timeFormat.toString() var regstr = this._defaults.separator + this._defaults.timeFormat.toString()
.replace(/h{1,2}/ig, '(\\d?\\d)') .replace(/h{1,2}/ig, '(\\d?\\d)')
.replace(/m{1,2}/ig, '(\\d?\\d)') .replace(/m{1,2}/ig, '(\\d?\\d)')
.replace(/s{1,2}/ig, '(\\d?\\d)') .replace(/s{1,2}/ig, '(\\d?\\d)')
@ -173,7 +174,7 @@ $.extend(Timepicker.prototype, {
// the time should come after x number of characters and a space. // the time should come after x number of characters and a space.
// x = at least the length of text specified by the date format // x = at least the length of text specified by the date format
var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat'); var dp_dateFormat = $.datepicker._get(this.inst, 'dateFormat');
regstr = '.{' + dp_dateFormat.length + ',}\\s+' + regstr; regstr = '.{' + dp_dateFormat.length + ',}\\s*?' + regstr;
} }
if (treg) { if (treg) {
@ -519,7 +520,7 @@ $.extend(Timepicker.prototype, {
if (this._defaults.timeOnly === true) formattedDateTime = this.formattedTime; if (this._defaults.timeOnly === true) formattedDateTime = this.formattedTime;
else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) { else if (this._defaults.timeOnly !== true && (this._defaults.alwaysSetTime || timeAvailable)) {
if (this.$altInput) this.$altInput.val(this.formattedTime); if (this.$altInput) this.$altInput.val(this.formattedTime);
else formattedDateTime += ' ' + this.formattedTime; else formattedDateTime += this._defaults.separator + this.formattedTime;
} }
this.formattedDateTime = formattedDateTime; this.formattedDateTime = formattedDateTime;