feat(gallery): add historical date parsing

feat: add logo file
This commit is contained in:
Matthieu Bessat 2022-09-29 17:24:11 +02:00
parent b5785c8218
commit bb43b2bc9d
9 changed files with 124 additions and 18 deletions

View file

@ -0,0 +1,36 @@
{{ $formattedDate := "" }}
{{ $rawDate := . }}
{{- $date := "1800-01-01" -}}
{{- $datePrecision := "day" -}}
{{ if reflect.IsMap $rawDate }}
{{ partial "FormatHistoricalDate" ($rawDate.from) }}
-
{{ partial "FormatHistoricalDate" ($rawDate.to) }}
{{ else }}
{{ $rawDate = string $rawDate }}
{{ if eq (len $rawDate) 4 }}
{{ $datePrecision = "year" }}
{{ $date = printf "%s-01-01" $rawDate }}
{{ end }}
{{ if eq (len $rawDate) 7 }}
{{ $datePrecision = "month" }}
{{ $date = printf "%s-01" $rawDate }}
{{ end }}
{{ if eq (len $rawDate) 10 }}
{{ $datePrecision = "day" }}
{{ $date = $rawDate }}
{{ end }}
{{- if eq $datePrecision "year" -}}
{{ $formattedDate = ($date | time.Format "2006") }}
{{- end -}}
{{- if eq $datePrecision "month" -}}
{{ $formattedDate = ($date | time.Format "January 2006") }}
{{- end -}}
{{- if eq $datePrecision "day" -}}
{{ $formattedDate = ($date | time.Format "2 January 2006") }}
{{- end -}}
{{ end }}
{{ printf "%s" $formattedDate }}