From fcf851cec21cc092eb28757b0749bbc4d816148b Mon Sep 17 00:00:00 2001 From: Amandine Jacquelin Date: Wed, 18 Dec 2024 18:02:15 +0100 Subject: [PATCH] =?UTF-8?q?Emp=C3=AAche=20l'import=20PA=20d'=C3=A9chouer?= =?UTF-8?q?=20si=20le=20format=20de=20date=20DD/MM/YYYY=20est=20parfois=20?= =?UTF-8?q?transform=C3=A9=20en=20MM/DD/YYYY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../import_plan_action/fonctionsDeNettoyage.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/supabase/functions/import_plan_action/fonctionsDeNettoyage.ts b/supabase/functions/import_plan_action/fonctionsDeNettoyage.ts index df89293075..691bbe1cbb 100644 --- a/supabase/functions/import_plan_action/fonctionsDeNettoyage.ts +++ b/supabase/functions/import_plan_action/fonctionsDeNettoyage.ts @@ -105,7 +105,16 @@ const nettoieDate = async (date: any) => { if (!date) { return null; } - const d = new Date(date); + let d = new Date(date); + if (d.toString() == "Invalid Date") { + const regex = /^(\d{2})\/(\d{2})\/(\d{4})$/; + const match = date.match(regex); + if (match) { + const [, day, month, year] = match; + const invertedDate = `${month}/${day}/${year}`; + d = new Date(invertedDate); + } + } if (d.toString() == "Invalid Date") { throw Error("La date n'est pas valide"); }