fix(deadline-banner): count calendar days, not 24h windows
Deploy / verify (push) Successful in 49s
Deploy / deploy (push) Successful in 53s

daysLeft used Math.ceil(ms/24h) which counted partial 24h windows:
30h before a midnight event tomorrow showed "Noch 2 Tage" instead
of "Morgen". Compare midnight-to-midnight day-keys instead, same
approach as CalendarBlock relativeDays().

Also adds data-block="DeadlineBanner" identifier.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Peter Meier
2026-05-07 15:45:22 +02:00
parent a1c59b549d
commit fc6c59bc10
@@ -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}
<div
class="deadline-banner {layoutClasses}"
data-block-type="deadline_banner"
data-block="DeadlineBanner" data-block-type="deadline_banner"
data-block-slug={block._slug}
>
<div