fix countdown timezone

This commit is contained in:
2025-11-09 14:27:08 +01:00
parent b2c24f394f
commit 1cf452f074
2 changed files with 9 additions and 5 deletions

View File

@@ -1,9 +1,14 @@
<script lang="ts"> <script lang="ts">
import { onDestroy } from 'svelte'; import { onDestroy } from 'svelte';
let { start, end }: { start?: number; end: number } = $props(); interface Props {
start?: Date,
end: Date,
}
let title = `Spielstart ist am ${new Date(end).toLocaleString('de-DE', { let { start, end }: Props = $props();
const title = `Spielstart ist am ${new Date(end).toLocaleString('de-DE', {
day: '2-digit', day: '2-digit',
month: 'long', month: 'long',
year: 'numeric', year: 'numeric',
@@ -12,7 +17,7 @@
})} Uhr`; })} Uhr`;
function getUntil(): [number, number, number, number] { function getUntil(): [number, number, number, number] {
let diff = (end - (start || Date.now())) / 1000; let diff = (end.getTime() - (start?.getTime() || Date.now())) / 1000;
return [ return [
Math.floor(diff / (60 * 60 * 24)), Math.floor(diff / (60 * 60 * 24)),
@@ -25,7 +30,6 @@
let [days, hours, minutes, seconds] = $state(getUntil()); let [days, hours, minutes, seconds] = $state(getUntil());
let intervalId = setInterval(() => { let intervalId = setInterval(() => {
[days, hours, minutes, seconds] = getUntil(); [days, hours, minutes, seconds] = getUntil();
if (start) start += 1000;
}, 1000); }, 1000);
onDestroy(() => clearInterval(intervalId)); onDestroy(() => clearInterval(intervalId));

View File

@@ -66,7 +66,7 @@ const information = [
<img src={Background.src} alt="" loading="lazy" width="100%" height="100%" /> <img src={Background.src} alt="" loading="lazy" width="100%" height="100%" />
</div> </div>
<div class="hidden xl:flex justify-center absolute bottom-12 right-0 w-[60%]"> <div class="hidden xl:flex justify-center absolute bottom-12 right-0 w-[60%]">
<Countdown end={Date.parse(START_DATE)} client:load /> <Countdown end={new Date(START_DATE)} client:load />
</div> </div>
</div> </div>