-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ceb5a6
commit 498b7f3
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
function formatMsToTime(i32) { | ||
let mins = Math.trunc(i32 / 60000); | ||
i32 %= 60000; | ||
let sec = Math.trunc(i32 / 1000); | ||
i32 %= 1000; | ||
let ret = `${mins.toString().padStart(2, "0")}:${sec.toString().padStart(2, "0")}.${Math.trunc(i32).toString().padStart(3, "0")}`; | ||
return ret; | ||
} | ||
|
||
function timeToMs(timeStr) { | ||
let split = timeStr.split("'"); | ||
let mins = parseInt(split[0]); | ||
let split2 = split[1].split("\""); | ||
let secs = parseInt(split2[0]); | ||
let ms = parseInt(split2[1]); | ||
return mins * 60000 + secs * 1000 + ms | ||
} | ||
|
||
function timeToMsColons(timeStr) { | ||
let split = timeStr.split(":"); | ||
let mins = parseInt(split[0]); | ||
let split2 = split[1].split("."); | ||
let secs = parseInt(split2[0]); | ||
let ms = parseInt(split2[1]); | ||
return mins * 60000 + secs * 1000 + ms | ||
} | ||
|
||
function sumTimesColon(timeArray) { | ||
return formatMsToTime(timeArray.reduce((a,b)=>a+timeToMsColons(b),0)); | ||
} | ||
|
||
function timeDiffColon(time1, time2) { | ||
return formatMsToTime(timeToMsColons(time2)-timeToMsColons(time1)); | ||
} |