diff options
| author | Fuwn <[email protected]> | 2024-10-28 15:32:46 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-28 15:32:46 -0700 |
| commit | 39b677404558ae3b7eb34e818d7ca308f62f9cb0 (patch) | |
| tree | 7f19fca39ecd4237e3c0d1aef2d8e9fa3cec7845 /src/lib/Tools/Birthdays.svelte | |
| parent | feat(graphql): paged badges query (diff) | |
| download | due.moe-svelte-5.tar.xz due.moe-svelte-5.zip | |
feat: update to svelte 5svelte-5
Diffstat (limited to 'src/lib/Tools/Birthdays.svelte')
| -rw-r--r-- | src/lib/Tools/Birthdays.svelte | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/Tools/Birthdays.svelte b/src/lib/Tools/Birthdays.svelte index 97ff40d8..17c91709 100644 --- a/src/lib/Tools/Birthdays.svelte +++ b/src/lib/Tools/Birthdays.svelte @@ -1,4 +1,6 @@ <script lang="ts"> + import { run } from 'svelte/legacy'; + import { browser } from '$app/environment'; import { page } from '$app/stores'; import { ACDBBirthdays, type ACDBBirthday } from '$lib/Data/Birthday/secondary'; @@ -18,12 +20,12 @@ const urlParameters = browser ? new URLSearchParams(window.location.search) : null; let date = new Date(); - let month = parseOrDefault(urlParameters, 'month', date.getMonth() + 1); - let day = parseOrDefault(urlParameters, 'day', date.getDate()); - let anisearchBirthdays: Promise<aniSearchBirthday[]>; - let acdbBirthdays: Promise<ACDBBirthday[]>; + let month = $state(parseOrDefault(urlParameters, 'month', date.getMonth() + 1)); + let day = $state(parseOrDefault(urlParameters, 'day', date.getDate())); + let anisearchBirthdays: Promise<aniSearchBirthday[]> = $state(); + let acdbBirthdays: Promise<ACDBBirthday[]> = $state(); - $: { + run(() => { month = Math.min(month, 12); month = Math.max(month, 1); day = Math.min(day, new Date(new Date().getFullYear(), month, 0).getDate()); @@ -39,7 +41,7 @@ clearAllParameters(['month', 'day']); history.replaceState(null, '', `?${$page.url.searchParams.toString()}`); } - } + }); onMount(() => clearAllParameters(['month', 'day'])); |