UNPKG

loop-modules

Version:

Shared modules for the Loop product suite.

31 lines (24 loc) 685 B
// angular import { Pipe, PipeTransform } from '@angular/core'; @Pipe({ name: 'minutes' }) /** * This pipe is used to take an integer (which is seconds), and convert it to * a minutes:seconds format (01:43) * @param: Number * @return: String */ export class MinutesPipe implements PipeTransform { transform(seconds: number): string { let minutes: number = 0; if(seconds >= 60) { minutes = Math.floor(seconds / 60); seconds = seconds % 60; } return this.convertNumber(minutes) + ':' + this.convertNumber(seconds); } private convertNumber(i: number): string { return ('0' + i).slice(-2); } }