added timezone override support

This commit is contained in:
Andy Miller
2015-02-14 10:38:01 -07:00
parent 2938848df1
commit b418a7fd1e
3 changed files with 10 additions and 4 deletions

View File

@@ -5,6 +5,7 @@ if (version_compare($ver = PHP_VERSION, $req = '5.4.0', '<')) {
exit(sprintf('You are running PHP %s, but Grav needs at least <strong>PHP %s</strong> to run.', $ver, $req));
}
// Ensure vendor libraries exist
$autoload = __DIR__ . '/vendor/autoload.php';
if (!is_file($autoload)) {
exit('Please run: <i>bin/grav install</i>');
@@ -15,19 +16,19 @@ use Grav\Common\Grav;
// Register the auto-loader.
$loader = require_once $autoload;
if (!ini_get('date.timezone')) {
date_default_timezone_set('UTC');
}
// Set timezone to default, falls back to system if php.ini not set
date_default_timezone_set(@date_default_timezone_get());
// Get the Grav instance
$grav = Grav::instance(
array(
'loader' => $loader
)
);
// Process the page
try {
$grav->process();
} catch (\Exception $e) {
$grav->fireEvent('onFatalException');
throw $e;

View File

@@ -1,4 +1,5 @@
absolute_urls: false # Absolute or relative URLs for `base_url`
timezone: '' # Valid values: http://php.net/manual/en/timezones.php
home:
alias: '/home' # Default path for home, ie /

View File

@@ -172,6 +172,10 @@ class Grav extends Container
ob_start('ob_gzhandler');
}
// Initialize the timezone
if ($this['config']->get('system.timezone')) {
date_default_timezone_set($this['config']->get('system.timezone'));
}
/** @var Debugger $debugger */
$debugger = $this['debugger'];