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.
This commit is contained in:
parent
5dd0f454c1
commit
2fcd77f101
2 changed files with 6 additions and 1 deletions
|
@ -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,
|
||||
}
|
||||
|
||||
|
|
|
@ -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 }}
|
||||
|
|
Loading…
Reference in a new issue