MDL-49684 timezones: rewrite timezone support
This patch replaces all homegrown timezone stuff with standard PHP date/time code. The main change is the introduction of core_date class that returns normalised user and server timezones. From now on nobody should be using $CFG->timezone or $user->timezone directly! Other new features and fixes: * admins are prompted for timezone during install * editing of other users is finally fixed * timezones are displayed in user profile * new $this->setTimezone() in phpunit * time locale is now automatically reset in phpunit * timezone is now automatically reset in phpunit * phpunit has Australia/Perth as default timezone
This commit is contained in:
@@ -501,6 +501,19 @@ abstract class advanced_testcase extends PHPUnit_Framework_TestCase {
|
||||
self::setUser(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change server and default php timezones.
|
||||
*
|
||||
* @param string $servertimezone timezone to set in $CFG->timezone (not validated)
|
||||
* @param string $defaultphptimezone timezone to fake default php timezone (must be valid)
|
||||
*/
|
||||
public static function setTimezone($servertimezone = 'Australia/Perth', $defaultphptimezone = 'Australia/Perth') {
|
||||
global $CFG;
|
||||
$CFG->timezone = $servertimezone;
|
||||
core_date::phpunit_override_default_php_timezone($defaultphptimezone);
|
||||
core_date::set_default_server_timezone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get data generator
|
||||
* @static
|
||||
|
||||
Reference in New Issue
Block a user