forked from extern/egroupware
catch exception from unparsable date and display it empty instead
This commit is contained in:
parent
f0868ec431
commit
e923931fda
@ -253,6 +253,7 @@ var et2_date = et2_inputWidget.extend(
|
|||||||
// Handle just time as a string in the form H:i
|
// Handle just time as a string in the form H:i
|
||||||
if(typeof _value == 'string' && isNaN(_value))
|
if(typeof _value == 'string' && isNaN(_value))
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
// silently fix skiped minutes or times with just one digit, as parser is quite pedantic ;-)
|
// silently fix skiped minutes or times with just one digit, as parser is quite pedantic ;-)
|
||||||
var fix_reg = new RegExp((this._type == "date-timeonly"?'^':' ')+'([0-9]+)(:[0-9]*)?( ?(a|p)m?)?$','i');
|
var fix_reg = new RegExp((this._type == "date-timeonly"?'^':' ')+'([0-9]+)(:[0-9]*)?( ?(a|p)m?)?$','i');
|
||||||
var matches = _value.match(fix_reg);
|
var matches = _value.match(fix_reg);
|
||||||
@ -327,6 +328,11 @@ var et2_date = et2_inputWidget.extend(
|
|||||||
|
|
||||||
this.set_validation_error(false);
|
this.set_validation_error(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
// catch exception from unparsable date and display it empty instead
|
||||||
|
catch(e) {
|
||||||
|
return this.set_value(null);
|
||||||
|
}
|
||||||
} else if (typeof _value == 'object' && _value.date) {
|
} else if (typeof _value == 'object' && _value.date) {
|
||||||
this.date = _value.date;
|
this.date = _value.date;
|
||||||
} else if (typeof _value == 'object' && _value.valueOf) {
|
} else if (typeof _value == 'object' && _value.valueOf) {
|
||||||
@ -785,11 +791,17 @@ var et2_date_ro = et2_valueWidget.extend([et2_IDetachedDOM],
|
|||||||
}
|
}
|
||||||
else if(typeof _value == 'string' && isNaN(_value))
|
else if(typeof _value == 'string' && isNaN(_value))
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
// parseDateTime to handle string PHP: DateTime local date/time format
|
// parseDateTime to handle string PHP: DateTime local date/time format
|
||||||
var parsed = (typeof jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value) !='undefined')?
|
var parsed = (typeof jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value) !='undefined')?
|
||||||
jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value):
|
jQuery.datepicker.parseDateTime("yy-mm-dd","hh:mm:ss", _value):
|
||||||
jQuery.datepicker.parseDateTime(this.egw().preference('dateformat'),this.egw().preference('timeformat') == '24' ? 'H:i' : 'g:i a', _value);
|
jQuery.datepicker.parseDateTime(this.egw().preference('dateformat'),this.egw().preference('timeformat') == '24' ? 'H:i' : 'g:i a', _value);
|
||||||
|
}
|
||||||
|
// display unparsable dates as empty
|
||||||
|
catch(e) {
|
||||||
|
this.span.attr("datetime", "").text("");
|
||||||
|
return;
|
||||||
|
}
|
||||||
var text = new Date(parsed);
|
var text = new Date(parsed);
|
||||||
|
|
||||||
// Update local variable, but remove the timezone offset that javascript adds
|
// Update local variable, but remove the timezone offset that javascript adds
|
||||||
|
Loading…
Reference in New Issue
Block a user