File size: 594 Bytes
f5071ca
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import React from 'react'

const convertTimeToHourMinuteFormat = timeInHours => {
    var hours = Math.trunc(timeInHours / 60);
    var minutes = timeInHours % 60;
    return `${hours}h ${minutes}m`
}

export const getSeasonsOrMovieLength = (seasons, runtime) => {
    let timeSpan
    if (runtime) {
        timeSpan = <span>{convertTimeToHourMinuteFormat(runtime)}</span>
    } else if (seasons) {
        timeSpan = (
            <span>
                {seasons.length > 1 ? `${seasons.length} Seasons` : `${seasons.length} Season`}
            </span>
        )
    }

    return timeSpan
}