forum: use a more readable date format

This commit is contained in:
Lephe 2021-07-10 17:54:07 +02:00
parent 1837f8f9a6
commit 7fc4424812
Signed by untrusted user: Lephenixnoir
GPG Key ID: 1BBA026E13FC0495
2 changed files with 4 additions and 4 deletions

View File

@ -9,9 +9,9 @@
<td class="author">{{ widget_user.profile(c.author) }}</td>
<td class="message">
<div class="info">
<div>Posté le {{ c.date_created|date }}</div>
<div>Posté le {{ c.date_created|dyndate }}</div>
{% if c.date_created != c.date_modified %}
<div>Modifié le {{ c.date_modified|date }}</div>
<div>Modifié le {{ c.date_modified|dyndate }}</div>
{% endif %}
<div><a href="{{ request.path }}#{{ c.id }}">Permalien</a></div>
{# TODO: Let guests edit their posts #}

View File

@ -13,8 +13,8 @@ def filter_date(date, format="%Y-%m-%d à %H:%M"):
"Août", "Septembre", "Octobre", "Novembre","Décembre"] \
[date.month - 1]
# Omit current year in the dynamic format
if date.year == datetime.now().year:
# Omit current year in the last 8 months
if (date - datetime.now()).days <= 8 * 30:
format = f"{d} {m} à %H:%M"
else:
format = f"{d} {m} %Y à %H:%M"