From 396fd73eebb7f9d5dec29e006f5d38cc11ad27cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=81=A5=E8=BE=89?= <40563566+mrwangjianhui@users.noreply.github.com> Date: Mon, 18 Jul 2022 15:56:23 +0800 Subject: [PATCH] fix format last_modify --- seahub/base/templatetags/seahub_tags.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/seahub/base/templatetags/seahub_tags.py b/seahub/base/templatetags/seahub_tags.py index 12e6b3de94..822c96b7a3 100644 --- a/seahub/base/templatetags/seahub_tags.py +++ b/seahub/base/templatetags/seahub_tags.py @@ -12,7 +12,7 @@ from django.utils import translation, formats from django.utils.dateformat import DateFormat from django.utils.translation import ugettext as _ from django.utils.translation import ugettext, ungettext -from django.utils.translation import pgettext +from django.utils.timezone import get_current_timezone from django.utils.html import escape from seahub.base.accounts import User @@ -28,6 +28,8 @@ from seahub.utils.html import avoid_wrapping from seahub.utils.file_size import get_file_size_unit register = template.Library() +current_timezone = get_current_timezone() + @register.filter(name='tsstr_sec') def tsstr_sec(value): @@ -280,7 +282,7 @@ def translate_commit_desc_escape(value): def translate_seahub_time(value, autoescape=None): if isinstance(value, int) or isinstance(value, int): # check whether value is int try: - val = datetime.fromtimestamp(value) # convert timestamp to datetime + val = datetime.fromtimestamp(value, tz=current_timezone) # convert timestamp to datetime except ValueError as e: return "" elif isinstance(value, datetime):