Skip to content

Instantly share code, notes, and snippets.

@Londeren
Last active March 16, 2022 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Londeren/5b8be44e073c6d6d9a5ac50abe77ba48 to your computer and use it in GitHub Desktop.
Save Londeren/5b8be44e073c6d6d9a5ac50abe77ba48 to your computer and use it in GitHub Desktop.
const times = {
'Video 0': '00:39:13',
'Video 1': '00:29:03',
'Video 2': '00:24:02',
'Video 3': '00:31:55',
'Video 4': '00:32:26',
'Video 5': '00:42:29',
'Video 6': '00:49:11',
};
function timeToSeconds(time) {
const [hours, minutes, seconds] = time.split(':');
return 3600 * hours + 60 * minutes + +seconds;
}
function secondsToTime(seconds) {
return new Date(seconds * 1000).toISOString().substr(11, 8);
}
Object.entries(times).reduce((fromTheBeginning, [name, time], index) => {
const seconds = timeToSeconds(time);
if (seconds > 180) {
console.log(`${secondsToTime(fromTheBeginning)} ${name}`);
}
return fromTheBeginning + seconds;
}, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment