From 117b8c82ef02b95d289cd1ad22f226828918a18b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adri=C3=A1n=20Oliva?= <adrian.oliva@cimat.mx>
Date: Sun, 28 May 2023 14:02:01 -0600
Subject: Changed date format.

On the user end it displays in a human readable way. On the database it
is saved in ISO format. A lot of changes had to be made to control it.
---
 src/App.jsx | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'src/App.jsx')

diff --git a/src/App.jsx b/src/App.jsx
index 832db93..6f1b14f 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -14,14 +14,19 @@ function App() {
     const dispatch = useDispatch();
     function handler(data) {
         data.map((todo) => {
+            const due_date = new Date(todo.dueDate);
+            const offset = due_date.getTimezoneOffset();
+
             dispatch(
                 set_todo({
                     id: todo.id,
                     text: todo.text,
                     due_date:
                         todo.dueDate != null
-                            ? todo.dueDate.substring(0, 16)
-                            : todo.dueDate,
+                            ? new Date(due_date - offset * 60 * 1000)
+                                  .toISOString()
+                                  .slice(0, -1)
+                            : "",
                     done: todo.done,
                     priority: todo.priority,
                     creation_date: todo.creationDate,
-- 
cgit v1.2.3

