import { Pipe, PipeTransform } from '@angular/core';
import { CommonService } from '../../services/common/common.service';

@Pipe({
  name: 'dateTime'
})
export class DateTimePipe implements PipeTransform {
  constructor(
    public cs: CommonService
  ) {

  }
  transform(value: any, args?: any): any {
    if (value) {
      return this.cs.evaluteDate(value, true);
    }
    return null;
  }

  public evaluteDate(dateStr: string): string {
    const utc = parseInt(dateStr.substring(6, dateStr.length - 2), 10);
    const appoDate = new Date(utc);
    return appoDate.toLocaleString();
  }

}
