/**
 * Resolve after `time` has been spend.
 *
 * @param time Time in milliseconds to wait
 */

const dateFormat = {
  millisecondsRemove: (str: string) => {
    const setDate = new Date(str)
    if (isNaN(setDate.getTime())) {
      console.error('유효하지 않은 날짜 형식입니다:', str)
      return null
    }
    const year = setDate.getFullYear()
    const month = setDate.getMonth() + 1
    const day = setDate.getDate()
    const hours = setDate.getHours()
    const minutes = setDate.getMinutes()
    const formattedMonth = String(month).padStart(2, '0')
    const formattedDay = String(day).padStart(2, '0')
    const formattedHours = String(hours).padStart(2, '0')
    const formattedMinutes = String(minutes).padStart(2, '0')
    return `${year}-${formattedMonth}-${formattedDay} ${formattedHours}:${formattedMinutes}`
  },
}

export default dateFormat
