Created
April 9, 2021 01:14
-
-
Save jsdev/17d6e0abdc1ca1cdd8fdbb6a545a7d0b to your computer and use it in GitHub Desktop.
formatDuration method
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
// constraints: video 24 hours or less | |
export default duration => { | |
const afterHours = duration % 3600; | |
const hours = Math.floor(duration / 3600); | |
const minutes = Math.floor(afterHours / 60); | |
const seconds = Math.ceil(afterHours % 60); | |
return [hours, minutes, seconds] | |
.filter(o => o) | |
.map(o => o > 9 ? o : '0' + o).join(':'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment