diff options
Diffstat (limited to 'webapp/src/app/@theme/pipes/timing.pipe.ts')
-rw-r--r-- | webapp/src/app/@theme/pipes/timing.pipe.ts | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/webapp/src/app/@theme/pipes/timing.pipe.ts b/webapp/src/app/@theme/pipes/timing.pipe.ts new file mode 100644 index 0000000..afc9056 --- /dev/null +++ b/webapp/src/app/@theme/pipes/timing.pipe.ts @@ -0,0 +1,18 @@ +import { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ name: 'timing' }) +export class TimingPipe implements PipeTransform { + transform(time: number): string { + if (time) { + const minutes = Math.floor(time / 60); + const seconds = Math.floor(time % 60); + return `${this.initZero(minutes)}${minutes}:${this.initZero(seconds)}${seconds}`; + } + + return '00:00'; + } + + private initZero(time: number): string { + return time < 10 ? '0' : ''; + } +} |