| 1 |
const formatDuration = ( seconds ) => { |
| 2 |
let d; |
| 3 |
|
| 4 |
const dayInSeconds = 3600 * 24; |
| 5 |
|
| 6 |
if ( seconds > dayInSeconds ) { |
| 7 |
d = ( seconds - ( seconds % dayInSeconds ) ) / dayInSeconds; |
| 8 |
seconds = seconds % dayInSeconds; |
| 9 |
} else if ( seconds == dayInSeconds ) { |
| 10 |
return '24:00'; |
| 11 |
} |
| 12 |
|
| 13 |
const x = ( new Date( seconds * 1000 ).toUTCString() ).match( /\d{2}:\d{2}:\d{2}/ )[ 0 ].split( ':' ); |
| 14 |
|
| 15 |
if ( d ) { |
| 16 |
x[ 0 ] = parseInt( x[ 0 ] ) + ( d * 24 ); |
| 17 |
} |
| 18 |
|
| 19 |
const html = x.join( ':' ); |
| 20 |
|
| 21 |
return html; |
| 22 |
}; |
| 23 |
|
| 24 |
export default formatDuration; |
| 25 |
|