From 95ae28aa0fbca0c32bd67b74b09009802dd29307 Mon Sep 17 00:00:00 2001 From: Chris Sexton <3216719+chrissexton@users.noreply.github.com> Date: Wed, 28 Feb 2024 17:05:23 -0500 Subject: [PATCH] web: format time string --- bot/stats/stats.go | 4 ++-- bot/web/index.templ | 2 +- bot/web/index_templ.go | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/bot/stats/stats.go b/bot/stats/stats.go index 3ca919a..61a27eb 100644 --- a/bot/stats/stats.go +++ b/bot/stats/stats.go @@ -14,6 +14,6 @@ func New() *Stats { return &Stats{startTime: time.Now()} } -func (s Stats) Uptime() time.Duration { - return time.Now().Sub(s.startTime) +func (s Stats) Uptime() string { + return time.Now().Sub(s.startTime).Truncate(time.Second).String() } diff --git a/bot/web/index.templ b/bot/web/index.templ index f6d6a29..cc555a2 100644 --- a/bot/web/index.templ +++ b/bot/web/index.templ @@ -76,7 +76,7 @@ templ (w *Web) showStats() { Uptime - { fmt.Sprintf("%v", w.stats.Uptime()) } + { w.stats.Uptime() } diff --git a/bot/web/index_templ.go b/bot/web/index_templ.go index e7b3aee..179095e 100644 --- a/bot/web/index_templ.go +++ b/bot/web/index_templ.go @@ -314,9 +314,9 @@ func (w *Web) showStats() templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var16 string - templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%v", w.stats.Uptime())) + templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(w.stats.Uptime()) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 78, Col: 53} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `bot/web/index.templ`, Line: 78, Col: 34} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil {