Change display date format

This commit is contained in:
Gabriel Augendre 2020-12-06 16:51:49 +01:00
parent 3ff0c0292f
commit c9c378e2d6
No known key found for this signature in database
GPG key ID: 1E693F4CE4AEE7B4
4 changed files with 8 additions and 11 deletions

View file

@ -23,7 +23,7 @@ def drafts_count(request):
def date_format(request):
if request.path in IGNORED_PATHS:
return {}
return {"CUSTOM_ISO": r"Y-m-d\TH:i:sO"}
return {"CUSTOM_ISO": r"Y-m-d\TH:i:sO", "ISO_DATE": "Y-m-d"}
def git_version(request):

View file

@ -9,11 +9,7 @@
<ul>
{% for article in articles %}
<li>
{% if article.published_at %}
<time datetime="{{ article.published_at|date:CUSTOM_ISO }}">{{ article.published_at|date }}</time>
{% else %}
<time datetime="{{ article.updated_at|date:CUSTOM_ISO }}">{{ article.updated_at|date }}</time>
{% endif %}
{% include "articles/datetime_snippet.html" %}
: <a href="{% url 'article-detail' slug=article.slug %}">{{ article.title }}</a>
</li>
{% empty %}

View file

@ -0,0 +1,5 @@
{% if article.published_at %}
<time datetime="{{ article.published_at|date:CUSTOM_ISO }}">{{ article.published_at|date:ISO_DATE }}</time>
{% else %}
<time datetime="{{ article.updated_at|date:CUSTOM_ISO }}">{{ article.updated_at|date:ISO_DATE }}</time>
{% endif %}

View file

@ -1,9 +1,5 @@
{% load i18n %}
<p class="metadata">
{% if article.published_at %}
<time datetime="{{ article.published_at|date:CUSTOM_ISO }}">{{ article.published_at|date }}</time>
{% else %}
<time datetime="{{ article.updated_at|date:CUSTOM_ISO }}">{{ article.updated_at|date }}</time>
{% endif %}
{% include "articles/datetime_snippet.html" %}
{% include "articles/admin_link_snippet.html" %}
</p>