Skip to content

Commit

Permalink
Pad human-readable times with zeros
Browse files Browse the repository at this point in the history
  • Loading branch information
bananu7 committed Apr 2, 2024
1 parent 9ff6c66 commit 0ca91b8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/zoom/formatProjectTime.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import { ProjectTimeSeconds } from './zoom_l12'

function padWithZero(n) {

Check failure on line 3 in src/zoom/formatProjectTime.ts

View workflow job for this annotation

GitHub Actions / tsc

Parameter 'n' implicitly has an 'any' type.
if (n < 10) {
return `0${n}`;
} else {
return `${n}`;
}
}

export function formatProjectTime(time: ProjectTimeSeconds) {
const hours = Math.floor(time / 3600);
time -= hours * 3600;
const minutes = Math.floor(time / 60);
time -= minutes * 60;
return `${hours}:${minutes}:${Math.floor(time)}`;
return `${padWithZero(hours)}:${padWithZero(minutes)}:${padWithZero(Math.floor(time))}`;
}

0 comments on commit 0ca91b8

Please sign in to comment.