import { format } from 'date-fns'

const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm'
const DATE_FORMAT = 'YYYY-MM-DD '
const DATE_FORMAT_HMS = 'yyyy-MM-dd HH:mm:ss'
const DATA_FORMAT_2 = 'yyyy/MM/dd'

export function formatToDateTime(date: Date | number, formatStr = DATE_TIME_FORMAT): string {
  return format(date, formatStr)
}

export function formatToDate(date: Date | number, formatStr = DATE_FORMAT): string {
  return format(date, formatStr)
}

export function formatToDate2(date: Date | number, formatStr = DATA_FORMAT_2): string {
  return format(date, formatStr)
}

export function formatToDateHMS(date: Date | number, formatStr = DATE_FORMAT_HMS) {
  return format(date, formatStr)
}
