From ef5c91980339b137b3fbb5754abc1ca0ef0a4b95 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Mon, 4 Aug 2014 14:18:43 +0000 Subject: [PATCH] Add timezone option to the config file Fixes #55 --- src/mibew/configs/default_config.yml | 5 +++++ src/mibew/libs/init.php | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/mibew/configs/default_config.yml b/src/mibew/configs/default_config.yml index b6597b35..e34a27f0 100644 --- a/src/mibew/configs/default_config.yml +++ b/src/mibew/configs/default_config.yml @@ -21,6 +21,11 @@ home_locale: en ## If user does not provide known lang default_locale: en +# A timezone to use. Leave this value empty to use the default timezone from the +# system settings. For the details about available timezones see +# http://php.net/manual/en/timezones.php +timezone: "" + # Plugins plugins: [] diff --git a/src/mibew/libs/init.php b/src/mibew/libs/init.php index 56e757ec..39f5bdda 100644 --- a/src/mibew/libs/init.php +++ b/src/mibew/libs/init.php @@ -67,9 +67,10 @@ if (is_secure_request()) { session_start(); if (function_exists("date_default_timezone_set")) { - // TODO try to get timezone from config.yml/session etc. - // autodetect timezone - @date_default_timezone_set(function_exists("date_default_timezone_get") ? @date_default_timezone_get() : "GMT"); + $timezone = !empty($configs['timezone']) + ? $configs['timezone'] + : (function_exists("date_default_timezone_get") ? @date_default_timezone_get() : "GMT"); + @date_default_timezone_set($timezone); } if (!installation_in_progress()) {