Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Trim system timezone output
Browse files Browse the repository at this point in the history
  • Loading branch information
msjyoo committed Oct 5, 2014
1 parent fae330d commit d4c75ce
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/pocketmine/PocketMine.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function dummy(){
$logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI);

if(!ini_get("date.timezone")){
if(($timezone = trim(detect_system_timezone())) and date_default_timezone_set($timezone)){
if(($timezone = detect_system_timezone()) and date_default_timezone_set($timezone)){
//Success! Timezone has already been set and validated in the if statement.
//This here is just for redundancy just in case some stupid program wants to read timezone data from the ini.
ini_set("date.timezone", $timezone);
Expand Down Expand Up @@ -171,7 +171,7 @@ function detect_system_timezone(){

exec("systeminfo", $output);

$string = implode("\n", $output);
$string = trim(implode("\n", $output));

//Detect the Time Zone string in systeminfo
preg_match($regex, $string, $matches);
Expand All @@ -189,15 +189,15 @@ function detect_system_timezone(){
if(file_exists('/etc/timezone')){
$data = file_get_contents('/etc/timezone');
if($data){
return $data;
return trim($data);
}
}

// RHEL / CentOS
if(file_exists('/etc/sysconfig/clock')){
$data = parse_ini_file('/etc/sysconfig/clock');
if(!empty($data['ZONE'])){
return $data['ZONE'];
return trim($data['ZONE']);
}
}

Expand All @@ -216,7 +216,7 @@ function detect_system_timezone(){
$filename = readlink('/etc/localtime');
if(strpos($filename, '/usr/share/zoneinfo/') === 0){
$timezone = substr($filename, 20);
return $timezone;
return trim($timezone);
}
}

Expand Down

0 comments on commit d4c75ce

Please sign in to comment.