Last active
March 16, 2022 13:47
-
-
Save Londeren/5b8be44e073c6d6d9a5ac50abe77ba48 to your computer and use it in GitHub Desktop.
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
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