import { Pipe } from '@angular/core' ; @ Pipe ( { name : 'timediff' , } ) export class TimediffPipe { transform ( time , displaySeconds = false ) { const seconds = time % 60 ; const minutes = Math . floor ( time / 60 ) % 60 ; const hours = Math . floor ( time / 3600 ) ; let output = '' ; if ( hours > 0 ) { output += `${ hours }h ` ; } if ( minutes > 0 || ! displaySeconds ) { output += `${ minutes }m ` ; } if ( displaySeconds ) { const paddedSeconds = seconds . toString ( ) . padStart ( 2 , '0' ) ; output += `${ paddedSeconds }s` ; } return output ; } }