]> git.agnieray.net Git - galette.git/commitdiff
Use same logic for date getters than in contributions
authorJohan Cwiklinski <johan@x-tnd.be>
Mon, 23 Oct 2023 12:43:11 +0000 (14:43 +0200)
committerJohan Cwiklinski <johan@x-tnd.be>
Mon, 23 Oct 2023 12:43:11 +0000 (14:43 +0200)
galette/lib/Galette/Filters/TransactionsList.php

index 31c09059caedc43a1598a9b7c0a97e13994568c7..2c24384cc9233e2ab9452295fd5ea44092a6881d 100644 (file)
@@ -138,11 +138,19 @@ class TransactionsList extends Pagination
                 switch ($name) {
                     case 'start_date_filter':
                     case 'end_date_filter':
+                        if ($this->$name === null) {
+                            return $this->$name;
+                        }
                         try {
-                            if ($this->$name !== null) {
-                                $d = new \DateTime($this->$name);
-                                return $d->format(__("Y-m-d"));
+                            $d = \DateTime::createFromFormat(__("Y-m-d"), $this->$name);
+                            if ($d === false) {
+                                //try with non localized date
+                                $d = \DateTime::createFromFormat("Y-m-d", $this->$name);
+                                if ($d === false) {
+                                    throw new \Exception('Incorrect format');
+                                }
                             }
+                            return $d->format(__("Y-m-d"));
                         } catch (Throwable $e) {
                             //oops, we've got a bad date :/
                             Analog::log(