From f6aec1b0f64b18a767b458286e0d6a5f6549a573 Mon Sep 17 00:00:00 2001 From: Lucas Declercq Date: Mon, 19 Mar 2018 10:32:12 +0100 Subject: 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 --- client/src/app/shared/video/video.model.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/src/app/shared/video/video.model.ts b/client/src/app/shared/video/video.model.ts index 8e46ce44b..50ca9eb99 100644 --- a/client/src/app/shared/video/video.model.ts +++ b/client/src/app/shared/video/video.model.ts @@ -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) { -- cgit v1.2.3