1 import { Pipe, PipeTransform } from '@angular/core'
4 name: 'myDurationFormatter'
6 export class DurationFormatterPipe implements PipeTransform {
8 transform (value: number): string {
9 const hours = Math.floor(value / 3600)
10 const minutes = Math.floor((value % 3600) / 60)
11 const seconds = value % 60
14 let result = $localize`${hours}h`
16 if (minutes !== 0) result += ' ' + $localize`${minutes}min`
17 if (seconds !== 0) result += ' ' + $localize`${seconds}sec`
23 let result = $localize`${minutes}min`
25 if (seconds !== 0) result += ' ' + `${seconds}sec`
30 return $localize`${seconds} sec`