]> git.agnieray.net Git - galette.git/blobdiff - galette/lib/Galette/Filters/ContributionsList.php
Fix contributions date filters; closes #1469
[galette.git] / galette / lib / Galette / Filters / ContributionsList.php
index c44c193b9ad5e5a6c8b13c69cec797905af4f425..6a98c0db6ed68dc49939ead4998e9f7106feb12f 100644 (file)
@@ -153,10 +153,15 @@ class ContributionsList extends Pagination
                     case 'start_date_filter':
                     case 'end_date_filter':
                         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 (\Exception $e) {
                             //oops, we've got a bad date :/
                             Analog::log(