forked from FoundKeyGang/FoundKey
18 lines
509 B
Vue
18 lines
509 B
Vue
<template>
|
|
<MkTime format="date" mode="absolute" :time="birthday" :utc="true"/> ({{ $t('yearsOld', { age }) }})
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import MkTime from '@/components/global/time.vue';
|
|
|
|
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;
|
|
|
|
return Math.floor((now.getTime() - birthday.getTime()) / 1000 / 31536000);
|
|
});
|
|
|
|
</script>
|