From 2fcd77f101003b65590f6ab103d0b633b219587b Mon Sep 17 00:00:00 2001 From: sqwishy Date: Mon, 24 Feb 2020 15:38:20 -0800 Subject: toLocal template function Hi. This adds a template function to convert a time to the local time zone. And modifies the default quoted_reply template to use it and show the time zone when formatting the timestamp of the quoted message. Previously, the quoted message timestamp was UTC and it would format it without the time zone. And I thought it might be a little confusing or weird to some normal people when I email them and I don't want normal people to be confused or think that I'm weird. --- lib/templates/template.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib') diff --git a/lib/templates/template.go b/lib/templates/template.go index f2765e8..9df594e 100644 --- a/lib/templates/template.go +++ b/lib/templates/template.go @@ -156,11 +156,16 @@ func cmd(cmd, text string) string { return out.String() } +func toLocal(t time.Time) time.Time { + return time.Time.In(t, time.Local) +} + var templateFuncs = template.FuncMap{ "quote": quote, "wrapText": wrapText, "wrap": wrap, "dateFormat": time.Time.Format, + "toLocal": toLocal, "exec": cmd, } -- cgit 1.4.1-2-gfad0