const getStartTime = (date) => {
  return new Date(new Date(date).setHours(0, 0, 0, 0));
}

const getEndTime = (date) => {
  return new Date(new Date(date).setHours(23, 59, 59, 0));
}

const getDateFormat = (txtDate = '') => {
  const dateStr = txtDate.split('T')[0];
  const timeArr = txtDate.split('T')[1]?.replace('Z', '').split(':');
  const date = new Date(dateStr.replace(/-/g, '/')); // ie, safari 대응
  const year = date.getFullYear();
  const month = ((1 + date.getMonth()).toString()).slice(-2);
  const day = (date.getDate().toString()).slice(-2);
  const useTime = timeArr?.length;
  const hh = useTime ? timeArr[0] : '00';
  const mm = useTime ? timeArr[1] : '00';
  const ss = useTime ? timeArr[2] : '00';

  return new Date(`${year}/${month}/${day} ${hh}:${mm}:${ss}`)
}

export default {
  getDateFormat,
  getStartTime,
  getEndTime
}