Fix #281. Add mouse-over precise time and on-click switch listener.

This commit is contained in:
Justin Nuß 2014-07-24 22:31:59 +02:00
parent c20f5dc2ea
commit 835e85b5ce
4 changed files with 81 additions and 2 deletions

View file

@ -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