Add a prettier runtime string for movies
This commit is contained in:
parent
20ca2adefc
commit
eae4598c88
@ -47,14 +47,22 @@ ListDetails.propTypes = {
|
||||
export default ListDetails;
|
||||
|
||||
const Runtime = (props) => {
|
||||
if (props.runtime === undefined) {
|
||||
if (props.runtime === undefined || props.runtime === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const hours = Math.floor(props.runtime / 60);
|
||||
const minutes = (props.runtime % 60);
|
||||
|
||||
let duration = "";
|
||||
if (hours > 0) { duration += hours + "h" }
|
||||
if (minutes > 0) { duration += ("0" + minutes).slice(-2) }
|
||||
if (hours === 0) { duration += " min" }
|
||||
|
||||
return (
|
||||
<p>
|
||||
<i className="fa fa-clock-o"></i>
|
||||
{props.runtime} min
|
||||
{duration}
|
||||
</p>
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user