Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ Do not use 20.x.x if you need IE support.

- removed IE conditional comments, IE styles, IE scripts and IE eot files ([#1073](https://github.com/OpenMage/magento-lts/pull/1073))
- removed frontend default themes (default, modern, iphone, german, french, blank, blue) ([#1600](https://github.com/OpenMage/magento-lts/pull/1600))
- fixed incorrect datetime in customer block (`$useTimezone` parameter) ([#1525](https://github.com/OpenMage/magento-lts/pull/1525))
- added redis as a valid option for `global/session_save` ([#1513](https://github.com/OpenMage/magento-lts/pull/1513))
- reduce needless saves by avoiding setting `_hasDataChanges` flag ([#2066](https://github.com/OpenMage/magento-lts/pull/2066))
- removed support for `global/sales/old_fields_map` defined in XML ([#921](https://github.com/OpenMage/magento-lts/pull/921))
Expand Down
16 changes: 9 additions & 7 deletions app/code/core/Mage/Adminhtml/Block/Customer/Edit/Tab/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,17 @@ public function getCreateDate()
*/
public function getStoreCreateDate()
{
if (!$this->getCustomer()->getCreatedAt()) {
$date = $this->getCustomer()->getCreatedAt();
if (!$date) {
return null;
}
$date = Mage::app()->getLocale()->storeDate(
$this->getCustomer()->getStoreId(),
$this->getCustomer()->getCreatedAtTimestamp(),
true

return Mage::helper('core')->formatTimezoneDate(
$date,
Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM,
true,
false
);
return $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true);
}

public function getStoreCreateDateTimezone()
Expand All @@ -107,7 +109,7 @@ public function getStoreCreateDateTimezone()
public function getLastLoginDate()
{
return ($date = $this->getCustomerLog()->getLoginAtTimestamp())
? $this->formatDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true, false)
? Mage::helper('core')->formatTimezoneDate($date, Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true, false)
: Mage::helper('customer')->__('Never');
}

Expand Down
1 change: 1 addition & 0 deletions app/code/core/Mage/Core/Block/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ public function setChild($alias, $block)
public function unsetChild($alias)
{
if (isset($this->_children[$alias])) {
/** @var Mage_Core_Block_Abstract $block */
$block = $this->_children[$alias];
$name = $block->getNameInLayout();
unset($this->_children[$alias]);
Expand Down
49 changes: 34 additions & 15 deletions app/code/core/Mage/Core/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,33 +146,52 @@ public function formatPrice($price, $includeContainer = true)
/**
* Format date using current locale options and time zone.
*
* @param string|Zend_Date|null $date If empty, return current datetime.
* @param string $format See Mage_Core_Model_Locale::FORMAT_TYPE_* constants
* @param bool $showTime Whether to include time
* @param bool $useTimezone Convert to local datetime?
* @param string|Zend_Date|int|null $date If empty, return current local datetime.
* @param string $format See Mage_Core_Model_Locale::FORMAT_TYPE_* constants
* @param bool $showTime Whether to include time
* @param bool $useTimezone Convert to local datetime?
* @return string
*/
public function formatDate($date = null, $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT, $showTime = false, $useTimezone = true)
{
return $this->formatTimezoneDate($date, $format, $showTime);
}

/**
* Format date using current locale options and time zone.
*
* @param string|Zend_Date|null $date If empty, return current datetime.
* @param string $format See Mage_Core_Model_Locale::FORMAT_TYPE_* constants
* @param bool $showTime Whether to include time
* @param bool $useTimezone Convert to local datetime?
* @return string
*/
public function formatTimezoneDate(
$date = null,
string $format = Mage_Core_Model_Locale::FORMAT_TYPE_SHORT,
bool $showTime = false,
bool $useTimezone = true
) {
if (!in_array($format, $this->_allowedFormats, true)) {
return $date;
}

if ($showTime) {
$format = Mage::app()->getLocale()->getDateTimeFormat($format);
} else {
$format = Mage::app()->getLocale()->getDateFormat($format);
}

$locale = Mage::app()->getLocale();
if (empty($date)) {
$date = Mage::app()->getLocale()->date(Mage::getSingleton('core/date')->gmtTimestamp(), null, null, $useTimezone);
$date = $locale->date(Mage::getSingleton('core/date')->gmtTimestamp(), null, null, $useTimezone);
} elseif (is_int($date)) {
$date = Mage::app()->getLocale()->date($date, null, null, $useTimezone);
$date = $locale->date($date, null, null, $useTimezone);
} elseif (!$date instanceof Zend_Date) {
if ($time = strtotime($date)) {
$date = Mage::app()->getLocale()->date($time, null, null, $useTimezone);
} else {
return '';
}
return '';
}

$format = $showTime
? Mage::app()->getLocale()->getDateTimeFormat($format)
: Mage::app()->getLocale()->getDateFormat($format);

$format = $showTime ? $locale->getDateTimeFormat($format) : $locale->getDateFormat($format);
return $date->toString($format);
}

Expand Down