aboutsummaryrefslogtreecommitdiff
path: root/src/routes/+page.svelte
diff options
context:
space:
mode:
authorArjun Satarkar <me@arjunsatarkar.net>2024-12-31 16:09:16 +0000
committerArjun Satarkar <me@arjunsatarkar.net>2024-12-31 16:09:16 +0000
commit1ed9638c04e16dea78c747a56b78dd3050507754 (patch)
tree2ef6a8130f27379d30e9a1e233b70729c78b6e8f /src/routes/+page.svelte
parent292806498e1adb71ede3c77ea32c5167d4f19929 (diff)
downloadis-the-year-a-perfect-square-1ed9638c04e16dea78c747a56b78dd3050507754.tar
is-the-year-a-perfect-square-1ed9638c04e16dea78c747a56b78dd3050507754.tar.gz
is-the-year-a-perfect-square-1ed9638c04e16dea78c747a56b78dd3050507754.zip
Refactor, use adapter-static
Diffstat (limited to 'src/routes/+page.svelte')
-rw-r--r--src/routes/+page.svelte12
1 files changed, 7 insertions, 5 deletions
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">