From f8ee6214bf114b2b8ebc55b2c2bc8c702ac847cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nikola=20Forr=C3=B3?= Date: Sun, 24 Jun 2018 16:25:59 +0200 Subject: [PATCH] Make offsets more human readable --- apps/twitch-logs/src/app/comments/comments.component.html | 4 ++-- apps/twitch-logs/src/app/pipes/tohms.pipe.ts | 8 +++++++- apps/twitch-logs/src/app/videos/videos.component.html | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/twitch-logs/src/app/comments/comments.component.html b/apps/twitch-logs/src/app/comments/comments.component.html index fc2ab8c..5a37dd5 100644 --- a/apps/twitch-logs/src/app/comments/comments.component.html +++ b/apps/twitch-logs/src/app/comments/comments.component.html @@ -29,9 +29,9 @@ - + - {{comment.offset | tohms}} + {{comment.offset | tohms : 'colons'}} diff --git a/apps/twitch-logs/src/app/pipes/tohms.pipe.ts b/apps/twitch-logs/src/app/pipes/tohms.pipe.ts index 72ac944..bf50c8f 100644 --- a/apps/twitch-logs/src/app/pipes/tohms.pipe.ts +++ b/apps/twitch-logs/src/app/pipes/tohms.pipe.ts @@ -9,7 +9,7 @@ import { }) export class ToHMSPipe implements PipeTransform { - transform(offset: number): string { + transform(offset: number, format: string): string { let secs = offset >> 0; let seconds = secs % 60; let mins = (secs - seconds) / 60 >> 0; @@ -20,6 +20,12 @@ export class ToHMSPipe implements PipeTransform { let m = minutes.toString().padStart(2, '0'); let h = hours.toString().padStart(2, '0'); + if (format == 'colons') { + return `${h}:${m}:${s}`; + } else if (format == 'spaces') { + return `${h}h ${m}m ${s}s`; + } + return `${h}h${m}m${s}s`; } } diff --git a/apps/twitch-logs/src/app/videos/videos.component.html b/apps/twitch-logs/src/app/videos/videos.component.html index 171c940..d2878b1 100644 --- a/apps/twitch-logs/src/app/videos/videos.component.html +++ b/apps/twitch-logs/src/app/videos/videos.component.html @@ -59,7 +59,7 @@ Length - {{video.length | tohms}} + {{video.length | tohms : 'spaces'}}