Changed input type to datetime-local and simplified datetime convertion
This commit is contained in:
parent
c728956099
commit
464dde127b
@ -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"
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
type="datetime-local"
|
||||
value={editedTask.due_date || ""}
|
||||
onChange={(e) => setEditedTask({ ...editedTask, due_date: e.target.value })}
|
||||
className="border p-1 mb-1 w-full"
|
||||
|
Loading…
x
Reference in New Issue
Block a user