MCPcopy Index your code
hub / github.com/cameri/nostream / formatUptime

Function formatUptime

src/cli/commands/info.ts:86–108  ·  view source on GitHub ↗
(uptimeSeconds: number | null)

Source from the content-addressed store, hash-verified

84}
85
86const formatUptime = (uptimeSeconds: number | null): string => {
87 if (uptimeSeconds === null) {
88 return 'unavailable'
89 }
90
91 const days = Math.floor(uptimeSeconds / 86400)
92 const hours = Math.floor((uptimeSeconds % 86400) / 3600)
93 const minutes = Math.floor((uptimeSeconds % 3600) / 60)
94 const seconds = uptimeSeconds % 60
95
96 const segments = []
97 if (days > 0) {
98 segments.push(`${days}d`)
99 }
100 if (hours > 0 || days > 0) {
101 segments.push(`${hours}h`)
102 }
103 if (minutes > 0 || hours > 0 || days > 0) {
104 segments.push(`${minutes}m`)
105 }
106 segments.push(`${seconds}s`)
107 return segments.join(' ')
108}
109
110const writeJson = (value: unknown): void => {
111 process.stdout.write(`${JSON.stringify(value, null, 2)}\n`)

Callers 1

runInfoFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected