Created
October 27, 2016 13:28
-
-
Save davidsharp/be896506913c88897cb10f510e204a3f to your computer and use it in GitHub Desktop.
timecode->seconds && seconds->timecode (M+:SS.D+)
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
// Tic.js timecode->seconds->timecode functions | |
const Tic={ | |
toSeconds: | |
tc => ( | |
( parseInt(tc.split(':')[0]) * 60 ) | |
+ ( parseFloat(tc.split(':')[1]) ) | |
), | |
toTimecode: | |
sec => ( | |
`${ Math.floor(sec/60) }:${ ((sec%60)<10?'0':'') + (sec%60).toFixed(((sec+'').split('.')[1]||[]).length) }` | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment