From 072fa3e84f0768db1b35be6d35427bfaec98bb77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Sat, 1 Oct 2022 14:15:05 +0200 Subject: [PATCH] Use local date format as default and use context date format as fallback issue11728 review427801003 --- src/common.js | 2 +- src/view/form.js | 11 +++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/common.js b/src/common.js index ccfcde0ada..b16f923579 100644 --- a/src/common.js +++ b/src/common.js @@ -223,7 +223,7 @@ Sao.common.date_format = function(format) { if (jQuery.isEmptyObject(format)) { - format = '%Y-%m-%d'; + format = '%x'; if (Sao.Session.current_session) { var context = Sao.Session.current_session.context; if (context.locale && context.locale.date) { diff --git a/src/view/form.js b/src/view/form.js index 94994930d5..74aedd64cf 100644 --- a/src/view/form.js +++ b/src/view/form.js @@ -1659,7 +1659,6 @@ function eval_pyson(value){ _input_format: '%Y-%m-%d', _format: Sao.common.format_date, _parse: Sao.common.parse_date, - _default_format: '%x', init: function(view, attributes) { Sao.View.Form.Date._super.init.call(this, view, attributes); this.el = jQuery('
', { @@ -1740,7 +1739,8 @@ function eval_pyson(value){ if (this.field && this.record) { return this.field.date_format(this.record); } else { - return this._default_format; + return Sao.common.date_format( + this.view.screen.context.date_format); } }, get_value: function() { @@ -1797,13 +1797,13 @@ function eval_pyson(value){ _input_format: '%Y-%m-%dT%H:%M:%S', _format: Sao.common.format_datetime, _parse: Sao.common.parse_datetime, - _default_format: '%x %X', get_format: function() { if (this.field && this.record) { return (this.field.date_format(this.record) + ' ' + this.field.time_format(this.record)); } else { - return this._default_format; + return (Sao.common.date_format( + this.view.screen.context.date_format) + ' %X'); } }, cast: function(value){ @@ -1818,7 +1818,6 @@ function eval_pyson(value){ _input_format: '%H:%M:%S', _format: Sao.common.format_time, _parse: Sao.common.parse_time, - _default_format: '%X', init: function(view, attributes) { Sao.View.Form.Time._super.init.call(this, view, attributes); if (~navigator.userAgent.indexOf("Firefox")) { @@ -1830,7 +1829,7 @@ function eval_pyson(value){ if (this.field && this.record) { return this.field.time_format(this.record); } else { - return this._default_format; + return '%X'; } }, cast: function(value){