deprecate App::ge DI::app(),tTimeZone() and App::setTimezone()

pull/14542/head
Art4 2024-11-06 07:52:46 +00:00
parent 81b0bab084
commit 4f16bbe5f5
2 changed files with 8 additions and 5 deletions

View File

@ -172,23 +172,24 @@ class App
/** /**
* Set the timezone * Set the timezone
* *
* @deprecated 2024.12 Use AppHelper::setTimeZone() instead
*
* @param string $timezone A valid time zone identifier, see https://www.php.net/manual/en/timezones.php * @param string $timezone A valid time zone identifier, see https://www.php.net/manual/en/timezones.php
* @return void * @return void
*/ */
public function setTimeZone(string $timezone) public function setTimeZone(string $timezone)
{ {
$this->timezone = (new \DateTimeZone($timezone))->getName(); DI::apphelper()->setTimeZone($timezone);
DateTimeFormat::setLocalTimeZone($this->timezone);
} }
/** /**
* Get the timezone * Get the timezone
* *
* @return int * @deprecated 2024.12 Use AppHelper::getTimeZone() instead
*/ */
public function getTimeZone(): string public function getTimeZone(): string
{ {
return $this->timezone; return DI::apphelper()->getTimeZone();
} }
/** /**
@ -364,7 +365,7 @@ class App
$timezone = $default_timezone ?? '' ?: 'UTC'; $timezone = $default_timezone ?? '' ?: 'UTC';
} }
$this->setTimeZone($timezone); DI::apphelper()->setTimeZone($timezone);
} }
/** /**

View File

@ -71,6 +71,8 @@ abstract class DI
// //
/** /**
* @deprecated 2024.12 use DI::apphelper() instead
*
* @return App * @return App
*/ */
public static function app() public static function app()