From 464dde127b74f87ce24f3abc4bda20e2a8b8ab7e Mon Sep 17 00:00:00 2001 From: Marcin-Ramotowski Date: Wed, 30 Apr 2025 17:33:05 +0000 Subject: [PATCH] Changed input type to datetime-local and simplified datetime convertion --- frontend/src/pages/Tasks.tsx | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/frontend/src/pages/Tasks.tsx b/frontend/src/pages/Tasks.tsx index 7cd3ad4..7737ebd 100644 --- a/frontend/src/pages/Tasks.tsx +++ b/frontend/src/pages/Tasks.tsx @@ -101,12 +101,9 @@ const Tasks = () => { const handleSaveEdit = async (taskId: number) => { try { const formatDateForApi = (dateStr: string): string => { - const date = new Date(dateStr); - const day = String(date.getDate()).padStart(2, '0'); - const month = String(date.getMonth() + 1).padStart(2, '0'); - const year = date.getFullYear(); - const hours = String(date.getHours()).padStart(2, '0'); - const minutes = String(date.getMinutes()).padStart(2, '0'); + const [datePart, timePart] = dateStr.split('T'); + const [year, month, day] = datePart.split('-'); + const [hours, minutes] = timePart.split(':'); return `${day}-${month}-${year} ${hours}:${minutes}`; }; @@ -189,7 +186,7 @@ const Tasks = () => { className="border p-1 mb-1 w-full" /> setEditedTask({ ...editedTask, due_date: e.target.value })} className="border p-1 mb-1 w-full"