Created
August 20, 2021 08:05
-
-
Save bacor/ac6a6c92ed5204a13ed3fe452d1a611d to your computer and use it in GitHub Desktop.
Jekyll/Liquid output a period/range
This file contains 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
{%- assign start = include.start %} | |
{%- assign end = include.end %} | |
{%- assign startMonth = start | date: '%b' %} | |
{%- assign endMonth = end | date: '%b' %} | |
{%- assign sameMonthStartFmt = include.same_month_start_fmt | default: '%d' -%} | |
{%- assign sameMonthEndFmt = include.same_month_end_fmt | default: "%d %b '%y" -%} | |
{%- if startMonth == endMonth -%} | |
<time datetime="{{ start | date: '%Y-%m-%d' }}"> | |
{{- start | date: sameMonthStartFmt -}} | |
</time>–<time datetime="{{ end | date: '%Y-%m-%d' }}"> | |
{{- end | date: sameMonthEndFmt -}} | |
</time> | |
{%- else -%} | |
<time datetime="{{ start | date: '%Y-%m-%d' }}"> | |
{{- start | date: '%d %b' -}} | |
</time>–{{--}} | |
<time datetime="{{ end | date: '%Y-%m-%d' }}"> | |
{{- end | date: '%d %b %Y' -}} | |
</time> | |
{%- endif -%} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment