♻️ refactor: format date as "6 July 2049"

Follows Oxford's and other formal style manuals.
This commit is contained in:
welpo
2023-03-06 00:07:41 +01:00
parent 7195734d59
commit 4b18391c18
6 changed files with 5 additions and 30 deletions

View File

@@ -21,7 +21,7 @@
<div class="meta">
{%- if page.date %}
{{ macros_format_date::format_date(date=page.date) }}
{{ page.date | date(format=config.extra.date_format | default (value="%d %B %Y")) }}
{% endif -%}
{% if page.draft %}
<span class="draft-label">DRAFT</span>

View File

@@ -13,7 +13,7 @@
{% endif %}
{% if page.date %}
<span>{{ macros_format_date::format_date(date=page.date) }}</span>
<span>{{ page.date | date(format=config.extra.date_format | default (value="%d %B %Y")) }}</span>
{{ separator }}
{% endif %}
@@ -30,7 +30,7 @@
{% endif %}
{% if page.updated %}
<br><span>Last updated on {{ macros_format_date::format_date(date=page.updated) }}</span>
<br><span>Last updated on {{ page.updated | date(format=config.extra.date_format | default (value="%d %B %Y")) }}</span>
{% endif %}
</ul>

View File

@@ -1,22 +0,0 @@
{% macro format_date(date) %}
{% if config.extra.date_format %}
{{ date | date(format=config.extra.date_format) }}
{% else %}
{% set day = date | date(format='%-d') | int %}
{% if day in [11, 12, 13] %}
{% set suffix = "th" %}
{% else %}
{% set last_digit = day % 10 %}
{% if last_digit == 1 %}
{% set suffix = "st" %}
{% elif last_digit == 2 %}
{% set suffix = "nd" %}
{% elif last_digit == 3 %}
{% set suffix = "rd" %}
{% else %}
{% set suffix = "th" %}
{% endif %}
{% endif %}
{{ date | date(format="%-d") }}{{ suffix }} {{ date | date(format="%B %Y") }}
{% endif %}
{% endmacro %}

View File

@@ -13,7 +13,7 @@
{% if post.date %}
<div class="date">
{{ macros_format_date::format_date(date=post.date) }}
{{ post.date | date(format=config.extra.date_format | default (value="%d %B %Y")) }}
</div>
{% endif %}