From 835e85b5ce9921ffd4d50b90b706e02685167331 Mon Sep 17 00:00:00 2001 From: Justin Nuß Date: Thu, 24 Jul 2014 22:31:59 +0200 Subject: Fix #281. Add mouse-over precise time and on-click switch listener. --- modules/base/tool.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'modules/base') diff --git a/modules/base/tool.go b/modules/base/tool.go index 9635f13e..f2a4059a 100644 --- a/modules/base/tool.go +++ b/modules/base/tool.go @@ -12,6 +12,7 @@ import ( "encoding/hex" "fmt" "hash" + "html/template" "math" "strconv" "strings" @@ -239,8 +240,8 @@ func TimeSincePro(then time.Time) string { return strings.TrimPrefix(timeStr, ", ") } -// TimeSince calculates the time interval and generate user-friendly string. -func TimeSince(then time.Time) string { +// timeSince calculates the time interval and generate user-friendly string. +func timeSince(then time.Time) string { now := time.Now() lbl := "ago" @@ -290,6 +291,11 @@ func TimeSince(then time.Time) string { } } +// TimeSince calculates the time interval and generate user-friendly string. +func TimeSince(t time.Time) template.HTML { + return template.HTML(fmt.Sprintf(`%s`, t.Format(setting.TimeFormat), timeSince(t))) +} + const ( Byte = 1 KByte = Byte * 1024 -- cgit v1.2.3