From 8d120762dede4ca7c452fe8f901bb94205cadcd7 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Wed, 12 Nov 2014 12:13:46 +0100 Subject: [PATCH] Add timezone detection to `setupTimezone' in ApplicationBootstrap --- library/Icinga/Application/ApplicationBootstrap.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/library/Icinga/Application/ApplicationBootstrap.php b/library/Icinga/Application/ApplicationBootstrap.php index 7d22eaafa..b9ff9a440 100644 --- a/library/Icinga/Application/ApplicationBootstrap.php +++ b/library/Icinga/Application/ApplicationBootstrap.php @@ -14,6 +14,7 @@ use Icinga\Exception\NotReadableError; use Icinga\Application\Logger; use Icinga\Util\DateTimeFactory; use Icinga\Util\Translator; +use Icinga\Util\TimezoneDetect; use Icinga\Exception\IcingaException; /** @@ -441,7 +442,14 @@ abstract class ApplicationBootstrap */ 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) { $default = 'UTC'; }