mirror of
https://github.com/ArthurDanjou/artsite.git
synced 2026-01-14 15:54:13 +01:00
fix date bug
This commit is contained in:
@@ -1,10 +1,15 @@
|
||||
<script lang="ts" setup>
|
||||
import type { Stats } from '~~/types'
|
||||
|
||||
const { locale, locales } = useI18n()
|
||||
const currentLocale = computed(() => locales.value.find(l => l.code === locale.value))
|
||||
|
||||
const { data: stats } = await useFetch<Stats>('/api/stats')
|
||||
const { t } = useI18n({
|
||||
useScope: 'local',
|
||||
})
|
||||
|
||||
const formatDate = (date: Date, format: string) => useDateFormat(date, format, { locales: currentLocale.value?.code ?? 'en' }).value
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -15,12 +20,12 @@ const { t } = useI18n({
|
||||
tag="p"
|
||||
>
|
||||
<template #time>
|
||||
{{ useTimeAgo(new Date(stats.coding.data.range.start)).value }}
|
||||
{{ useTimeAgo(new Date(stats.coding.data.range.start)).value.split(' ')[0] }}
|
||||
</template>
|
||||
<template #date>
|
||||
<HoverText
|
||||
:hover="t('tooltip.date')"
|
||||
:text="useDateFormat(new Date(stats.coding.data.range.start), 'Do MMMM YYYY').value"
|
||||
:text="formatDate(new Date(stats.coding.data.range.start), 'DD MMMM YYYY')"
|
||||
/>
|
||||
</template>
|
||||
<template #hours>
|
||||
@@ -53,7 +58,7 @@ const { t } = useI18n({
|
||||
<i18n lang="json">
|
||||
{
|
||||
"en": {
|
||||
"stats": "I collect some data for {time}, started the {date}. I've coded for a total of {hours} hours. My best editors are {editors}. My best OS is {os}. My top languages are {languages}.",
|
||||
"stats": "I collect some data for {time} years, started the {date}. I've coded for a total of {hours} hours. My best editors are {editors}. My best OS is {os}. My top languages are {languages}.",
|
||||
"separator": " and ",
|
||||
"tooltip": {
|
||||
"date": "That was so long ago 🫣",
|
||||
@@ -61,7 +66,7 @@ const { t } = useI18n({
|
||||
}
|
||||
},
|
||||
"fr": {
|
||||
"stats": "Je collecte des données depuis {time}, commencé le {date}. J'ai codé un total de {hours} heures. Mes meilleurs éditeurs sont {editors}. Mon meilleur OS est {os}. Mes langages préférés sont {languages}.",
|
||||
"stats": "Je collecte des données depuis {time} ans, commencé le {date}. J'ai codé un total de {hours} heures. Mes meilleurs éditeurs sont {editors}. Mon meilleur OS est {os}. Mes langages préférés sont {languages}.",
|
||||
"separator": " et ",
|
||||
"tooltip": {
|
||||
"date": "C'était il y a si longtemps 🫣",
|
||||
|
||||
Reference in New Issue
Block a user