mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
silently fix skiped minutes or times with just one digit, as parser is quite pedantic ;-)
This commit is contained in:
parent
db3422fccb
commit
a659b49f51
@ -285,7 +285,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
|
||||
// Check for required
|
||||
if(this.options && this.options.needed && !this.options.readonly && (this.getValue() == null || this.getValue().valueOf() == ''))
|
||||
{
|
||||
messages.push(this.egw().lang('input required'));
|
||||
messages.push(this.egw().lang('Field must not be empty !!!'));
|
||||
ok = false;
|
||||
}
|
||||
return ok;
|
||||
|
@ -83,6 +83,7 @@ var et2_date = et2_inputWidget.extend(
|
||||
var self = this;
|
||||
this.input_date.bind('change', function(e){
|
||||
self.set_value(this.value);
|
||||
return false;
|
||||
});
|
||||
|
||||
// Framewok skips nulls, but null needs to be processed here
|
||||
@ -128,8 +129,28 @@ var et2_date = et2_inputWidget.extend(
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
this.date = new Date(jQuery.datepicker.parseDateTime(this.input_date.datepicker('option', 'dateFormat'),
|
||||
this.input_date.datepicker('option', 'timeFormat'), _value));
|
||||
try {
|
||||
// silently fix skiped minutes or times with just one digit, as parser is quite pedantic ;-)
|
||||
var fix_reg = / ([0-9]+)(:[0-9]*)?( ?(a|p)m?)?$/i;
|
||||
var matches = _value.match(fix_reg);
|
||||
if (matches && (matches[1].length < 2 || matches[2] === undefined || matches[2].length < 3 ||
|
||||
matches[3] && matches[3] != 'am' && matches[3] != 'pm'))
|
||||
{
|
||||
if (matches[1].length < 2 && !matches[3]) matches[1] = '0'+matches[1];
|
||||
if (matches[2] === undefined) matches[2] = ':00';
|
||||
while (matches[2].length < 3) matches[2] = ':0'+matches[2].substr(1);
|
||||
_value = _value.replace(fix_reg, ' '+matches[1]+matches[2]+matches[3]);
|
||||
if (matches[4] !== undefined) matches[3] = matches[4].toLowerCase() == 'a' ? 'am' : 'pm';
|
||||
}
|
||||
var parsed = jQuery.datepicker.parseDateTime(this.input_date.datepicker('option', 'dateFormat'),
|
||||
this.input_date.datepicker('option', 'timeFormat'), _value);
|
||||
this.date = new Date(parsed);
|
||||
this.set_validation_error(false);
|
||||
}
|
||||
catch(e) {
|
||||
this.set_validation_error(this.egw().lang("'%1' has an invalid format !!!",_value));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (typeof _value == 'object' && _value.date) {
|
||||
this.date = _value.date;
|
||||
|
@ -49,6 +49,7 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd) {
|
||||
function timePreferences(_egw)
|
||||
{
|
||||
return {
|
||||
// timepicker does NOT work with spaces in timeformat
|
||||
"timeFormat": egw.preference("timeformat") == 12 ? "h:mmtt" : "HH:mm",
|
||||
"ampm": (egw.preference("timeformat") == "12"),
|
||||
"hourGrid": 4,
|
||||
|
Loading…
Reference in New Issue
Block a user