Skip to content

Commit 26a7867

Browse files
sreichelfballiano
authored andcommitted
rebased to main
1 parent 90fefd7 commit 26a7867

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ Do not use 20.x.x if you need IE support.
226226

227227
- removed IE conditional comments, IE styles, IE scripts and IE eot files ([#1073](https://github.com/OpenMage/magento-lts/pull/1073))
228228
- removed frontend default themes (default, modern, iphone, german, french, blank, blue) ([#1600](https://github.com/OpenMage/magento-lts/pull/1600))
229-
- fixed incorrect datetime in customer block (`$useTimezone` parameter) ([#1525](https://github.com/OpenMage/magento-lts/pull/1525))
230229
- added redis as a valid option for `global/session_save` ([#1513](https://github.com/OpenMage/magento-lts/pull/1513))
231230
- reduce needless saves by avoiding setting `_hasDataChanges` flag ([#2066](https://github.com/OpenMage/magento-lts/pull/2066))
232231
- removed support for `global/sales/old_fields_map` defined in XML ([#921](https://github.com/OpenMage/magento-lts/pull/921))

app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,17 @@ public function getCreateDate()
8282
*/
8383
public function getStoreCreateDate()
8484
{
85-
if (!$this->getCustomer()->getCreatedAt()) {
85+
$date = $this->getCustomer()->getCreatedAt();
86+
if (!$date) {
8687
return null;
8788
}
88-
$date = Mage::app()->getLocale()->storeDate(
89-
$this->getCustomer()->getStoreId(),
90-
$this->getCustomer()->getCreatedAtTimestamp(),
91-
true
89+
90+
return $this->_getCoreHelper()->formatTimezoneDate(
91+
$date,
92+
Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM,
93+
true,
94+
false
9295
);
93-
return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
9496
}
9597

9698
public function getStoreCreateDateTimezone()
@@ -107,7 +109,7 @@ public function getStoreCreateDateTimezone()
107109
public function getLastLoginDate()
108110
{
109111
return ($date = $this->getCustomerLog()->getLoginAtTimestamp())
110-
? $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true, false)
112+
? Mage::helper('core')->formatTimezoneDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true, false)
111113
: Mage::helper('customer')->__('Never');
112114
}
113115

app/code/core/Mage/Core/Block/Abstract.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ public function setChild($alias, $block)
480480
public function unsetChild($alias)
481481
{
482482
if (isset($this->_children[$alias])) {
483+
/** @var Mage_Core_Block_Abstract $block */
483484
$block = $this->_children[$alias];
484485
$name = $block->getNameInLayout();
485486
unset($this->_children[$alias]);

app/code/core/Mage/Core/Helper/Data.php

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,33 +146,52 @@ public function formatPrice($price, $includeContainer = true)
146146
/**
147147
* Format date using current locale options and time zone.
148148
*
149-
* @param string|Zend_Date|null $date If empty, return current datetime.
149+
* @param string|Zend_Date|int|null $date If empty, return current local datetime.
150150
* @param string $format See Mage_Core_Model_Locale::FORMAT_TYPE_* constants
151151
* @param bool $showTime Whether to include time
152152
* @param bool $useTimezone Convert to local datetime?
153153
* @return string
154154
*/
155155
public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false, $useTimezone = true)
156156
{
157+
return $this->formatTimezoneDate($date, $format, $showTime);
158+
}
159+
160+
/**
161+
* Format date using current locale options and time zone.
162+
*
163+
* @param string|Zend_Date|null $date If empty, return current datetime.
164+
* @param string $format See Mage_Core_Model_Locale::FORMAT_TYPE_* constants
165+
* @param bool $showTime Whether to include time
166+
* @param bool $useTimezone Convert to local datetime?
167+
* @return string
168+
*/
169+
public function formatTimezoneDate(
170+
$date = null,
171+
string $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT,
172+
bool $showTime = false,
173+
bool $useTimezone = true
174+
) {
157175
if (!in_array($format, $this->_allowedFormats, true)) {
158176
return $date;
159177
}
178+
179+
if ($showTime) {
180+
$format = Mage::app()->getLocale()->getDateTimeFormat($format);
181+
} else {
182+
$format = Mage::app()->getLocale()->getDateFormat($format);
183+
}
184+
185+
$locale = Mage::app()->getLocale();
160186
if (empty($date)) {
161-
$date = Mage::app()->getLocale()->date(Mage::getSingleton('core/date')->gmtTimestamp(), null, null, $useTimezone);
187+
$date = $locale->date(Mage::getSingleton('core/date')->gmtTimestamp(), null, null, $useTimezone);
162188
} elseif (is_int($date)) {
163-
$date = Mage::app()->getLocale()->date($date, null, null, $useTimezone);
189+
$date = $locale->date($date, null, null, $useTimezone);
164190
} elseif (!$date instanceof Zend_Date) {
165-
if ($time = strtotime($date)) {
166-
$date = Mage::app()->getLocale()->date($time, null, null, $useTimezone);
167-
} else {
168-
return '';
169-
}
191+
return '';
170192
}
171193

172-
$format = $showTime
173-
? Mage::app()->getLocale()->getDateTimeFormat($format)
174-
: Mage::app()->getLocale()->getDateFormat($format);
175-
194+
$format = $showTime ? $locale->getDateTimeFormat($format) : $locale->getDateFormat($format);
176195
return $date->toString($format);
177196
}
178197

0 commit comments

Comments
 (0)