summaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/tool.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index 9635f13e0f..f2a4059a6c 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(`<span class="time-since" title="%s">%s</span>`, t.Format(setting.TimeFormat), timeSince(t)))
+}
+
const (
Byte = 1
KByte = Byte * 1024