(cherry picked from commit 3f0e8ce8634b085d49638d11df96109797ac9cef) Closes #9129pull/9175/head
parent
4a41c67dfe
commit
c2df194d49
@ -1,15 +0,0 @@
|
|||||||
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;
|
|
@ -0,0 +1,27 @@
|
|||||||
|
import translate from 'Utilities/String/translate';
|
||||||
|
|
||||||
|
function formatRuntime(runtime: number, format = 'hoursMinutes') {
|
||||||
|
if (!runtime) {
|
||||||
|
return format === 'hoursMinutes' ? '0m' : '0 mins';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (format === 'minutes') {
|
||||||
|
return `${runtime} mins`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hours = Math.floor(runtime / 60);
|
||||||
|
const minutes = runtime % 60;
|
||||||
|
const result = [];
|
||||||
|
|
||||||
|
if (hours) {
|
||||||
|
result.push(translate('FormatRuntimeHours', { hours }));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (minutes) {
|
||||||
|
result.push(translate('FormatRuntimeMinutes', { minutes }));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.join(' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
export default formatRuntime;
|
Loading…
Reference in new issue