Skip to content
Draft
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
12 changes: 10 additions & 2 deletions app/code/core/Mage/Core/Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@

use Carbon\Carbon;
use Carbon\Exceptions\InvalidFormatException;
use Carbon\FactoryImmutable;
use Psr\Clock\ClockInterface;

/**
* Core data helper
*
* @package Mage_Core
*/
class Mage_Core_Helper_Data extends Mage_Core_Helper_Abstract
class Mage_Core_Helper_Data extends Mage_Core_Helper_Abstract implements ClockInterface
{
public const XML_PATH_DEFAULT_COUNTRY = 'general/country/default';

Expand Down Expand Up @@ -230,7 +232,7 @@ public function formatTime($time = null, $format = Mage_Core_Model_Locale::FORMA

$locale = Mage::app()->getLocale();
if (is_null($time)) {
$date = $locale->date(Carbon::now()->getTimestamp());
$date = $locale->date($this->now()->getTimestamp());
} elseif ($time instanceof Zend_Date) {
$date = $time;
} else {
Expand Down Expand Up @@ -1097,4 +1099,10 @@ public function recordRateLimitHit(): void
Mage::app()->saveCache(1, $cacheTag, ['brute_force'], Mage::getStoreConfig('system/rate_limit/timeframe'));
}
}

public function now(): \DateTimeImmutable
{
static $clock = new FactoryImmutable();
return $clock->now();
}
}
Loading