From 198d237679bcc19655138f76a11770c3ef91ec4f Mon Sep 17 00:00:00 2001 From: Jesse Duffield Date: Fri, 27 Mar 2020 19:12:15 +1100 Subject: more centralised handling of refreshing --- pkg/utils/date.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pkg/utils/date.go') diff --git a/pkg/utils/date.go b/pkg/utils/date.go index 7f8f8f8a5..40165ecaa 100644 --- a/pkg/utils/date.go +++ b/pkg/utils/date.go @@ -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) +} -- cgit v1.2.3