mirror of
https://gitcode.com/gitea/gitea.git
synced 2025-06-03 10:54:42 +08:00
Fix #281. Add mouse-over precise time and on-click switch listener.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user