New dashboard look & feel
[src/xds/xds-agent.git] / webapp / src / app / @theme / pipes / timing.pipe.ts
1 import { Pipe, PipeTransform } from '@angular/core';
2
3 @Pipe({ name: 'timing' })
4 export class TimingPipe implements PipeTransform {
5   transform(time: number): string {
6     if (time) {
7       const minutes = Math.floor(time / 60);
8       const seconds = Math.floor(time % 60);
9       return `${this.initZero(minutes)}${minutes}:${this.initZero(seconds)}${seconds}`;
10     }
11
12     return '00:00';
13   }
14
15   private initZero(time: number): string {
16     return time < 10 ? '0' : '';
17   }
18 }