Last active
December 7, 2018 11:00
-
-
Save ankedsgn/46eee9ddbef563fce5a5f988c6ccdce1 to your computer and use it in GitHub Desktop.
Check on date - output a pretty date
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# Checks start- and enddates and returns a pretty formatting. | |
# available formats: | |
# 14 jan 2019 (one day) | |
# 14 jan 2019 14:00 - 16:00 (one day but different end time) | |
# 14 jan 2019 - 18 jan 2019 (multiple day event) | |
#} | |
{% if item is not defined %} | |
{% set item = record %} | |
{% endif %} | |
{% if item.startdate|localedatetime("%G%b%e") == item.enddate|localedatetime("%G%b%e") %} {# one day event #} | |
{% if item.startdate|localedatetime("%k%M") == item.enddate|localedatetime("%k%M") %} | |
{# one day, same time #} | |
{{ item.startdate|localedatetime("%e %b %G") }} | |
{% else %} | |
{# one day, start and end time #} | |
{{ item.startdate|localedatetime("%e %b %G %k:%M") }} - {{ item.enddate|localedatetime("%k:%M") }} | |
{% endif %} | |
{% else %} | |
{# multiple day event, don't show time #} | |
{{ item.startdate|localedatetime("%e %b %G") }} - {{ item.enddate|localedatetime("%e %b %G") }} | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment