diff --git a/src/lib/components/blocks/DeadlineBannerBlock.svelte b/src/lib/components/blocks/DeadlineBannerBlock.svelte index bf2b5b8..a0478cc 100644 --- a/src/lib/components/blocks/DeadlineBannerBlock.svelte +++ b/src/lib/components/blocks/DeadlineBannerBlock.svelte @@ -61,11 +61,20 @@ }); }); + /** Kalendertage zwischen heute und Ziel — über Mitternacht-zu- + * Mitternacht-Diff, nicht roh per ms. Sonst zählt z. B. 30 h vor + * Termin als „2 Tage" obwohl der Termin morgen ist. */ const daysLeft = $derived.by(() => { if (!dateObj) return null; - const ms = dateObj.getTime() - Date.now(); - if (ms < 0) return null; - return Math.ceil(ms / (1000 * 60 * 60 * 24)); + const today = new Date(); + today.setHours(0, 0, 0, 0); + const target = new Date(dateObj); + target.setHours(0, 0, 0, 0); + const diffDays = Math.round( + (target.getTime() - today.getTime()) / (1000 * 60 * 60 * 24), + ); + if (diffDays < 0) return null; + return diffDays; }); const countdownStr = $derived.by(() => { @@ -103,7 +112,7 @@ {#if hasContent && !dismissed}