1 import { Pipe, PipeTransform } from '@angular/core'
2 import { I18n } from '@ngx-translate/i18n-polyfill'
5 name: 'myVideoDurationFormatter'
7 export class VideoDurationPipe implements PipeTransform {
9 constructor (private i18n: I18n) {
13 transform (value: number): string {
14 const hours = Math.floor(value / 3600)
15 const minutes = Math.floor((value % 3600) / 60)
16 const seconds = value % 60
19 return this.i18n('{{hours}} h {{minutes}} min {{seconds}} sec', { hours, minutes, seconds })
23 return this.i18n('{{minutes}} min {{seconds}} sec', { minutes, seconds })
26 return this.i18n('{{seconds}} sec', { seconds })