Skip to content

Commit 3d85e16

Browse files
author
Nino van Galen
committed
feat: added timezone config
1 parent 4430ee1 commit 3d85e16

3 files changed

Lines changed: 8 additions & 0 deletions

File tree

docs/CONFIGURATION.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
| DATABASE_USERNAME | The username which is used to authenticate against the database. | cern |
99
| DATABASE_PASSWORD | The password which is used to authenticate against the database. | cern |
1010
| DATABASE_NAME | The name of the database | bookkeeping |
11+
| DATABASE_TIMEZONE | The timezone of the database | Etc/GMT+0 |

lib/config/database.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ let port = 3306;
1717
let username = 'cern';
1818
let password = 'cern';
1919
let database = 'bookkeeping';
20+
let timezone = 'Etc/GMT+2';
2021

2122
if (process.env.DATABASE_HOST) {
2223
host = process.env.DATABASE_HOST;
@@ -38,6 +39,10 @@ if (process.env.DATABASE_NAME) {
3839
database = process.env.DATABASE_NAME;
3940
}
4041

42+
if (process.env.DATABASE_TIMEZONE) {
43+
timezone = process.env.DATABASE_TIMEZONE;
44+
}
45+
4146
if (process.env.NODE_ENV === 'test') {
4247
database = `${database}_test`;
4348
}
@@ -49,4 +54,5 @@ module.exports = {
4954
username,
5055
password,
5156
database,
57+
timezone,
5258
};

lib/database/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class SequelizeDatabase extends IDatabase {
4141
dialectOptions: {
4242
charset: 'utf8mb4',
4343
collate: 'utf8mb4_unicode_ci',
44+
timezone: Config.timezone,
4445
},
4546
logging: this.logger.debug.bind(this.logger),
4647
define: {

0 commit comments

Comments
 (0)