We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0ae0795 commit e16d7c3Copy full SHA for e16d7c3
1 file changed
src/utils/misc/formatter.ts
@@ -122,6 +122,21 @@ export namespace Formatter {
122
return number(unix / 86400, 1) + ' days'
123
}
124
125
+ export function duration(ms: number): string {
126
+ if (ms <= 0) return "0s"
127
+ const s = Math.floor(ms / 1000)
128
+ const d = Math.floor(s / 86400)
129
+ const h = Math.floor((s % 86400) / 3600)
130
+ const m = Math.floor((s % 3600) / 60)
131
+ const sec = s % 60
132
+ const parts: string[] = []
133
+ if (d) parts.push(`${d}d`)
134
+ if (h) parts.push(`${h}h`)
135
+ if (m) parts.push(`${m}m`)
136
+ if (sec || parts.length === 0) parts.push(`${sec}s`)
137
+ return parts.join(" ")
138
+ }
139
+
140
export function error(msg: string): string {
141
const regex = /user rejected action\s*\(action="([^"]+)"/i
142
const match = msg.match(regex)
0 commit comments