Skip to content

Commit 6f2a589

Browse files
anzinxmav
authored andcommitted
Reverted change Date.php
1 parent 0ddc741 commit 6f2a589

File tree

1 file changed

+3
-48
lines changed
  • lib/internal/Magento/Framework/View/Element/Html

1 file changed

+3
-48
lines changed

lib/internal/Magento/Framework/View/Element/Html/Date.php

Lines changed: 3 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,13 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
76
namespace Magento\Framework\View\Element\Html;
87

98
/**
109
* Date element block
1110
*/
1211
class Date extends \Magento\Framework\View\Element\Template
1312
{
14-
/**
15-
* Date format not supported function date().
16-
*/
17-
private const DATE_FORMAT_NOT_SUPPORTED = [
18-
'%a', '%A', '%d', '%e', '%u', '%w', '%W', '%b', '%h', '%B', '%m', '%y', '%Y', '%D', '%F', '%x', '%n', '%t',
19-
'%H', '%k', '%I', '%l', '%M', '%p', '%P', '%r', '%R', '%S', '%T', '%X', '%z', '%Z', '%c', '%s', '%g', '%G', '%%'
20-
];
21-
22-
/**
23-
* Date format supported by function date().
24-
*/
25-
private const DATE_FORMAT_SUPPORTED = [
26-
'D', 'l', 'd', 'j', 'N', 'w', 'W', 'M', 'M', 'F', 'm', 'y', 'Y', 'm/d/y', 'Y-m-d', 'm/d/y',"\n","\t", 'H', 'G',
27-
'h', 'g', 'i', 'A', 'a', 'h:i:s A', 'H:i', 's', 'H:i:s', 'H:i:s', 'O', 'T', 'D M j H:i:s Y', 'U', 'y', 'Y', '%'
28-
];
29-
3013
/**
3114
* Render block HTML
3215
*
@@ -93,48 +76,20 @@ protected function _toHtml()
9376
public function getEscapedValue()
9477
{
9578
if ($this->getFormat() && $this->getValue()) {
96-
return $this->getDateByFormat($this->getFormat(), strtotime($this->getValue()));
79+
return strftime($this->getFormat(), strtotime($this->getValue()));
9780
}
9881
return $this->escapeHtml($this->getValue());
9982
}
10083

10184
/**
10285
* Produce and return block's html output
10386
*
87+
* {@inheritdoc}
88+
*
10489
* @return string
10590
*/
10691
public function getHtml()
10792
{
10893
return $this->toHtml();
10994
}
110-
111-
/**
112-
* Method to get date by format.
113-
*
114-
* @param string $format
115-
* @param int $timestamp
116-
*
117-
* @return string
118-
*/
119-
private function getDateByFormat(string $format, int $timestamp): string
120-
{
121-
$format = str_replace(self::DATE_FORMAT_NOT_SUPPORTED, self::DATE_FORMAT_SUPPORTED, $format);
122-
123-
if (strpos($format, '%') !== false) {
124-
$unsupportedData = ['%U', '%V', '%C'];
125-
126-
foreach ($unsupportedData as $unsupported) {
127-
if (strpos($format, $unsupported) !== false) {
128-
if ($unsupported === '%C') {
129-
$format = str_replace($unsupported, round(date("Y", $timestamp) / 100), $format);
130-
131-
continue;
132-
}
133-
$format = str_replace($unsupported, date("W", strtotime("-1 day", $timestamp)), $format);
134-
}
135-
}
136-
}
137-
138-
return date($format, $timestamp);
139-
}
14095
}

0 commit comments

Comments
 (0)