use time.Format to format dates. It allows dates to be localized.

This commit is contained in:
Charles Brunet 2022-04-09 20:56:23 -04:00
parent cfee1e3cd1
commit 6e162a32ae
3 changed files with 3 additions and 3 deletions

View File

@ -287,7 +287,7 @@ Dates of blog posts and single pages are rendered with the default date format c
date_format = "2. January 2006"
```
See hugo's documentation of the [`dateFormat` function](https://gohugo.io/functions/dateformat/) for more details.
See hugo's documentation of the [`time.Format` function](https://gohugo.io/functions/dateformat/) for more details.
### Nearly finished

View File

@ -32,7 +32,7 @@
{{/* Hugo uses Go's date formatting is set by example. Here are two formats */}}
{{ if not .Date.IsZero }}
<time class="f6 mv4 dib tracked" {{ printf `datetime="%s"` (.Date.Format "2006-01-02T15:04:05Z07:00") | safeHTMLAttr }}>
{{- .Date.Format (default "January 2, 2006" .Site.Params.date_format) -}}
{{- .Date | time.Format (default ":date_full" .Site.Params.date_format) -}}
</time>
{{end}}

View File

@ -1,7 +1,7 @@
<div class="mb3 pa4 {{ $.Param "text_color" | default "mid-gray" }} overflow-hidden">
{{ if .Date }}
<div class="f6">
{{ .Date.Format (default "January 2, 2006" .Site.Params.date_format) }}
{{ .Date | time.Format (default ":date_full" .Site.Params.date_format) }}
</div>
{{ end }}
<h1 class="f3 near-black">