Convert passed datetime object to localetime

Closes #274
This commit is contained in:
Christopher C. Wells 2021-08-06 08:33:41 -07:00
parent 1aad600f6c
commit 858436e840
1 changed files with 6 additions and 1 deletions

View File

@ -30,9 +30,14 @@ def datetime_short(date):
:param date: datetime instance :param date: datetime instance
:return: a string representation of `date`. :return: a string representation of `date`.
""" """
now = timezone.now()
date_string = None date_string = None
time_string = None time_string = None
# The value received from templates will be UTC so it must be converted to
# localtime here.
date = timezone.localtime(date)
now = timezone.localtime()
if now.date() == date.date(): if now.date() == date.date():
date_string = _('Today') date_string = _('Today')
time_string = formats.date_format(date, format='TIME_FORMAT') time_string = formats.date_format(date, format='TIME_FORMAT')