File tree Expand file tree Collapse file tree 1 file changed +8
-14
lines changed
app/code/Magento/Sales/Plugin/Model/ResourceModel/Order Expand file tree Collapse file tree 1 file changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -49,12 +49,8 @@ public function aroundAddFieldToFilter(
4949 if ($ field === 'created_at ' || $ field === 'order_created_at ' ) {
5050 if (is_array ($ condition )) {
5151 foreach ($ condition as $ key => $ value ) {
52- if ($ value instanceof DateTimeInterface
53- && $ value ->getTimezone ()->getName () !== $ this ->timeZone ->getConfigTimezone ()) {
54- $ value ->setTimezone (new \DateTimeZone ($ this ->timeZone ->getConfigTimezone ()));
55- }
56- if ($ this ->isValidDate ($ value )) {
57- $ condition [$ key ] = $ this ->timeZone ->convertConfigTimeToUtc ($ value );
52+ if ($ value = $ this ->isValidDate ($ value )) {
53+ $ condition [$ key ] = $ value ->setTimezone (new \DateTimeZone ('UTC ' ))->format ('Y-m-d H:i:s ' );
5854 }
5955 }
6056 }
@@ -72,19 +68,17 @@ public function aroundAddFieldToFilter(
7268 /**
7369 * Validate date string
7470 *
75- * @param string| DateTimeInterface $datetime
76- * @return bool
71+ * @param DateTimeInterface|string $datetime
72+ * @return mixed
7773 */
78- private function isValidDate ($ datetime ): bool
74+ private function isValidDate ($ datetime ): mixed
7975 {
8076 try {
81- $ dt = is_string ($ datetime ) ? new DateTime ($ datetime ) : $ datetime ;
82- if ($ dt instanceof DateTimeInterface) {
83- return true ;
84- }
77+ return $ datetime instanceof DateTimeInterface
78+ ? $ datetime : (is_string ($ datetime ) ? new DateTime ($ datetime ) : false );
79+
8580 } catch (\Exception $ e ) {
8681 return false ;
8782 }
88- return false ;
8983 }
9084}
You can’t perform that action at this time.
0 commit comments