All checks were successful
ci/woodpecker/push/build Pipeline was successful
ci/woodpecker/push/lint-backend Pipeline was successful
ci/woodpecker/push/lint-client Pipeline was successful
ci/woodpecker/push/lint-foundkey-js Pipeline was successful
ci/woodpecker/push/test Pipeline was successful
Constants were borrowed from `const.ts` from the backend but also includes `WEEK`, `MONTH`, and `YEAR` constants as well. Co-authored-by: Francis Dinh <normandy@biribiri.dev> Reviewed-on: #183
21 lines
565 B
Vue
21 lines
565 B
Vue
<template>
|
|
<MkTime format="date" mode="absolute" :time="birthday" :utc="true"/> ({{ i18n.t('yearsOld', { age }) }})
|
|
</template>
|
|
<script lang="ts" setup>
|
|
import MkTime from '@/components/global/time.vue';
|
|
import { i18n } from '@/i18n';
|
|
import { YEAR } from '@/const';
|
|
|
|
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()) / YEAR);
|
|
});
|
|
|
|
</script>
|