File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed
app/code/Magento/Ui/Component/Form/Element/DataType
dev/tests/functional/tests/app/Magento/Backend/Test/Fixture/Source Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -60,16 +60,14 @@ public function __construct(
60
60
public function prepare ()
61
61
{
62
62
$ config = $ this ->getData ('config ' );
63
-
64
- if (!isset ($ config ['timeOffset ' ])) {
65
- $ config ['timeOffset ' ] = (new \DateTime (
66
- 'now ' ,
67
- new \DateTimeZone (
68
- $ this ->localeDate ->getConfigTimezone ()
69
- )
70
- ))->getOffset ();
63
+ if (!isset ($ config ['storeTimeZone ' ])) {
64
+ $ storeTimeZone = $ this ->localeDate ->getConfigTimezone ();
65
+ $ config ['storeTimeZone ' ] = $ storeTimeZone ;
71
66
}
72
-
67
+ // Set date format pattern by current locale
68
+ $ localeDateFormat = $ this ->localeDate ->getDateFormat ();
69
+ $ config ['options ' ]['dateFormat ' ] = $ localeDateFormat ;
70
+ $ config ['outputDateFormat ' ] = $ localeDateFormat ;
73
71
$ this ->setData ('config ' , $ config );
74
72
75
73
parent ::prepare ();
Original file line number Diff line number Diff line change 6
6
7
7
namespace Magento \Backend \Test \Fixture \Source ;
8
8
9
+ use Magento \Framework \App \ObjectManager ;
9
10
use Magento \Mtf \Fixture \DataSource ;
10
11
11
12
/**
12
13
* Class Date.
13
14
*
14
15
* Data keys:
15
16
* - pattern (Format a local time/date with delta, e.g. 'm/d/Y -3 days' = current day - 3 days)
17
+ * - apply_timezone (true if it is needed to apply timezone)
16
18
*/
17
19
class Date extends DataSource
18
20
{
@@ -35,7 +37,16 @@ public function __construct(array $params, $data = [])
35
37
if (!$ timestamp ) {
36
38
throw new \Exception ('Invalid date format for " ' . $ this ->params ['attribute_code ' ] . '" field ' );
37
39
}
38
- $ date = date (str_replace ($ delta , '' , $ data ['pattern ' ]), $ timestamp );
40
+ if (isset ($ data ['apply_timezone ' ]) && $ data ['apply_timezone ' ] === true ) {
41
+ $ timezone = ObjectManager::getInstance ()
42
+ ->get (\Magento \Framework \Stdlib \DateTime \TimezoneInterface::class);
43
+ $ date = new \DateTime ();
44
+ $ date ->setTimestamp ($ timestamp );
45
+ $ date ->setTimezone (new \DateTimeZone ($ timezone ->getConfigTimezone ()));
46
+ $ date = $ date ->format (str_replace ($ delta , '' , $ data ['pattern ' ]));
47
+ } else {
48
+ $ date = date (str_replace ($ delta , '' , $ data ['pattern ' ]), $ timestamp );
49
+ }
39
50
if (!$ date ) {
40
51
$ date = date ('m/d/Y ' );
41
52
}
You can’t perform that action at this time.
0 commit comments