1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

more centralised handling of refreshing

This commit is contained in:
Jesse Duffield
2020-03-27 19:12:15 +11:00
parent 39315ca1e2
commit 198d237679
32 changed files with 189 additions and 126 deletions

View File

@ -5,9 +5,9 @@ import (
"time"
)
func UnixToTimeAgo(timestamp int) string {
func UnixToTimeAgo(timestamp int64) string {
now := time.Now().Unix()
delta := float64(now - int64(timestamp))
delta := float64(now - timestamp)
// we go seconds, minutes, hours, days, weeks, months, years
conversions := []float64{60, 60, 24, 7, 4.34524, 12}
labels := []string{"s", "m", "h", "d", "w", "m", "y"}
@ -19,3 +19,7 @@ func UnixToTimeAgo(timestamp int) string {
}
return fmt.Sprintf("%dy", int(delta))
}
func UnixToDate(timestamp int64) string {
return time.Unix(timestamp, 0).Format(time.RFC822)
}