This partial evaluates the values start
and end
in the front matter and displays it this way:
1. Februar 2020
24. März 2021 17:00 – 19:00
24. August 2021 – 25. August 2021
21. Mai 2021 10:00 – 22. Mai 2021 11:00
The time 00:00:00 is not displayed. So it is possible to output dates without time.
Partial: date_range.html
{{ $month_names := slice "Januar" "Februar" "März" "April" "Mai" "Juni" "Juli" "August" "September" "Oktober" "November" "Dezember" }}
{{ $start := .Params.Start }}
{{ $end := .Params.End }}
{{ $month := dateFormat "1" $start }}
{{ dateFormat "2" $start }}. {{ index $month_names ( sub ( int $month ) 1 ) }} {{ dateFormat "2006" $start }}
{{ if int ( dateFormat "1504" $end ) }} {{ dateFormat "15:04" $start }}{{ end }}
{{ $diff_days := sub ( int ( dateFormat "200612" $end ) ) ( int ( dateFormat "200612" $start ) ) }}
{{ if $end }}
{{ $month := dateFormat "1" $end }}
–
{{ if $diff_days }}{{ dateFormat "2" $end }}. {{ index $month_names ( sub ( int $month ) 1 ) }} {{ dateFormat "2006" $end }}{{ end }}
{{ if int ( dateFormat "1504" $end ) }} {{ dateFormat "15:04" $end }}{{ end }}
{{ end }}
(based on date.html)