import { useState } from "react"
import { diff } from '@/utils/chatDate'
import useInterval from './useInterval'

/**
 * 倒计时
 * @param {*} date1 
 * @param {*} date2 
 */
export default function useCountDown(date1, date2) {
  const [countdown, setCountDown] = useState([])

  useInterval(() => {
    setCountDown(diff(date1, date2))
  }, 1000, true)

  return countdown
}
