<template>
  <div class="absolute top-0 right-4 hidden lg:block" v-if="gameStore.world.date && typeof gameStore.world.date === 'object'">
    <p class="text-white text-lg">
      {{ useDateFormat(gameStore.world.date, 'YYYY/MM/DD HH:mm') }}
    </p>
  </div>
</template>

<script setup lang="ts">
import { SocketEvent } from '@/application/enums'
import { useGameStore } from '@/stores/gameStore'
import { useDateFormat } from '@vueuse/core'
import { onUnmounted } from 'vue'

const gameStore = useGameStore()

onUnmounted(() => {
  gameStore.connection?.off(SocketEvent.DATE)
})
</script>
