Fix minor oscillation in timestamp
Fix a minor oscillation between then date and "now" in timestamp.
This commit is contained in:
parent
ee2720539d
commit
0385389252
|
@ -158,7 +158,7 @@ func handlerDevices(w http.ResponseWriter, r *http.Request) {
|
|||
|
||||
func timeDeltastr(now int64, tsmp int64) string {
|
||||
delta := now - tsmp
|
||||
if delta > 0 {
|
||||
if delta >= 0 {
|
||||
if delta < 10 {
|
||||
// Practically fresh
|
||||
return "now"
|
||||
|
@ -176,12 +176,13 @@ func timeDeltastr(now int64, tsmp int64) string {
|
|||
return "1 hour ago"
|
||||
} else if hours < 24 {
|
||||
return fmt.Sprintf("%d hours ago", hours)
|
||||
}
|
||||
days := hours / 24
|
||||
if days == 1 {
|
||||
return "yesterday"
|
||||
} else if days < 7 {
|
||||
return fmt.Sprintf("%d days ago", days)
|
||||
} else {
|
||||
days := hours / 24
|
||||
if days == 1 {
|
||||
return "yesterday"
|
||||
} else if days < 7 {
|
||||
return fmt.Sprintf("%d days ago", days)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue