File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
lib/internal/Magento/Framework/Data/Form/Element Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -53,6 +53,19 @@ public function __construct(
53
53
}
54
54
}
55
55
56
+ /**
57
+ * Check if a string is a date value
58
+ *
59
+ * @param string $value
60
+ * @return bool
61
+ */
62
+ private function isDate (string $ value ): bool
63
+ {
64
+ $ date = date_parse ($ value );
65
+
66
+ return !empty ($ date ['year ' ]) && !empty ($ date ['month ' ]) && !empty ($ date ['day ' ]);
67
+ }
68
+
56
69
/**
57
70
* If script executes on x64 system, converts large numeric values to timestamp limit
58
71
*
@@ -85,13 +98,13 @@ public function setValue($value)
85
98
$ this ->_value = $ value ;
86
99
return $ this ;
87
100
}
88
-
89
101
try {
90
102
if (preg_match ('/^[0-9]+$/ ' , $ value )) {
91
103
$ this ->_value = (new \DateTime ())->setTimestamp ($ this ->_toTimestamp ($ value ));
104
+ } else if (is_string ($ value ) && $ this ->isDate ($ value )) {
105
+ $ this ->_value = new \DateTime ($ value , new \DateTimeZone ($ this ->localeDate ->getConfigTimezone ()));
92
106
} else {
93
- $ this ->_value = new \DateTime ($ value );
94
- $ this ->_value ->setTimezone (new \DateTimeZone ($ this ->localeDate ->getConfigTimezone ()));
107
+ $ this ->_value = '' ;
95
108
}
96
109
} catch (\Exception $ e ) {
97
110
$ this ->_value = '' ;
You can’t perform that action at this time.
0 commit comments