Skip to content

Commit 1ed74ad

Browse files
committed
Fix : Correct display for perm input in edit mode
1 parent 423e881 commit 1ed74ad

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

frontend/src/components/utils/datetime_utils.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,18 @@ export const formatDateForInput = (date?: string | null) => {
55
if (!date) return "";
66
const localDate = new Date(date);
77
if (isNaN(localDate.getTime())) return "";
8-
// Convertir en "YYYY-MM-DDTHH:mm"
9-
return localDate.toISOString().slice(0, 16);
8+
9+
// Construire YYYY-MM-DDTHH:mm en LOCAL
10+
const year = localDate.getFullYear();
11+
const month = String(localDate.getMonth() + 1).padStart(2, "0");
12+
const day = String(localDate.getDate()).padStart(2, "0");
13+
const hours = String(localDate.getHours()).padStart(2, "0");
14+
const minutes = String(localDate.getMinutes()).padStart(2, "0");
15+
16+
return `${year}-${month}-${day}T${hours}:${minutes}`;
1017
};
1118

19+
1220
// Pour envoyer vers la DB
1321
// On reçoit une string "YYYY-MM-DDTHH:mm" venant de l'input datetime-local
1422
// On la convertit en UTC ISO (toujours ce que ta DB attend)

0 commit comments

Comments
 (0)