]> git.r.bdr.sh - rbdr/mobius/blob - hotline/stats.go
Move code to hotline dir
[rbdr/mobius] / hotline / stats.go
1 package hotline
2
3 import (
4 "fmt"
5 "time"
6 )
7
8 type Stats struct {
9 LoginCount int `yaml:"login count"`
10 StartTime time.Time `yaml:"start time"`
11 Uptime time.Duration `yaml:"uptime"`
12 }
13
14 func (s *Stats) String() string {
15 template := `
16 Server Stats:
17 Start Time: %v
18 Uptime: %s
19 Login Count: %v
20 `
21 d := time.Since(s.StartTime)
22 d = d.Round(time.Minute)
23 h := d / time.Hour
24 d -= h * time.Hour
25 m := d / time.Minute
26
27 return fmt.Sprintf(
28 template,
29 s.StartTime.Format(time.RFC1123Z),
30 fmt.Sprintf("%02d:%02d", h, m),
31 s.LoginCount,
32 )
33 }