diff options
author | Justin Nuß <nuss.justin@gmail.com> | 2014-07-24 22:31:59 +0200 |
---|---|---|
committer | Justin Nuß <nuss.justin@gmail.com> | 2014-07-24 22:31:59 +0200 |
commit | 835e85b5ce9921ffd4d50b90b706e02685167331 (patch) | |
tree | 0edaa72fd600cfa9ef0ec73cc6786922eaf87e15 /modules/base | |
parent | c20f5dc2ea1b27e80c28e00831278c7451ba6cce (diff) | |
download | gitea-835e85b5ce9921ffd4d50b90b706e02685167331.tar.gz gitea-835e85b5ce9921ffd4d50b90b706e02685167331.zip |
Fix #281. Add mouse-over precise time and on-click switch listener.
Diffstat (limited to 'modules/base')
-rw-r--r-- | modules/base/tool.go | 10 |
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 |