From cf5b380a8617f595da9af1c49c072809df2362d0 Mon Sep 17 00:00:00 2001 From: Sebastian Dietrich Date: Sat, 16 Dec 2017 17:43:59 +0100 Subject: [PATCH] Format comment timestamps according to users preferences. --- code_comments/comment.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/code_comments/comment.py b/code_comments/comment.py index 8850db9..ae033e7 100644 --- a/code_comments/comment.py +++ b/code_comments/comment.py @@ -7,7 +7,7 @@ import trac.wiki.formatter from trac.mimeview.api import Context -from time import strftime, localtime +from trac.util.datefmt import format_datetime, user_time from code_comments import db from trac.util import Markup from trac.web.href import Href @@ -129,9 +129,7 @@ def path_link_tag(self): return Markup('%s' % (self.href(), self.link_text())) def formatted_date(self): - encoding = locale.getlocale()[1] if locale.getlocale()[1] else 'utf-8' - return strftime('%d %b %Y, %H:%M', - localtime(self.time)).decode(encoding) + return user_time(self.req, format_datetime, self.time, '%x %X') def get_ticket_relations(self): query = """