feat: cool age counter

This commit is contained in:
trafficlunar 2025-05-09 14:25:03 +01:00
parent ade8d0512c
commit f2eed91109
2 changed files with 26 additions and 1 deletions

22
src/components/Age.svelte Normal file
View file

@ -0,0 +1,22 @@
<script lang="ts">
import { onMount } from "svelte";
let age = $state("");
onMount(() => {
const interval = setInterval(() => {
// only people who can read code can see my birthday
const birthday = new Date("03/02/2010");
const currentDate = new Date();
const diffInMs = currentDate.getTime() - birthday.getTime();
const msInYear = 365.25 * 24 * 60 * 60 * 1000;
age = (diffInMs / msInYear).toFixed(14);
}, 10);
return () => clearInterval(interval);
});
</script>
<span class="font-mono">{age}</span>