Skip to content

Commit

Permalink
Empêche l'import PA d'échouer si le format de date DD/MM/YYYY est par…
Browse files Browse the repository at this point in the history
…fois transformé en MM/DD/YYYY
  • Loading branch information
amandinejacquelin committed Dec 18, 2024
1 parent b8b9815 commit fcf851c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion supabase/functions/import_plan_action/fonctionsDeNettoyage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit fcf851c

Please sign in to comment.