changeset 9fe74517f6a3 in tryton:5.0
details: https://hg.tryton.org/tryton?cmd=changeset;node=9fe74517f6a3
description:
        Use locale context to format date in domain parser

        issue8999
        review278401002
        (grafted from a40efbdaba86fc9236ea2ba58bb0333c81bb9d97)
diffstat:

 tryton/common/domain_parser.py |  13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)

diffs (51 lines):

diff -r ba9816dd9e04 -r 9fe74517f6a3 tryton/common/domain_parser.py
--- a/tryton/common/domain_parser.py    Sun Feb 02 17:00:34 2020 +0100
+++ b/tryton/common/domain_parser.py    Tue Feb 04 18:28:09 2020 +0100
@@ -10,7 +10,8 @@
 import io
 from collections import OrderedDict
 
-from tryton.common import untimezoned_date, timezoned_date, datetime_strftime
+from tryton.common import (
+    untimezoned_date, timezoned_date, datetime_strftime, date_format)
 from tryton.common.datetime_ import date_parse
 from tryton.common.timedelta import parse as timedelta_parse
 from tryton.common.timedelta import format as timedelta_format
@@ -271,7 +272,8 @@
     def convert_datetime():
         if not value:
             return
-        format_ = context.get('date_format', '%x') + ' %X'
+        format_ = (
+            date_format(context.get('date_format')) + ' ' + time_format(field))
         try:
             dt = date_parse(value, format_)
             return untimezoned_date(dt)
@@ -281,7 +283,7 @@
     def convert_date():
         if not value:
             return
-        format_ = context.get('date_format', '%x')
+        format_ = date_format(context.get('date_format'))
         try:
             return date_parse(value, format_).date()
         except (ValueError, TypeError):
@@ -525,7 +527,8 @@
     def format_datetime():
         if not value:
             return ''
-        format_ = context.get('date_format', '%x') + ' ' + time_format(field)
+        format_ = (
+            date_format(context.get('date_format')) + ' ' + time_format(field))
         if not isinstance(value, datetime.datetime):
             time = datetime.datetime.combine(value, datetime.time.min)
         else:
@@ -537,7 +540,7 @@
     def format_date():
         if not value:
             return ''
-        format_ = context.get('date_format', '%x')
+        format_ = date_format(context.get('date_format'))
         return datetime_strftime(value, format_)
 
     def format_time():

Reply via email to