Skip to content

Commit

Permalink
Better PHP timezone handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
onovy committed Sep 20, 2014
1 parent 79373d4 commit bc00300
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ todo_file=todo.txt
archive_file=archive.txt
backup_dir=backup
similar_limit=70
timezone=

[gui]
history_file=history.txt
Expand Down
19 changes: 19 additions & 0 deletions otodo
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,24 @@ try {
exit(-1);
}

$tz = @Config::$config['core']['timezone'];
if ($tz) {
if (!@date_default_timezone_set($tz)) {
echo 'Timezone ' . $tz . ' from config core.timezone ' .
'is not correct. Please set one from ' .
'http://php.net/manual/en/timezones.php ' .
PHP_EOL;
exit(-1);
}
} else {
if (!ini_get('date.timezone')) {
echo 'Timezone is not set. Please set one from ' .
'http://php.net/manual/en/timezones.php ' .
'in config core.timezone or in php.ini' .
PHP_EOL;
exit(-1);
}
}

$g = new Gui();
$g->start();

0 comments on commit bc00300

Please sign in to comment.