diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-27 19:12:15 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2020-03-28 11:59:45 +1100 |
commit | 198d237679bcc19655138f76a11770c3ef91ec4f (patch) | |
tree | ecc09e91f96baeaf75d437f5fbd00e007d4c6472 /pkg/utils | |
parent | 39315ca1e2f526911ea35d9848b0427093e4080a (diff) |
more centralised handling of refreshing
Diffstat (limited to 'pkg/utils')
-rw-r--r-- | pkg/utils/date.go | 8 |
1 files changed, 6 insertions, 2 deletions
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) +} |