Created
December 11, 2017 03:42
-
-
Save gaoxiaoliangz/f86e1fdf470f69c66c5fb307e335edbe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function toTime(secs) { | |
const s = secs % 60 | |
const m = (secs - s) / 60 | |
return [(m - (m % 60)) / 60, m % 60, s] | |
} | |
function test() { | |
const tests = [8654, 0, 10, 600, 60, 987678987, 61] | |
tests.forEach(time => { | |
const result = toTime(time) | |
const result2 = result[0] * 60 * 60 + result[1] * 60 + result[2] | |
console.log(result) | |
console.log(result2 === time) | |
}) | |
} | |
test() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment