2022-08-28 18:49:22 +00:00
|
|
|
<template>
|
2022-08-28 19:38:49 +00:00
|
|
|
<MkTime format="date" mode="absolute" :time="birthday" :utc="true"/> ({{ i18n.t('yearsOld', { age }) }})
|
2022-08-28 18:49:22 +00:00
|
|
|
</template>
|
|
|
|
<script lang="ts" setup>
|
|
|
|
import MkTime from '@/components/global/time.vue';
|
2022-08-28 19:38:49 +00:00
|
|
|
import { i18n } from '@/i18n';
|
2022-10-04 18:05:41 +00:00
|
|
|
import { YEAR } from '@/const';
|
2022-08-28 18:49:22 +00:00
|
|
|
|
|
|
|
const props = defineProps<{
|
|
|
|
birthday: Date | string;
|
|
|
|
}>();
|
|
|
|
|
|
|
|
const age = $computed(() => {
|
|
|
|
const now = new Date();
|
|
|
|
const birthday = (typeof props.birthday === 'string') ? new Date(props.birthday) : props.birthday;
|
|
|
|
|
2022-10-04 18:05:41 +00:00
|
|
|
return Math.floor((now.getTime() - birthday.getTime()) / YEAR);
|
2022-08-28 18:49:22 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|