import { Pipe, PipeTransform } from '@angular/core';
import * as moment from 'moment';

@Pipe({ name: 'datef' })
export class MomentPipe implements PipeTransform {
  transform(value: Date | moment.Moment, dateFormat: string | undefined = undefined): any {
    if (!dateFormat) {
      return moment(value).fromNow();
    }
    
    return moment(value).format(dateFormat);
  }
}