Phill Pover 72f3b9b111
All checks were successful
Music Collection CI Workflow / test (./backend) (push) Successful in 22s
Music Collection CI Workflow / test (./frontend) (push) Successful in 19s
Music Collection CI Workflow / build-and-push-images (./backend/Dockerfile, git.anatid.net/tabris/msuic-collection-backend, ./backend) (push) Successful in 49s
Music Collection CI Workflow / build-and-push-images (./frontend/Dockerfile, git.anatid.net/tabris/music-collection-frontend, ./frontend) (push) Successful in 1m12s
Music Collection CI Workflow / deploy (push) Successful in 21s
Adding time formatting
2025-04-03 11:41:00 +01:00

23 lines
549 B
TypeScript

export class TimeUtils {
// Copied from https://stackoverflow.com/a/11486026
static fancyTimeFormat(duration: number) {
// Hours, minutes and seconds
const hrs = ~~(duration / 3600);
const mins = ~~((duration % 3600) / 60);
const secs = ~~duration % 60;
// Output like "1:01" or "4:03:59" or "123:03:59"
let ret = "";
if (hrs > 0) {
ret += "" + hrs + ":" + (mins < 10 ? "0" : "");
}
ret += "" + mins + ":" + (secs < 10 ? "0" : "");
ret += "" + secs;
return ret;
}
}