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

        issue8999
        review278401002
        (grafted from a40efbdaba86fc9236ea2ba58bb0333c81bb9d97)
diffstat:

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

diffs (50 lines):

diff -r bfc43d406f8b -r 74cc14b47c04 tryton/common/domain_parser.py
--- a/tryton/common/domain_parser.py    Sun Feb 02 16:59:40 2020 +0100
+++ b/tryton/common/domain_parser.py    Tue Feb 04 18:28:09 2020 +0100
@@ -10,7 +10,7 @@
 import io
 from collections import OrderedDict
 
-from tryton.common import untimezoned_date, timezoned_date
+from tryton.common import untimezoned_date, timezoned_date, 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 +271,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 +282,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 +526,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 +539,7 @@
     def format_date():
         if not value:
             return ''
-        format_ = context.get('date_format', '%x')
+        format_ = date_format(context.get('date_format'))
         return value.strftime(format_)
 
     def format_time():

Reply via email to