From 5decda2998bec9fd2c8811e45af5f015a773decb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Wed, 9 Jul 2014 00:36:28 +0200 Subject: [PATCH] Use null for empty Date review13391003 --- src/common.js | 7 +++++-- src/model.js | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/common.js b/src/common.js index 40b969e8cf..ac83f6925b 100644 --- a/src/common.js +++ b/src/common.js @@ -127,8 +127,11 @@ }; Sao.common.parse_datetime = function(date_format, time_format, value) { - var date = Sao.DateTime( - jQuery.datepicker.parseDate(date_format, value)); + value = jQuery.datepicker.parseDate(date_format, value); + if (!value) { + return null; + } + var date = Sao.DateTime(value); var time_value = value.replace(jQuery.datepicker.formatDate( date_format, date), '').trim(); var time = Sao.common.parse_time(time_format, time_value); diff --git a/src/model.js b/src/model.js index 6694a19019..3b269c4aec 100644 --- a/src/model.js +++ b/src/model.js @@ -1232,8 +1232,11 @@ set_client: function(record, value, force_change) { if (typeof value == 'string') { try { - value = Sao.Date(jQuery.datepicker.parseDate( - Sao.common.date_format(), value)); + value = jQuery.datepicker.parseDate( + Sao.common.date_format(), value); + if (value) { + value = Sao.Date(value); + } } catch (e) { value = this._default; }