commit 243d273fada353c498aefd3deb1daea67689f182
parent 6d9857f6f7628eef70e1d0eeedcb13dd4a6c5b59
Author: Nat Welch <nat@natwelch.com>
Date: Wed, 12 Jan 2022 01:59:15 +0000
Add time html element
Diffstat:
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/html/thread.html b/html/thread.html
@@ -2,7 +2,7 @@
<h2>{{ .Data.Title }}</h2>
{{ range $index, $post := .Data.Posts }}
<div>
- <p><b>{{ $post.Author }}</b> &emdash; {{ $post.Publish | formatDateTime }}</p>
+ <p><b>{{ $post.Author }}</b> &emdash; <time datetime="{{ $post.Publish | formatDateTimeRFC3339 }}">{{ $post.Publish | formatDateTime }}</time></p>
{{ $post.Content }}
</div>
{{ end }}
diff --git a/server/server.go b/server/server.go
@@ -107,7 +107,10 @@ var (
templates = template.Must(template.ParseFiles(wrapViews()...))
templateFuncs = template.FuncMap{
"formatDateTime": func(dt time.Time) string {
- return t.Format(time.RFC3339)
+ return t.Format("2006-01-02 15:04:05")
+ },
+ "formatDateTimeRFC3339": func(dt time.Time) string {
+ return t.Format(time.RFC3339Nano)
},
"formatDate": func(dt time.Time) string {
return t.Format("2006-01-02")