import { defineComponent, ref, computed, PropType, toRef, onMounted } from 'vue'
import { useUserStore } from '@store/UserStore'
import { useRouter } from 'vue-router'
import { useGlobalStore } from '@store/globalStore'
import { useI18n } from 'vue-i18n'
import { tools } from '@tools'
import { toolsext } from '@store/Modules/toolsext'

import { es, it, enUS } from 'date-fns/locale' // import custom locale

export default defineComponent({
  name: 'CTimeAgo',
  components: {},
  props: {
    datetime: {
      type: String,
      required: true
    },
  },

  setup(props, { emit }) {

    const mylocale = ref(<any>null)

    function mounted() {
      mylocale.value = enUS
      if (toolsext.getLocale() === 'it')
        mylocale.value = it
      else if (toolsext.getLocale() === 'es')
        mylocale.value = es
    }

    mounted()

    return {
      tools,
      toolsext,
      mylocale,
    }
  }
})
