You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
408 B
16 lines
408 B
function formatRuntime(minutes, format) {
|
|
if (!minutes) {
|
|
return (format === 'hoursMinutes') ? '0m' : '0 mins';
|
|
}
|
|
|
|
if (format === 'minutes') {
|
|
return `${minutes} mins`;
|
|
}
|
|
|
|
const movieHours = Math.floor(minutes / 60);
|
|
const movieMinutes = (minutes <= 59) ? minutes : minutes % 60;
|
|
return `${((movieHours > 0) ? `${movieHours}h ` : '') + movieMinutes}m`;
|
|
}
|
|
|
|
export default formatRuntime;
|