Commit 6b47ba87 authored by Roland Denis's avatar Roland Denis
Browse files

Displaying date with hour when not midnight

And for single day events only
parent cffba3f1
......@@ -5,19 +5,26 @@ import datetime
from pelican import signals
from pelican.utils import get_date
def date_time(dt):
""" Format a date with time if not 00h00 """
s = dt.strftime('%d %B %Y')
if dt.hour != 0 or dt.minute != 0 or dt.second != 0:
s += ", %s" % dt.strftime("%-Hh%M")
return s
def date_interval(dt_interval):
"""Format a date interval of an event."""
(start_date, end_date) = dt_interval
if start_date == end_date:
return "Le %s" % start_date.strftime('%d %B %Y')
elif start_date.year == end_date.year and start_date.month == end_date.month:
return "Du %s au %s" % (start_date.strftime('%d'), end_date.strftime('%d %B %Y'))
elif start_date.year == end_date.year:
if start_date.year != end_date.year:
return "Du %s au %s" % (start_date.strftime('%d %B %Y'), end_date.strftime('%d %B %Y'))
elif start_date.month != end_date.month:
return "Du %s au %s" % (start_date.strftime('%d %B'), end_date.strftime('%d %B %Y'))
elif start_date.day != end_date.day:
return "Du %s au %s" % (start_date.strftime('%d'), end_date.strftime('%d %B %Y'))
else:
return "Du %s au %s" % (start_date.strftime('%d %B %Y'), end_date.strftime('%d %B %Y'))
return "Le %s" % date_time(start_date)
def highlighted_article(articles, config):
......@@ -96,6 +103,7 @@ def filter_by_date(articles, field_name, date = None):
def add_filter(pelican):
pelican.env.filters.update({
'date_time': date_time,
'date_interval': date_interval,
'highlighted_article': highlighted_article,
'previewed_articles': previewed_articles,
......
......@@ -29,10 +29,11 @@
</div>
<div class="card-body p-0 d-flex align-items-center">
{% if article.start_date is defined %}
<span class="pr-2 border-right">{{ article.start_date.strftime("%d %B %Y") }}</span>
{% set date = article.start_date %}
{% else %}
<span class="pr-2 border-right">{{ article.date.strftime("%d %B %Y") }}</span>
{% set date = article.date %}
{% endif %}
<span class="pr-2 border-right">{{ date | date_time }}</span>
<div class="mx-2 circle-{{article.category.slug}}"></div>
<span class="category text-uppercase"> {{CIRCLES[article.category.slug]}}</span>
</div>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment