Commit c8a9ed80 by Vladimir Zbrailov

prevent changing public timezone

parent 230f40c8
...@@ -69,6 +69,11 @@ class Formatter extends Component ...@@ -69,6 +69,11 @@ class Formatter extends Component
public $thousandSeparator; public $thousandSeparator;
/** /**
* @var \DateTimeZone
*/
private $_timeZone;
/**
* Initializes the component. * Initializes the component.
*/ */
public function init() public function init()
...@@ -77,9 +82,9 @@ class Formatter extends Component ...@@ -77,9 +82,9 @@ class Formatter extends Component
$this->timeZone = Yii::$app->timeZone; $this->timeZone = Yii::$app->timeZone;
} }
if (is_string($this->timeZone)) { if (is_string($this->timeZone)) {
$this->timeZone = new \DateTimeZone($this->timeZone); $this->_timeZone = new \DateTimeZone($this->timeZone);
} elseif ($this->timeZone instanceof IntlTimeZone) { } elseif ($this->_timeZone instanceof IntlTimeZone) {
$this->timeZone = $this->timeZone->toDateTimeZone(); $this->_timeZone = $this->timeZone->toDateTimeZone();
} }
if (empty($this->booleanFormat)) { if (empty($this->booleanFormat)) {
...@@ -351,7 +356,7 @@ class Formatter extends Component ...@@ -351,7 +356,7 @@ class Formatter extends Component
{ {
$date = new DateTime(); $date = new DateTime();
$date->setTimestamp($value); $date->setTimestamp($value);
$date->setTimezone($this->timeZone); $date->setTimezone($this->_timeZone);
return $date->format($format); 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