summaryrefslogtreecommitdiffstats
path: root/modules/base
diff options
context:
space:
mode:
author无闻 <joe2010xtmf@163.com>2014-08-01 00:15:06 -0400
committer无闻 <joe2010xtmf@163.com>2014-08-01 00:15:06 -0400
commit568c9b353ec1e18fceef4bd8e9897adf115c295d (patch)
tree8190c6902e200aea1eae5c51eaf2fd9fed2e9243 /modules/base
parentdabf5b057c358655d8635ed6ec8666660abeb92b (diff)
parent91480f3791f266369c343c539f8eeec245fa969a (diff)
downloadgitea-568c9b353ec1e18fceef4bd8e9897adf115c295d.tar.gz
gitea-568c9b353ec1e18fceef4bd8e9897adf115c295d.zip
Merge pull request #311 from nuss-justin/issue/281
Fix #281. Add mouse-over precise time and on-click switch listener.
Diffstat (limited to 'modules/base')
-rw-r--r--modules/base/tool.go9
1 files changed, 7 insertions, 2 deletions
diff --git a/modules/base/tool.go b/modules/base/tool.go
index a2a155d61f..eb0ac9e5bf 100644
--- a/modules/base/tool.go
+++ b/modules/base/tool.go
@@ -12,6 +12,7 @@ import (
"encoding/hex"
"fmt"
"hash"
+ "html/template"
"math"
"strings"
"time"
@@ -241,8 +242,7 @@ 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, lang string) string {
+func timeSince(then time.Time, lang string) string {
now := time.Now()
lbl := i18n.Tr(lang, "tool.ago")
@@ -292,6 +292,11 @@ func TimeSince(then time.Time, lang string) string {
}
}
+// TimeSince calculates the time interval and generate user-friendly string.
+func TimeSince(t time.Time, lang string) template.HTML {
+ return template.HTML(fmt.Sprintf(`<span class="time-since" title="%s">%s</span>`, t.Format(setting.TimeFormat), timeSince(t, lang)))
+}
+
const (
Byte = 1
KByte = Byte * 1024