[icinga-checkins] icinga.org: icingaweb2/feature/redesign-7144: Add timezone detection to `setupTimezone' in ApplicationBootstrap

git at icinga.org git at icinga.org
Thu Nov 13 21:22:53 CET 2014


Module: icingaweb2
Branch: feature/redesign-7144
Commit: 8d120762dede4ca7c452fe8f901bb94205cadcd7
URL:    https://git.icinga.org/?p=icingaweb2.git;a=commit;h=8d120762dede4ca7c452fe8f901bb94205cadcd7

Author: Alexander Fuhr <alexander.fuhr at netways.de>
Date:   Wed Nov 12 12:13:46 2014 +0100

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 7d22eaa..b9ff9a4 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';
         }



More information about the icinga-checkins mailing list