Merge pull request #654 from nextcloud/enh/621/timezone

allow to change the timezone
This commit is contained in:
Simon L 2022-05-23 15:45:58 +02:00 committed by GitHub
commit b4a8322a1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 102 additions and 10 deletions

View file

@ -483,4 +483,33 @@ class ConfigurationManager
}
return false;
}
public function GetTimezone() : string {
$config = $this->GetConfig();
if(!isset($config['timezone'])) {
$config['timezone'] = '';
}
return $config['timezone'];
}
public function SetTimezone(string $timezone) : void {
if ($timezone === "") {
throw new InvalidSettingConfigurationException("The timezone must not be empty!");
}
if (!preg_match("#[a-zA-Z0-9_-/+]+$#", $timezone)) {
throw new InvalidSettingConfigurationException("The entered timezone does not seem to be a valid timezone!");
}
$config = $this->GetConfig();
$config['timezone'] = $timezone;
$this->WriteConfig($config);
}
public function DeleteTimezone() : void {
$config = $this->GetConfig();
$config['timezone'] = '';
$this->WriteConfig($config);
}
}