aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar logmanoriginal <logmanoriginal@users.noreply.github.com> 2019-06-07 19:19:36 +0200
committerGravatar logmanoriginal <logmanoriginal@users.noreply.github.com> 2019-06-07 19:22:51 +0200
commit946a99d3347d0e25c11bb57b563cd5daeaa0aa5b (patch)
treea6c0da7ed37e0f9eaf6797a8258fb657157ee86d
parente2e0ced055c4a0ec59415ca00422b1db7fec68e9 (diff)
downloadrss-bridge-946a99d3347d0e25c11bb57b563cd5daeaa0aa5b.tar.gz
rss-bridge-946a99d3347d0e25c11bb57b563cd5daeaa0aa5b.tar.zst
rss-bridge-946a99d3347d0e25c11bb57b563cd5daeaa0aa5b.zip
config: Add [system] => 'timezone'
RSS-Bridge currently statically sets the timezone to UTC which can result in incorrect timestamps if the server is hosted in another region. This commit adds a new configuration parameter to allow admins to specify their own timezone for their servers. Invalid values will result in an error message. Example: [system] timezone = "UTC" For compatibility reasons the default value is set to UTC. This parameter accepts any of the supported timezones listed at https://www.php.net/manual/en/timezones.php Closes #956 References #1001
-rw-r--r--config.default.ini.php8
-rw-r--r--lib/Configuration.php6
2 files changed, 14 insertions, 0 deletions
diff --git a/config.default.ini.php b/config.default.ini.php
index 5f4a75f6..b7d4fba0 100644
--- a/config.default.ini.php
+++ b/config.default.ini.php
@@ -4,6 +4,14 @@
; file, it will be replaced on the next update of RSS-Bridge! You can specify
; your own configuration in 'config.ini.php' (copy this file).
+[system]
+
+; Defines the timezone used by RSS-Bridge
+; Find a list of supported timezones at
+; https://www.php.net/manual/en/timezones.php
+; timezone = "UTC" (default)
+timezone = "UTC"
+
[cache]
; Defines the cache type used by RSS-Bridge
diff --git a/lib/Configuration.php b/lib/Configuration.php
index cf2fd7c8..c327c1d4 100644
--- a/lib/Configuration.php
+++ b/lib/Configuration.php
@@ -155,6 +155,12 @@ final class Configuration {
}
}
+ if(!is_string(self::getConfig('system', 'timezone'))
+ || !in_array(self::getConfig('system', 'timezone'), timezone_identifiers_list(DateTimeZone::ALL_WITH_BC)))
+ die('Parameter [system] => "timezone" is invalid! Please check "config.ini.php"!');
+
+ date_default_timezone_set(self::getConfig('system', 'timezone'));
+
if(!is_string(self::getConfig('proxy', 'url')))
die('Parameter [proxy] => "url" is not a valid string! Please check "config.ini.php"!');