Skip to content

Commit 16a7f0b

Browse files
committed
Use @inheritdoc and revert back code change
1 parent da580fc commit 16a7f0b

File tree

1 file changed

+15
-110
lines changed

1 file changed

+15
-110
lines changed

lib/internal/Magento/Framework/Stdlib/DateTime/Timezone.php

Lines changed: 15 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -85,31 +85,23 @@ public function __construct(
8585
}
8686

8787
/**
88-
* Return path to default timezone
89-
*
90-
* @return string
88+
* @inheritdoc
9189
*/
9290
public function getDefaultTimezonePath()
9391
{
9492
return $this->_defaultTimezonePath;
9593
}
9694

9795
/**
98-
* Retrieve timezone code
99-
*
100-
* @return string
96+
* @inheritdoc
10197
*/
10298
public function getDefaultTimezone()
10399
{
104100
return 'UTC';
105101
}
106102

107103
/**
108-
* Gets the scope config timezone
109-
*
110-
* @param string $scopeType
111-
* @param string $scopeCode
112-
* @return string
104+
* @inheritdoc
113105
*/
114106
public function getConfigTimezone($scopeType = null, $scopeCode = null)
115107
{
@@ -121,10 +113,7 @@ public function getConfigTimezone($scopeType = null, $scopeCode = null)
121113
}
122114

123115
/**
124-
* Retrieve ISO date format
125-
*
126-
* @param int $type
127-
* @return string
116+
* @inheritdoc
128117
*/
129118
public function getDateFormat($type = \IntlDateFormatter::SHORT)
130119
{
@@ -136,9 +125,7 @@ public function getDateFormat($type = \IntlDateFormatter::SHORT)
136125
}
137126

138127
/**
139-
* Retrieve short date format with 4-digit year
140-
*
141-
* @return string
128+
* @inheritdoc
142129
*/
143130
public function getDateFormatWithLongYear()
144131
{
@@ -150,10 +137,7 @@ public function getDateFormatWithLongYear()
150137
}
151138

152139
/**
153-
* Retrieve ISO time format
154-
*
155-
* @param string $type
156-
* @return string
140+
* @inheritdoc
157141
*/
158142
public function getTimeFormat($type = \IntlDateFormatter::SHORT)
159143
{
@@ -165,24 +149,15 @@ public function getTimeFormat($type = \IntlDateFormatter::SHORT)
165149
}
166150

167151
/**
168-
* Retrieve ISO datetime format
169-
*
170-
* @param string $type
171-
* @return string
152+
* @inheritdoc
172153
*/
173154
public function getDateTimeFormat($type)
174155
{
175156
return $this->getDateFormat($type) . ' ' . $this->getTimeFormat($type);
176157
}
177158

178159
/**
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
186161
*/
187162
public function date($date = null, $locale = null, $useTimezone = true, $includeTime = true)
188163
{
@@ -216,12 +191,7 @@ public function date($date = null, $locale = null, $useTimezone = true, $include
216191
}
217192

218193
/**
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
225195
*/
226196
public function scopeDate($scope = null, $date = null, $includeTime = false)
227197
{
@@ -234,12 +204,7 @@ public function scopeDate($scope = null, $date = null, $includeTime = false)
234204
}
235205

236206
/**
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
243208
*/
244209
public function formatDate($date = null, $format = \IntlDateFormatter::SHORT, $showTime = false)
245210
{
@@ -253,12 +218,7 @@ public function formatDate($date = null, $format = \IntlDateFormatter::SHORT, $s
253218
}
254219

255220
/**
256-
* Get scope timestamp
257-
*
258-
* Timestamp will be built with scope timezone settings
259-
*
260-
* @param mixed $scope
261-
* @return int
221+
* @inheritdoc
262222
*/
263223
public function scopeTimeStamp($scope = null)
264224
{
@@ -271,12 +231,7 @@ public function scopeTimeStamp($scope = null)
271231
}
272232

273233
/**
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
280235
*/
281236
public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null)
282237
{
@@ -302,13 +257,7 @@ public function isScopeDateInInterval($scope, $dateFrom = null, $dateTo = null)
302257
}
303258

304259
/**
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
312261
*/
313262
public function formatDateTime(
314263
$date,
@@ -344,56 +293,15 @@ public function formatDateTime(
344293
}
345294

346295
/**
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
356297
*/
357298
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)
375299
{
376300
if (!($date instanceof \DateTimeInterface)) {
377301
if ($date instanceof \DateTimeImmutable) {
378302
$date = new \DateTime($date->format('Y-m-d H:i:s'), new \DateTimeZone($this->getConfigTimezone()));
379303
} 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()));
397305
}
398306
} else {
399307
if ($date->getTimezone()->getName() !== $this->getConfigTimezone()) {
@@ -405,13 +313,10 @@ public function convertConfigTimeToUtcWithPattern($date, $format = 'Y-m-d H:i:s'
405313
);
406314
}
407315
}
408-
409316
$date->setTimezone(new \DateTimeZone('UTC'));
410-
411317
return $date->format($format);
412318
}
413319

414-
415320
/**
416321
* Retrieve date with time
417322
*

0 commit comments

Comments
 (0)