Last active
April 18, 2016 18:02
-
-
Save bitdivine/7d6df41fb4eac20379d824068cd6a7bd to your computer and use it in GitHub Desktop.
Format time intervals as HH:MM:SS
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 formatTimeInterval(seconds){ | |
| seconds = Number(seconds); | |
| return [60,60,Infinity].map((max) => { var part = seconds % max; seconds -= part; seconds /= max; return part; }).reverse().map((n)=>('00'+n).replace(/^0*([0-9][0-9])/,(m,g1)=>g1).replace(/([.]...).*/,(m,g)=>g)).join(':'); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment