[chore] used codex to create a base layout for src
This commit is contained in:
17
src/shared/time/format.ts
Normal file
17
src/shared/time/format.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
type DurationLike = {
|
||||
secs?: number;
|
||||
nanos?: number;
|
||||
};
|
||||
|
||||
export function formatDuration(value: DurationLike): string {
|
||||
const totalSeconds = Math.max(0, Math.floor(value.secs ?? 0));
|
||||
const hours = Math.floor(totalSeconds / 3600)
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60)
|
||||
.toString()
|
||||
.padStart(2, "0");
|
||||
const seconds = (totalSeconds % 60).toString().padStart(2, "0");
|
||||
|
||||
return `${hours}:${minutes}:${seconds}`;
|
||||
}
|
||||
Reference in New Issue
Block a user