From f05d653eaa4d89c25ad11e88474ffcdf812722f3 Mon Sep 17 00:00:00 2001 From: Bertrand Chenal Date: Fri, 16 May 2008 01:04:06 +0200 Subject: [PATCH] Add locale formating support for datetime fields on reports. --- trytond/report/report.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/trytond/report/report.py b/trytond/report/report.py index aad9a0faae..8d379c0696 100644 --- a/trytond/report/report.py +++ b/trytond/report/report.py @@ -460,7 +460,15 @@ class Report(object): (self._name, localcontext.get('language', False) or 'en_US')) if date: - date = time.strptime(str(value), '%Y-%m-%d') - return time.strftime(locale.nl_langinfo(locale.D_FMT).\ - replace('%y', '%Y'), date) + # length of date like 2001-01-01 is ten: + if len(str(value)) == 10: + locale_format = locale.D_FMT + string_pattern = '%Y-%m-%d' + else: + locale_format = locale.D_T_FMT + string_pattern = '%Y-%m-%d %H:%M:%S' + date = time.strptime(str(value), string_pattern) + return time.strftime(locale.nl_langinfo(locale_format).\ + replace('%y', '%Y'), date) + return locale.format('%.' + str(digits) + 'f', value, True)