import { computed } from 'vue'
import dayjs from 'dayjs'
import useMainStore from '@/store/main'
import { useTimestamp } from '@vueuse/core'
import { timeFormat } from '@/utils/common'

const useTime = () => {
  const mainStore = useMainStore()
  const timestamp = useTimestamp()
  return computed(() => {
    return {
      serverTimeFormat: dayjs(timestamp.value - mainStore.diffTime).format('YYYY-MM-DD HH:mm:ss'),
      joinTimeFormat: timeFormat(timestamp.value - mainStore.loginSuccessTime),
    }
  })
}

export default useTime
