@@ -85,31 +85,23 @@ public function __construct(
85
85
}
86
86
87
87
/**
88
- * Return path to default timezone
89
- *
90
- * @return string
88
+ * @inheritdoc
91
89
*/
92
90
public function getDefaultTimezonePath ()
93
91
{
94
92
return $ this ->_defaultTimezonePath ;
95
93
}
96
94
97
95
/**
98
- * Retrieve timezone code
99
- *
100
- * @return string
96
+ * @inheritdoc
101
97
*/
102
98
public function getDefaultTimezone ()
103
99
{
104
100
return 'UTC ' ;
105
101
}
106
102
107
103
/**
108
- * Gets the scope config timezone
109
- *
110
- * @param string $scopeType
111
- * @param string $scopeCode
112
- * @return string
104
+ * @inheritdoc
113
105
*/
114
106
public function getConfigTimezone ($ scopeType = null , $ scopeCode = null )
115
107
{
@@ -121,10 +113,7 @@ public function getConfigTimezone($scopeType = null, $scopeCode = null)
121
113
}
122
114
123
115
/**
124
- * Retrieve ISO date format
125
- *
126
- * @param int $type
127
- * @return string
116
+ * @inheritdoc
128
117
*/
129
118
public function getDateFormat ($ type = \IntlDateFormatter::SHORT )
130
119
{
@@ -136,9 +125,7 @@ public function getDateFormat($type = \IntlDateFormatter::SHORT)
136
125
}
137
126
138
127
/**
139
- * Retrieve short date format with 4-digit year
140
- *
141
- * @return string
128
+ * @inheritdoc
142
129
*/
143
130
public function getDateFormatWithLongYear ()
144
131
{
@@ -150,10 +137,7 @@ public function getDateFormatWithLongYear()
150
137
}
151
138
152
139
/**
153
- * Retrieve ISO time format
154
- *
155
- * @param string $type
156
- * @return string
140
+ * @inheritdoc
157
141
*/
158
142
public function getTimeFormat ($ type = \IntlDateFormatter::SHORT )
159
143
{
@@ -165,24 +149,15 @@ public function getTimeFormat($type = \IntlDateFormatter::SHORT)
165
149
}
166
150
167
151
/**
168
- * Retrieve ISO datetime format
169
- *
170
- * @param string $type
171
- * @return string
152
+ * @inheritdoc
172
153
*/
173
154
public function getDateTimeFormat ($ type )
174
155
{
175
156
return $ this ->getDateFormat ($ type ) . ' ' . $ this ->getTimeFormat ($ type );
176
157
}
177
158
178
159
/**
179
- * Create \DateTime object for current locale
180
- *
181
- * @param mixed $date
182
- * @param string $locale
183
- * @param bool $useTimezone
184
- * @param bool $includeTime
185
- * @return \DateTime
160
+ * @inheritdoc
186
161
*/
187
162
public function date ($ date = null , $ locale = null , $ useTimezone = true , $ includeTime = true )
188
163
{
@@ -216,12 +191,7 @@ public function date($date = null, $locale = null, $useTimezone = true, $include
216
191
}
217
192
218
193
/**
219
- * Create \DateTime object with date converted to scope timezone and scope Locale
220
- *
221
- * @param mixed $scope Information about scope
222
- * @param string|integer|\DateTime|array|null $date date in UTC
223
- * @param boolean $includeTime flag for including time to date
224
- * @return \DateTime
194
+ * @inheritdoc
225
195
*/
226
196
public function scopeDate ($ scope = null , $ date = null , $ includeTime = false )
227
197
{
@@ -234,12 +204,7 @@ public function scopeDate($scope = null, $date = null, $includeTime = false)
234
204
}
235
205
236
206
/**
237
- * Format date using current locale options and time zone.
238
- *
239
- * @param \DateTime|null $date
240
- * @param int $format
241
- * @param bool $showTime
242
- * @return string
207
+ * @inheritdoc
243
208
*/
244
209
public function formatDate ($ date = null , $ format = \IntlDateFormatter::SHORT , $ showTime = false )
245
210
{
@@ -253,12 +218,7 @@ public function formatDate($date = null, $format = \IntlDateFormatter::SHORT, $s
253
218
}
254
219
255
220
/**
256
- * Get scope timestamp
257
- *
258
- * Timestamp will be built with scope timezone settings
259
- *
260
- * @param mixed $scope
261
- * @return int
221
+ * @inheritdoc
262
222
*/
263
223
public function scopeTimeStamp ($ scope = null )
264
224
{
@@ -271,12 +231,7 @@ public function scopeTimeStamp($scope = null)
271
231
}
272
232
273
233
/**
274
- * Checks if current date of the given scope (in the scope timezone) is within the range
275
- *
276
- * @param int|string|\Magento\Framework\App\ScopeInterface $scope
277
- * @param string|null $dateFrom
278
- * @param string|null $dateTo
279
- * @return bool
234
+ * @inheritdoc
280
235
*/
281
236
public function isScopeDateInInterval ($ scope , $ dateFrom = null , $ dateTo = null )
282
237
{
@@ -302,13 +257,7 @@ public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null)
302
257
}
303
258
304
259
/**
305
- * @param string|\DateTimeInterface $date
306
- * @param int $dateType
307
- * @param int $timeType
308
- * @param string|null $locale
309
- * @param string|null $timezone
310
- * @param string|null $pattern
311
- * @return string
260
+ * @inheritdoc
312
261
*/
313
262
public function formatDateTime (
314
263
$ date ,
@@ -344,56 +293,15 @@ public function formatDateTime(
344
293
}
345
294
346
295
/**
347
- * Convert date from config timezone to Utc.
348
- *
349
- * If pass \DateTime object as argument be sure that timezone is the same with config timezone
350
- *
351
- * @param string|\DateTimeInterface $date
352
- * @param string $format
353
- * @throws LocalizedException
354
- * @return string
355
- * @deprecated
296
+ * @inheritdoc
356
297
*/
357
298
public function convertConfigTimeToUtc ($ date , $ format = 'Y-m-d H:i:s ' )
358
- {
359
- return $ this ->convertConfigTimeToUtcWithPattern ($ date , $ format );
360
- }
361
-
362
- /**
363
- * Convert date from config timezone to Utc.
364
- *
365
- * If pass \DateTime object as argument be sure that timezone is the same with config timezone
366
- *
367
- * @param string|\DateTimeInterface $date
368
- * @param string $format
369
- * @param string $pattern
370
- * @throws LocalizedException
371
- * @return string
372
- * @deprecated
373
- */
374
- public function convertConfigTimeToUtcWithPattern ($ date , $ format = 'Y-m-d H:i:s ' , $ pattern = null )
375
299
{
376
300
if (!($ date instanceof \DateTimeInterface)) {
377
301
if ($ date instanceof \DateTimeImmutable) {
378
302
$ date = new \DateTime ($ date ->format ('Y-m-d H:i:s ' ), new \DateTimeZone ($ this ->getConfigTimezone ()));
379
303
} else {
380
- $ locale = $ this ->_localeResolver ->getLocale ();
381
- if ($ locale === null ) {
382
- $ pattern = 'Y-M-dd HH:mm:ss ' ;
383
- }
384
- $ formatter = new \IntlDateFormatter (
385
- $ locale ,
386
- \IntlDateFormatter::MEDIUM ,
387
- \IntlDateFormatter::MEDIUM ,
388
- $ this ->getConfigTimezone (),
389
- null ,
390
- $ pattern
391
- );
392
- $ unixTime = $ formatter ->parse ($ date );
393
- $ dateTime = new DateTime ($ this );
394
-
395
- $ dateUniversal = $ dateTime ->gmtDate (null , $ unixTime );
396
- $ date = new \DateTime ($ dateUniversal , new \DateTimeZone ($ this ->getConfigTimezone ()));
304
+ $ date = new \DateTime ($ date , new \DateTimeZone ($ this ->getConfigTimezone ()));
397
305
}
398
306
} else {
399
307
if ($ date ->getTimezone ()->getName () !== $ this ->getConfigTimezone ()) {
@@ -405,13 +313,10 @@ public function convertConfigTimeToUtcWithPattern($date, $format = 'Y-m-d H:i:s'
405
313
);
406
314
}
407
315
}
408
-
409
316
$ date ->setTimezone (new \DateTimeZone ('UTC ' ));
410
-
411
317
return $ date ->format ($ format );
412
318
}
413
319
414
-
415
320
/**
416
321
* Retrieve date with time
417
322
*
0 commit comments