From 056f9fc562481cbe8522b122fa54e94b042db8fc Mon Sep 17 00:00:00 2001 From: Aculix Technologies Date: Thu, 16 Oct 2025 17:32:02 +0530 Subject: [PATCH] Refactor date display logic in App.svelte to use reactive variable for improved readability --- src/App.svelte | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index c3bedf8..bb2dd83 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -15,6 +15,7 @@ let selectedDate = new Date().toDateString(); let draggedItem = null; let draggedOverIndex = null; + let currentDateDisplay = ''; function addTask() { if (newTask.trim()) { @@ -85,13 +86,16 @@ draggedOverIndex = null; } - function getCurrentDate() { - return new Date().toLocaleDateString('en-US', { - weekday: 'long', - year: 'numeric', - month: 'long', - day: 'numeric' - }); + $: { + currentDateDisplay = (() => { + const date = new Date(selectedDate); + return date.toLocaleDateString('en-US', { + weekday: 'long', + year: 'numeric', + month: 'long', + day: 'numeric' + }); + })(); } function getDateKey(dateString) { @@ -282,7 +286,7 @@

To-dos

-
{getCurrentDate()}
+
{currentDateDisplay}