From 7fca010e97f3631111eb2b20b1f71e27c76e2585 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elmeri=20Niemel=C3=A4?= Date: Fri, 5 Nov 2021 17:06:57 +0200 Subject: [PATCH] [IMP] Add ability to include properly formatted datetime field in a report displaying date and time --- report_py3o/models/_py3o_parser_context.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/report_py3o/models/_py3o_parser_context.py b/report_py3o/models/_py3o_parser_context.py index 370435150..31d5e07cd 100644 --- a/report_py3o/models/_py3o_parser_context.py +++ b/report_py3o/models/_py3o_parser_context.py @@ -42,6 +42,7 @@ class Py3oParserContext(object): # prefixes with o_ to avoid nameclash with default method provided # by py3o.template "o_format_date": self._format_date, + "o_format_datetime": self._format_datetime, # give access to the time lib "time": time, # keeps methods from report_sxw to ease migration @@ -91,6 +92,12 @@ class Py3oParserContext(object): self._env, value, lang_code=lang_code, date_format=date_format ) + def _format_datetime(self, value, tz=False, dt_format='medium', lang_code=False): + return misc.format_datetime( + self._env, value, tz=tz, dt_format=dt_format, lang_code=lang_code + ) + + def _old_format_lang( self, value,