import { Pipe , PipeTransform } from '@angular/core' ; @ Pipe ( { name : 'duration' } ) export class DurationPipe implements PipeTransform { transform ( seconds ) { let minutes = Math . floor ( seconds / 60 ) ; let hours = Math . floor ( minutes / 60 ) ; const days = Math . floor ( hours / 24 ) ; hours = hours - ( days * 24 ) ; minutes = minutes - ( days * 24 * 60 ) - ( hours * 60 ) ; seconds = Math . floor ( seconds - ( days * 24 * 60 * 60 ) - ( hours * 60 * 60 ) - ( minutes * 60 ) ) ; if ( hours > 0 ) { return `${ this . pad ( hours ) }:${ this . pad ( minutes ) }:${ this . pad ( seconds ) }` ; } else { return `${ this . pad ( minutes ) }:${ this . pad ( seconds ) }` ; } } pad ( value ) { if ( value < 10 ) { return `0${ value }` ; } return value . toString ( ) ; } }