import { NgModule , Pipe , PipeTransform } from '@angular/core' ; import { Locale } from 'date-fns' ; import formatDistance from 'date-fns/formatDistance' ; import { calculateLocale , DateFnsConfigurationService } from './date-fns-configuration.service' ; import { DateFnsInputDate } from './types' ; import { isValidDate } from './utils' ; @ Pipe ( { name : 'dfnsFormatDistancePure' } ) export class FormatDistancePurePipe implements PipeTransform { constructor ( public config ) { } transform ( date , dateToCompare , options ? ) { if ( isValidDate ( date ) && isValidDate ( dateToCompare ) ) { return formatDistance ( date , dateToCompare , calculateLocale ( options , this . config ) ) ; } return '' ; } } @ NgModule ( { declarations : [ FormatDistancePurePipe ] , exports : [ FormatDistancePurePipe ] } ) export class FormatDistancePurePipeModule { }