From 6f4cc3afffde36a13618458ffda72e6104624f36 Mon Sep 17 00:00:00 2001 From: polo Date: Wed, 30 Aug 2023 12:20:39 +0200 Subject: =?UTF-8?q?section=20client=20=C3=A0=20part,=20section=20modif=20e?= =?UTF-8?q?n=20cours,=20bug=20dans=20Dates,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Dates.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/Dates.php') diff --git a/src/Dates.php b/src/Dates.php index 2fe93cb..d7ed6c7 100644 --- a/src/Dates.php +++ b/src/Dates.php @@ -59,8 +59,7 @@ class Dates $input = $this->dashOrSlash($input); // formate pour strtotime() $this->setDayMonthYear($input); - //~ if(checkdate($splitedDate[0], $splitedDate[1], $splitedDate[2])) - if(checkdate($this->day, $this->month, $this->year)) + if(checkdate($this->month, $this->day, $this->year)) // checkdate() veut un format américain { $this->date = $input; $this->timestamp = strtotime($input); // date (string) -> timestamp (int) @@ -86,14 +85,19 @@ class Dates $splitedDate = preg_split('#\D#', $input); // \D = tout sauf chiffre if(self::$date_format === 'euro') + { + $this->day = $splitedDate[0]; + $this->month = $splitedDate[1]; + } + elseif(self::$date_format === 'usa') { $this->day = $splitedDate[1]; $this->month = $splitedDate[0]; } else { - $this->day = $splitedDate[0]; - $this->month = $splitedDate[1]; + echo("Le fichier config.php comporte une erreur. La variable $date_format doit avoir pour valeur 'euro' ou 'usa'"); + die(); // brutal } $this->year = $splitedDate[2]; } -- cgit v1.2.3