# HG changeset patch # User Matti Hamalainen # Date 1504215892 -10800 # Node ID f825d644cf7ad115892a56f84ab84909cfe88c57 # Parent bad658e1e7edde61e9ea865761e9088c212e9c16 Implement new config setting "timezone" for specifying the timezone used for date/timestamp interpretation. diff -r bad658e1e7ed -r f825d644cf7a example.cfg --- a/example.cfg Fri Sep 01 00:44:03 2017 +0300 +++ b/example.cfg Fri Sep 01 00:44:52 2017 +0300 @@ -2,6 +2,11 @@ ;;; MGallery example configuration ;;; +; Timezone used for timestamp/date calculations. +; See http://php.net/manual/en/timezones.php +timezone = "Europe/Helsinki" + + ;;; Gallery title, etc. title_prefix = "My Own Gallery" title_sep = " - " diff -r bad658e1e7ed -r f825d644cf7a mgallery.inc.php --- a/mgallery.inc.php Fri Sep 01 00:44:03 2017 +0300 +++ b/mgallery.inc.php Fri Sep 01 00:44:52 2017 +0300 @@ -54,6 +54,7 @@ // Configuration settings and their default values // $mgDefaults = [ + "timezone" => [MG_STR, NULL], "base_path" => [MG_STR, mgPathName(mgRealPath($_SERVER["SCRIPT_FILENAME"]))], "base_url" => [MG_STR, mgPathName($_SERVER["PHP_SELF"])], diff -r bad658e1e7ed -r f825d644cf7a mgallery.php --- a/mgallery.php Fri Sep 01 00:44:03 2017 +0300 +++ b/mgallery.php Fri Sep 01 00:44:52 2017 +0300 @@ -502,6 +502,9 @@ if (is_string($galImage)) $galImage = basename($galImage); +if (($pageTimeZone = mgGetSetting("timezone")) !== NULL) + date_default_timezone_set($pageTimeZone); + // Check language setting if (($tmp = mgGetRequestItem("lang", FALSE, TRUE)) !== FALSE) diff -r bad658e1e7ed -r f825d644cf7a mgtool.php --- a/mgtool.php Fri Sep 01 00:44:03 2017 +0300 +++ b/mgtool.php Fri Sep 01 00:44:52 2017 +0300 @@ -668,10 +668,6 @@ { global $galTNPath; - // Fetch the settings we need - if (mgReadSettings() === FALSE) - die("MGallery not configured.\n"); - // Check validity of some settings $galPath = mgGetSetting("base_path"); $galTNPath = mgCleanPath(TRUE, mgGetSetting("tn_path")); @@ -783,6 +779,11 @@ pcntl_signal(SIGQUIT, "mgSigHandler"); pcntl_signal(SIGINT, "mgSigHandler"); +if (mgReadSettings() === FALSE) + die("MGallery is not configured, failed to find a configuration file.\n"); + +if (($pageTimeZone = mgGetSetting("timezone")) !== NULL) + date_default_timezone_set($pageTimeZone); $cmd = mgCArgLC(1); switch ($cmd) @@ -848,8 +849,6 @@ case "config": case "dump": - if (mgReadSettings() === FALSE) - die("MGallery not configured.\n"); foreach ($mgDefaults as $key => $dval) {