mirror of
https://github.com/sst/opencode.git
synced 2025-09-01 18:57:24 +00:00
docs: share page add time footer back
This commit is contained in:
parent
9ca54020ac
commit
2f1acee5a1
4 changed files with 128 additions and 86 deletions
|
@ -58,3 +58,20 @@ export function createOverflow() {
|
|||
},
|
||||
}
|
||||
}
|
||||
|
||||
export function formatDuration(ms: number): string {
|
||||
const ONE_SECOND = 1000
|
||||
const ONE_MINUTE = 60 * ONE_SECOND
|
||||
|
||||
if (ms >= ONE_MINUTE) {
|
||||
const minutes = Math.floor(ms / ONE_MINUTE)
|
||||
return minutes === 1 ? `1min` : `${minutes}mins`
|
||||
}
|
||||
|
||||
if (ms >= ONE_SECOND) {
|
||||
const seconds = Math.floor(ms / ONE_SECOND)
|
||||
return `${seconds}s`
|
||||
}
|
||||
|
||||
return `${ms}ms`
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue