feat: initial commit
This commit is contained in:
1 parent
353f62e257
commit
c6852c6f1b
62 files changed
+5911
-2
No files matched your search
@@ -0,0 +1,26 @@
|
||||
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))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user