From 221b6451fb4f8559a10e7fefebd13ce125ef29d0 Mon Sep 17 00:00:00 2001 From: Joris Date: Thu, 13 May 2021 14:50:51 +0200 Subject: Rewrite in TypeScript BuckleScript is no longer maintained. Choose a widely used techno that will still be maintained in the following years. --- src/duration.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/duration.ts (limited to 'src/duration.ts') diff --git a/src/duration.ts b/src/duration.ts new file mode 100644 index 0000000..92952a7 --- /dev/null +++ b/src/duration.ts @@ -0,0 +1,9 @@ +function prettyPrintNumber(n: number): string { + return n.toString().padStart(2, "0") +} + +export function prettyPrint(duration: number): string { + const minutes = Math.floor(duration / 60) + const seconds = duration % 60 + return prettyPrintNumber(minutes) + ":" + prettyPrintNumber(seconds) +} -- cgit v1.2.3