From: Lucas Declercq Date: Mon, 19 Mar 2018 09:32:12 +0000 (+0100) Subject: Update video duration string to show hours when duration greater than or equal 60min... X-Git-Tag: v1.0.0-alpha.9~10 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f6aec1b0f64b18a767b458286e0d6a5f6549a573;p=oweals%2Fpeertube.git 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 --- 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) {