Files
2026-10-13 00:25:29 +03:00

27 lines
609 B
Go

package server
import (
"fmt"
"time"
)
// humanSince renders a coarse "time ago" label for the dashboard.
func humanSince(t time.Time) string {
if t.IsZero() {
return "никогда"
}
d := time.Since(t)
switch {
case d < 10*time.Second:
return "только что"
case d < time.Minute:
return fmt.Sprintf("%d сек назад", int(d.Seconds()))
case d < time.Hour:
return fmt.Sprintf("%d мин назад", int(d.Minutes()))
case d < 24*time.Hour:
return fmt.Sprintf("%d ч назад", int(d.Hours()))
default:
return fmt.Sprintf("%d дн назад", int(d.Hours()/24))
}
}