Skip to content

Instantly share code, notes, and snippets.

@davidsharp
Created October 27, 2016 13:28
Show Gist options
  • Save davidsharp/be896506913c88897cb10f510e204a3f to your computer and use it in GitHub Desktop.
Save davidsharp/be896506913c88897cb10f510e204a3f to your computer and use it in GitHub Desktop.
timecode->seconds && seconds->timecode (M+:SS.D+)
// 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