♻️ refactor: format date as "6 July 2049"
Follows Oxford's and other formal style manuals.main
parent
7195734d59
commit
4b18391c18
@ -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 %}
|
Loading…
Reference in New Issue