Compare commits
4 Commits
d8455ccaa3
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2a64577e2d | |||
| 59783ee93a | |||
| bb01d08622 | |||
| 3dc5461783 |
@@ -110,14 +110,17 @@ watch(() => showCoC.value, async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
function convertToAge(dob: string) {
|
function convertToAge(dob: string) {
|
||||||
|
|
||||||
|
if (dob === undefined) return "";
|
||||||
const [month, day, year] = dob.split('/').map(Number);
|
const [month, day, year] = dob.split('/').map(Number);
|
||||||
|
|
||||||
let dobDate = new Date(year, month - 1, day);
|
let dobDate = new Date(year, month - 1, day);
|
||||||
|
|
||||||
return Math.floor(
|
let out = Math.floor(
|
||||||
(Date.now() - dobDate.getTime()) / (1000 * 60 * 60 * 24 * 365.2425)
|
(Date.now() - dobDate.getTime()) / (1000 * 60 * 60 * 24 * 365.2425)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return Number.isNaN(out) ? "" : out;
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@@ -132,7 +135,7 @@ function convertToAge(dob: string) {
|
|||||||
<FormControl>
|
<FormControl>
|
||||||
<template class="flex items-center gap-10">
|
<template class="flex items-center gap-10">
|
||||||
<DateInput :model-value="(value as string) ?? ''" :disabled="readOnly" @update:model-value="handleChange" />
|
<DateInput :model-value="(value as string) ?? ''" :disabled="readOnly" @update:model-value="handleChange" />
|
||||||
<p class="text-muted-foreground">Age: {{ convertToAge(value) }}</p>
|
<p v-if="props.readOnly" class="text-muted-foreground">Age: {{ convertToAge(value) }}</p>
|
||||||
</template>
|
</template>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
<div class="h-4">
|
<div class="h-4">
|
||||||
|
|||||||
Reference in New Issue
Block a user