import { computed } from "vue"
import { isDate, format } from 'date-fns';
import { isTimestamp } from '@/utils/index.js'
export function filterFormatDate() {
  /**
   * 日期格式化
   */
  const formatDate = computed(() => {
    return function(date, formatStr){
      if(isDate(date) || isTimestamp(date)){
        return format(date, formatStr);
      }else{
        return '';
      }
    }
  })

  return {
    formatDate
  };
}