From 52e1bbaa70b41be5fda404f0d1f4110c9432e51e Mon Sep 17 00:00:00 2001 From: tamsin johnson Date: Tue, 13 Feb 2024 11:59:38 -0800 Subject: [PATCH] lets-go:14.1 passing tests --- snippetbox/cmd/web/templates.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/snippetbox/cmd/web/templates.go b/snippetbox/cmd/web/templates.go index 516124e..eb56819 100644 --- a/snippetbox/cmd/web/templates.go +++ b/snippetbox/cmd/web/templates.go @@ -22,7 +22,11 @@ type templateData struct { // humanDate ... func humanDate(t time.Time) string { - return t.Format("02 Jan 2006 at 15:04") + if t.IsZero() { + return "" + } + + return t.UTC().Format("02 Jan 2006 at 15:04") } var functions = template.FuncMap{