Chocobozzz/PeerTube

View on GitHub
client/src/app/shared/shared-main/date/days-duration-formatter.pipe.ts

Summary

Maintainability
A
0 mins
Test Coverage
import { Pipe, PipeTransform } from '@angular/core'

@Pipe({
  name: 'myDaysDurationFormatter',
  standalone: true
})
export class DaysDurationFormatterPipe implements PipeTransform {

  transform (value: number): string {
    const days = Math.floor(value / (3600 * 24 * 1000))

    if (days <= 1) return $localize`1 day`

    return $localize`${days} days`
  }
}