diff --git a/client/src/pages/AdminSequences.tsx b/client/src/pages/AdminSequences.tsx index a8d5f99..bffa9ad 100644 --- a/client/src/pages/AdminSequences.tsx +++ b/client/src/pages/AdminSequences.tsx @@ -106,11 +106,12 @@ export default function AdminSequences() { try { // Si c'est un objet Date JavaScript if (dateValue instanceof Date) { - const year = dateValue.getFullYear(); - const month = String(dateValue.getMonth() + 1).padStart(2, '0'); - const day = String(dateValue.getDate()).padStart(2, '0'); - const hours = String(dateValue.getHours()).padStart(2, '0'); - const minutes = String(dateValue.getMinutes()).padStart(2, '0'); + // Utiliser les méthodes UTC pour éviter le décalage horaire + const year = dateValue.getUTCFullYear(); + const month = String(dateValue.getUTCMonth() + 1).padStart(2, '0'); + const day = String(dateValue.getUTCDate()).padStart(2, '0'); + const hours = String(dateValue.getUTCHours()).padStart(2, '0'); + const minutes = String(dateValue.getUTCMinutes()).padStart(2, '0'); return `${year}-${month}-${day}T${hours}:${minutes}`; } @@ -154,6 +155,15 @@ export default function AdminSequences() { setIsEditOpen(true); }; + // Convertir une date locale (datetime-local) en ISO UTC + const convertLocalToUTC = (localDateStr: string): string => { + if (!localDateStr) return localDateStr; + // datetime-local retourne "YYYY-MM-DDTHH:mm" + // On doit le traiter comme heure locale et le convertir en UTC + const localDate = new Date(localDateStr); + return localDate.toISOString(); + }; + const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); @@ -168,10 +178,14 @@ export default function AdminSequences() { lieu: formData.lieu, publicCible: formData.publicCible, capaciteMax: parseInt(formData.capaciteMax), - dateBlocage: formData.dateBlocage, + dateBlocage: convertLocalToUTC(formData.dateBlocage), statut: formData.statut, formateurId: formData.formateur ? parseInt(formData.formateur) : null, - dates: formData.dates, + dates: formData.dates.map(d => ({ + ...d, + dateDebut: convertLocalToUTC(d.dateDebut), + dateFin: convertLocalToUTC(d.dateFin), + })), }; if (editingSequence) { diff --git a/todo.md b/todo.md index 8ac3b97..8bb2ea8 100644 --- a/todo.md +++ b/todo.md @@ -684,3 +684,10 @@ - [x] Vérifier si l'erreur vient de la création ou de la recherche dans la map (problème de récupération ID) - [x] Corriger le problème identifié (utilisation de $returningId() pour formations et séquences, ajout ordre pour dates) - [x] Tester l'import et valider que tout fonctionne + +## Bug décalage horaire - Heures de séquences + +- [x] Identifier où se produit le décalage horaire (+1h) (conversion locale vs UTC) +- [x] Vérifier la gestion des fuseaux horaires dans le formulaire +- [x] Corriger la conversion des dates/heures (UTC pour affichage et envoi) +- [x] Tester la saisie et l'affichage des heures