[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:
Denis Ledoux 2014-12-24 11:30:58 +01:00
parent e607f03fd0
commit 6372313494
1 changed files with 9 additions and 2 deletions

View File

@ -266,9 +266,16 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
value, (date_pattern + ' ' + time_pattern));
if (datetime !== null)
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 ;
}), (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)
return instance.web.datetime_to_str(datetime);
datetime = Date.parse(value);