diff options
author | sqwishy <somebody@froghat.ca> | 2020-02-24 15:38:20 -0800 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2020-02-25 11:05:41 -0500 |
commit | 2fcd77f101003b65590f6ab103d0b633b219587b (patch) | |
tree | f64128ebc5e2dad493637fd832cba9ece32c2d48 | |
parent | 5dd0f454c197ccbce369ee88d47d5be8cd5e8265 (diff) | |
download | aerc-2fcd77f101003b65590f6ab103d0b633b219587b.tar.gz |
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.
-rw-r--r-- | lib/templates/template.go | 5 | ||||
-rw-r--r-- | templates/quoted_reply | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/templates/template.go b/lib/templates/template.go index f2765e87..9df594eb 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, } diff --git a/templates/quoted_reply b/templates/quoted_reply index f22c2f3b..64db1b5f 100644 --- a/templates/quoted_reply +++ b/templates/quoted_reply @@ -1,2 +1,2 @@ -On {{dateFormat .OriginalDate "Mon Jan 2, 2006 at 3:04 PM"}}, {{(index .OriginalFrom 0).Name}} wrote: +On {{dateFormat (.OriginalDate | toLocal) "Mon Jan 2, 2006 at 3:04 PM PST"}}, {{(index .OriginalFrom 0).Name}} wrote: {{wrapText .OriginalText 72 | quote }} |