From a026de0028e415d2d79e18749b0b7dca8e0c977f Mon Sep 17 00:00:00 2001 From: Mark Unwin Date: Wed, 14 Feb 2024 09:57:30 +1000 Subject: [PATCH] Add some old code from 4.x to automatically derive timezone from the OS. Commented out, in testing, for now. --- app/Config/App.php | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/app/Config/App.php b/app/Config/App.php index 88f04a906..747bcb043 100755 --- a/app/Config/App.php +++ b/app/Config/App.php @@ -473,5 +473,29 @@ public function __construct() if (!empty($_SERVER['CI_ENVIRONMENT']) and $_SERVER['CI_ENVIRONMENT'] === 'development') { $this->CSPEnabled = false; } + + // $timezone = ''; + // $default = 'UTC'; + // if ((string) php_uname('s') === 'Linux') { + // // On many systems (Mac, for instance) "/etc/localtime" is a symlink + // // to the file with the timezone info + // if (@is_link('/etc/localtime')) { + // // If it is, that file's name is actually the "Olsen" format timezone + // $temp_file = @readlink('/etc/localtime'); + // $temp_pos = strpos($temp_file, 'zoneinfo'); + // if ($temp_pos) { + // // When it is, it's in the "/usr/share/zoneinfo/" folder + // $timezone = substr($temp_file, $temp_pos + strlen('zoneinfo/')); + // } + // } else { + // // On other systems, like Ubuntu, there's file with the Olsen time right inside it. + // $timezone = @file_get_contents('/etc/timezone'); + // } + // if ((string)$timezone === '') { + // $this->appTimezone = $default; + // } else { + // $this->appTimezone = $timezone; + // } + // } } }