mirror of
https://github.com/trafficlunar/website.git
synced 2026-06-28 06:04:09 +00:00
feat: cool age counter
This commit is contained in:
parent
ade8d0512c
commit
f2eed91109
2 changed files with 26 additions and 1 deletions
22
src/components/Age.svelte
Normal file
22
src/components/Age.svelte
Normal 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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue