Built motion from commit b6cf875.|1.0.15
[motion.git] / server / models / index.js
index 03fe202..97fbb5c 100644 (file)
@@ -5,6 +5,8 @@ var path = require("path");
 var config = require('../config/environment');
 var Sequelize = require("sequelize");
 var moment = require('moment');
+var jstz = require('jstz');
+var timezone = jstz.determine();
 
 //Used to disable all warnings for Promise!
 Sequelize.Promise.config({
@@ -14,14 +16,10 @@ Sequelize.Promise.config({
   }
 });
 
-if (config.timezone && config.timezone == 'xcally-motion-timezone') {
-  config.timezone = '';
-}
-
 var sequelize = new Sequelize(config.db.database, config.db.username, config.db.password, {
   host: config.db.host,
   dialect: 'mysql',
-  timezone: config.timezone || moment().format("Z"),
+  timezone: timezone.name() || moment().format("Z"),
   logging: false,
   define: {
     charset: 'utf8',
@@ -54,7 +52,7 @@ db.history = {};
 var sequelize_readOnly = new Sequelize(config.db_history.database, config.db_history.username, config.db_history.password, {
   host: config.db_history.host,
   dialect: 'mysql',
-  timezone: config.timezone || moment().format("Z"),
+  timezone: timezone.name() || moment().format("Z"),
   logging: false,
   define: {
     charset: 'utf8',