import { Pipe } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';
import { format } from 'date-fns';
import { zhCN } from 'date-fns/locale';

@Pipe({ name: 'dateFormat' })
export class DateFormat {
  /**
   * https://date-fns.org/v2.28.0/docs/format
   * @param dateStr
   */
  transform(dateStr, fmt: string = 'yyyy/M/d') {
    if(!dateStr) return '';
    let date = new Date(dateStr);
    return format(date, fmt, {locale : zhCN});
  }

}