From 1ed9638c04e16dea78c747a56b78dd3050507754 Mon Sep 17 00:00:00 2001
From: Arjun Satarkar <me@arjunsatarkar.net>
Date: Tue, 31 Dec 2024 21:39:16 +0530
Subject: Refactor, use adapter-static

---
 src/routes/+page.svelte | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

(limited to 'src/routes/+page.svelte')

diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte
index 3b2ef88..093347f 100644
--- a/src/routes/+page.svelte
+++ b/src/routes/+page.svelte
@@ -2,8 +2,8 @@
     import { DateTime } from "luxon";
 
     const getCurrentYear = () => DateTime.now().year;
-    const getRelative = (year) =>
-        DateTime.local(year).toRelative({ locale: "en" });
+    const getRelative = (year: number) =>
+        DateTime.local(year).toRelative({ locale: "en" })!;
 
     let year = $state(getCurrentYear());
     let sqrt = $derived(year ** 0.5);
@@ -12,12 +12,14 @@
     let nextSqrt = $derived(isPerfectSquare ? sqrt + 1 : Math.ceil(sqrt));
     let last = $derived(lastSqrt ** 2);
     let next = $derived(nextSqrt ** 2);
-    let nextRelative = $state(getRelative(next));
+    let nextRelative: string = $state("");
 
-    setInterval(() => {
+    const update = () => {
         year = getCurrentYear();
         nextRelative = getRelative(next);
-    }, 500);
+    };
+    update();
+    setInterval(update, 500);
 </script>
 
 <div id="container">
-- 
cgit v1.2.3-57-g22cb

