MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / formatUptime

Function formatUptime

internal/cli/cli_helpers.go:315–335  ·  view source on GitHub ↗

formatUptime formats seconds into a human-readable duration string.

(seconds int64)

Source from the content-addressed store, hash-verified

313
314// formatUptime formats seconds into a human-readable duration string.
315func formatUptime(seconds int64) string {
316 if seconds <= 0 {
317 return "0s"
318 }
319
320 d := seconds / 86400
321 h := (seconds % 86400) / 3600
322 m := (seconds % 3600) / 60
323 s := seconds % 60
324
325 switch {
326 case d > 0:
327 return fmt.Sprintf("%dd%dh%dm", d, h, m)
328 case h > 0:
329 return fmt.Sprintf("%dh%dm", h, m)
330 case m > 0:
331 return fmt.Sprintf("%dm%ds", m, s)
332 default:
333 return fmt.Sprintf("%ds", s)
334 }
335}
336
337// findNodeIP returns the IP address of the named node.
338func (s *cliSession) findNodeIP(ctx context.Context, nodeName string) (string, error) {

Callers 3

TestFormatUptimeFunction · 0.85
runNodesListFunction · 0.85
runNodesShowFunction · 0.85

Calls

no outgoing calls

Tested by 1

TestFormatUptimeFunction · 0.68