All files / modules/acute-common/src/pipes timing.pipe.ts

0% Statements 0/8
0% Branches 0/4
0% Functions 0/2
0% Lines 0/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19                                     
import { Pipe, PipeTransform } from '@angular/core';
 
@Pipe({ name: 'acuteTiming'  , standalone: true})
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' : '';
  }
}