[FIX] web: datetime value parsing without time
If the date format language was changed to invert month & day values (so, changed to the classic european format instead of the american format) Then, when entering manually a datetime without the time (so just '01/02/2014' instead of '01/02/2014 00:00:00', the day and month were inverted (the datetime was set to 02/01/2014 instead of 01/02/2014) because the datetime entered did not exactly match the date + time pattern. We therefore added a fallback case, to test to parse the value with the date pattern alone (without the time)
This commit is contained in:
parent
e607f03fd0
commit
6372313494
|
@ -266,9 +266,16 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
|
||||||
value, (date_pattern + ' ' + time_pattern));
|
value, (date_pattern + ' ' + time_pattern));
|
||||||
if (datetime !== null)
|
if (datetime !== null)
|
||||||
return instance.web.datetime_to_str(datetime);
|
return instance.web.datetime_to_str(datetime);
|
||||||
datetime = Date.parseExact(value.toString().replace(/\d+/g, function(m){
|
datetime = Date.parseExact(value, (date_pattern));
|
||||||
|
if (datetime !== null)
|
||||||
|
return instance.web.datetime_to_str(datetime);
|
||||||
|
var leading_zero_value = value.toString().replace(/\d+/g, function(m){
|
||||||
return m.length === 1 ? "0" + m : m ;
|
return m.length === 1 ? "0" + m : m ;
|
||||||
}), (date_pattern + ' ' + time_pattern));
|
});
|
||||||
|
datetime = Date.parseExact(leading_zero_value, (date_pattern + ' ' + time_pattern));
|
||||||
|
if (datetime !== null)
|
||||||
|
return instance.web.datetime_to_str(datetime);
|
||||||
|
datetime = Date.parseExact(leading_zero_value, (date_pattern));
|
||||||
if (datetime !== null)
|
if (datetime !== null)
|
||||||
return instance.web.datetime_to_str(datetime);
|
return instance.web.datetime_to_str(datetime);
|
||||||
datetime = Date.parse(value);
|
datetime = Date.parse(value);
|
||||||
|
|
Loading…
Reference in New Issue