Update video duration string to show hours when duration greater than or equal 60min (#360)

* Update video duration string to show hours when >= 60min

* Only show hours in duration when relevant

* Fix problem with ternary expression

* Remove accidentally commited package-lock.json
This commit is contained in:
Lucas Declercq 2018-03-19 10:32:12 +01:00 committed by Chocobozzz
parent 2db6f2b0c1
commit f6aec1b0f6
1 changed files with 6 additions and 2 deletions

View File

@ -42,12 +42,16 @@ export class Video implements VideoServerModel {
}
private static createDurationString (duration: number) {
const minutes = Math.floor(duration / 60)
const hours = Math.floor(duration / 3600)
const minutes = Math.floor(duration % 3600 / 60)
const seconds = duration % 60
const minutesPadding = minutes >= 10 ? '' : '0'
const secondsPadding = seconds >= 10 ? '' : '0'
const displayedHours = hours > 0 ? hours.toString() + ':' : ''
return minutesPadding + minutes.toString() + ':' + secondsPadding + seconds.toString()
return displayedHours + minutesPadding +
minutes.toString() + ':' + secondsPadding + seconds.toString()
}
constructor (hash: VideoServerModel) {