Add timezone detection to `setupTimezone' in ApplicationBootstrap

This commit is contained in:
Alexander Fuhr 2014-11-12 12:13:46 +01:00
parent 8d4e56a1fe
commit 8d120762de

View File

@ -14,6 +14,7 @@ use Icinga\Exception\NotReadableError;
use Icinga\Application\Logger; use Icinga\Application\Logger;
use Icinga\Util\DateTimeFactory; use Icinga\Util\DateTimeFactory;
use Icinga\Util\Translator; use Icinga\Util\Translator;
use Icinga\Util\TimezoneDetect;
use Icinga\Exception\IcingaException; use Icinga\Exception\IcingaException;
/** /**
@ -441,7 +442,14 @@ abstract class ApplicationBootstrap
*/ */
protected function setupTimezone() protected function setupTimezone()
{ {
$default = @date_default_timezone_get(); $detect = new TimezoneDetect();
if ($detect->success()) {
$default = $detect->getTimezoneName();
} else {
$default = @date_default_timezone_get();
}
if (! $default) { if (! $default) {
$default = 'UTC'; $default = 'UTC';
} }