Commit c8a9ed80 by Vladimir Zbrailov

prevent changing public timezone

parent 230f40c8
......@@ -69,6 +69,11 @@ class Formatter extends Component
public $thousandSeparator;
/**
* @var \DateTimeZone
*/
private $_timeZone;
/**
* Initializes the component.
*/
public function init()
......@@ -77,9 +82,9 @@ class Formatter extends Component
$this->timeZone = Yii::$app->timeZone;
}
if (is_string($this->timeZone)) {
$this->timeZone = new \DateTimeZone($this->timeZone);
} elseif ($this->timeZone instanceof IntlTimeZone) {
$this->timeZone = $this->timeZone->toDateTimeZone();
$this->_timeZone = new \DateTimeZone($this->timeZone);
} elseif ($this->_timeZone instanceof IntlTimeZone) {
$this->_timeZone = $this->timeZone->toDateTimeZone();
}
if (empty($this->booleanFormat)) {
......@@ -351,7 +356,7 @@ class Formatter extends Component
{
$date = new DateTime();
$date->setTimestamp($value);
$date->setTimezone($this->timeZone);
$date->setTimezone($this->_timeZone);
return $date->format($format);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment