@@ -109,6 +109,13 @@ class Queue extends \Magento\Framework\Model\AbstractModel implements TemplateTy
109
109
*/
110
110
protected $ _transportBuilder ;
111
111
112
+ /**
113
+ * Timezone library.
114
+ *
115
+ * @var \Magento\Framework\Stdlib\DateTime\Timezone
116
+ */
117
+ private $ timezone ;
118
+
112
119
/**
113
120
* @param \Magento\Framework\Model\Context $context
114
121
* @param \Magento\Framework\Registry $registry
@@ -120,6 +127,7 @@ class Queue extends \Magento\Framework\Model\AbstractModel implements TemplateTy
120
127
* @param \Magento\Newsletter\Model\Queue\TransportBuilder $transportBuilder
121
128
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
122
129
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
130
+ * @param \Magento\Framework\Stdlib\DateTime\Timezone $timezone
123
131
* @param array $data
124
132
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
125
133
*/
@@ -134,6 +142,7 @@ public function __construct(
134
142
\Magento \Newsletter \Model \Queue \TransportBuilder $ transportBuilder ,
135
143
\Magento \Framework \Model \ResourceModel \AbstractResource $ resource = null ,
136
144
\Magento \Framework \Data \Collection \AbstractDb $ resourceCollection = null ,
145
+ \Magento \Framework \Stdlib \DateTime \Timezone $ timezone = null ,
137
146
array $ data = []
138
147
) {
139
148
parent ::__construct (
@@ -149,6 +158,9 @@ public function __construct(
149
158
$ this ->_problemFactory = $ problemFactory ;
150
159
$ this ->_subscribersCollection = $ subscriberCollectionFactory ->create ();
151
160
$ this ->_transportBuilder = $ transportBuilder ;
161
+ $ this ->timezone = $ timezone ?: \Magento \Framework \App \ObjectManager::getInstance ()->get (
162
+ \Magento \Framework \Stdlib \DateTime \Timezone::class
163
+ );
152
164
}
153
165
154
166
/**
@@ -183,8 +195,7 @@ public function setQueueStartAtByString($startAt)
183
195
if ($ startAt === null || $ startAt == '' ) {
184
196
$ this ->setQueueStartAt (null );
185
197
} else {
186
- $ time = (new \DateTime ($ startAt ))->getTimestamp ();
187
- $ this ->setQueueStartAt ($ this ->_date ->gmtDate (null , $ time ));
198
+ $ this ->setQueueStartAt ($ this ->timezone ->convertConfigTimeToUtc ($ startAt ));
188
199
}
189
200
return $ this ;
190
201
}
0 commit comments