+ Timezones, fixes #14

This commit is contained in:
Miroslav Šedivý 2020-05-27 00:14:17 +02:00
parent 0a649d16b9
commit 6128fb62a8
4 changed files with 21 additions and 5 deletions

View file

@ -114,7 +114,7 @@ cp ./config.ini ./data/config.ini
```
## Install
If you have decied that you don't want to use Docker, you can intall it manually.
If you have decided that you don't want to use Docker, you can intall it manually.
**Requirements:** Apache 2.0*, PHP 7.4, MariaDB 10.1
@ -153,7 +153,10 @@ To check if your server is set up correctly, turn on a debug mode (in config add
* Display posts to chosen date using (format YYYY-MM-DD or YYY-MM): `http://blog/#to=2017-06`.
* Combine parameters in url using `&`, e.g. show posts between dates: `http://blog/#from=2017-06&to=2017-08`.
## Language support
## Localisation
Timezone can be set using `TZ` environment variable. List of supported values can be found [here](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
### Language support
Feel free to create new PR and add a new language. Specify language in config or in url: `http://blog/?hl=sk`.
* en - 🇬🇧 English

View file

@ -48,7 +48,14 @@ class DB
// Password
Config::get_safe('mysql_pass', '')
);
$this->_PDO->exec('SET NAMES utf8');
$this->_PDO->exec(
// Set charset
'SET NAMES utf8;'.
// Set timezone
'SET time_zone="'.date('P').'";'
);
} catch (PDOException $e) {
throw new DBException($e->getMessage());
}

View file

@ -27,8 +27,12 @@ if(Config::get_safe('debug', false)){
// Language
Lang::load(empty($_GET["hl"]) ? Config::get("lang") : $_GET["hl"]);
// Timezone
if(false !== ($TZ = getenv('TZ'))) {
date_default_timezone_set($TZ);
ini_set('date.timezone', $TZ);
}
// Start session
ini_set('session.cookie_httponly', 1);
session_start();

View file

@ -4,6 +4,8 @@ services:
webserver:
build: ./
container_name: blog_apache
environment:
TZ: Europe/Vienna
restart: unless-stopped
ports:
- ${HTTP_PORT-80}:80