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) => {
|
const handleSaveEdit = async (taskId: number) => {
|
||||||
try {
|
try {
|
||||||
const formatDateForApi = (dateStr: string): string => {
|
const formatDateForApi = (dateStr: string): string => {
|
||||||
const date = new Date(dateStr);
|
const [datePart, timePart] = dateStr.split('T');
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
const [year, month, day] = datePart.split('-');
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
const [hours, minutes] = timePart.split(':');
|
||||||
const year = date.getFullYear();
|
|
||||||
const hours = String(date.getHours()).padStart(2, '0');
|
|
||||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
||||||
return `${day}-${month}-${year} ${hours}:${minutes}`;
|
return `${day}-${month}-${year} ${hours}:${minutes}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -189,7 +186,7 @@ const Tasks = () => {
|
|||||||
className="border p-1 mb-1 w-full"
|
className="border p-1 mb-1 w-full"
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="datetime-local"
|
||||||
value={editedTask.due_date || ""}
|
value={editedTask.due_date || ""}
|
||||||
onChange={(e) => setEditedTask({ ...editedTask, due_date: e.target.value })}
|
onChange={(e) => setEditedTask({ ...editedTask, due_date: e.target.value })}
|
||||||
className="border p-1 mb-1 w-full"
|
className="border p-1 mb-1 w-full"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user