fixed vn-mysql time offset
gitea/salix/test This commit looks good
Details
gitea/salix/test This commit looks good
Details
This commit is contained in:
parent
ac1e619b06
commit
5ec352b71a
|
@ -24,6 +24,18 @@ class VnMySQL extends MySQL {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fromColumnValue(prop, val) {
|
||||||
|
if (val == null || !prop || prop.type !== Date)
|
||||||
|
return MySQL.prototype.fromColumnValue.call(this, prop, val);
|
||||||
|
|
||||||
|
let date = new Date(val);
|
||||||
|
let locale = new Date(val);
|
||||||
|
let offset = locale.getTimezoneOffset() * 60000;
|
||||||
|
date.setTime(date.getTime() + offset);
|
||||||
|
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Promisified version of execute().
|
* Promisified version of execute().
|
||||||
*
|
*
|
||||||
|
@ -34,6 +46,16 @@ class VnMySQL extends MySQL {
|
||||||
* @return {Promise} The operation promise
|
* @return {Promise} The operation promise
|
||||||
*/
|
*/
|
||||||
executeP(query, params, options = {}, cb) {
|
executeP(query, params, options = {}, cb) {
|
||||||
|
if (params) {
|
||||||
|
for (let param of params) {
|
||||||
|
if (param && typeof param.getMonth === 'function') {
|
||||||
|
let locale = new Date(param);
|
||||||
|
let offset = locale.getTimezoneOffset() * 60000;
|
||||||
|
param.setTime(param.getTime() - offset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
this.execute(query, params, options, (error, response) => {
|
this.execute(query, params, options, (error, response) => {
|
||||||
if (cb)
|
if (cb)
|
||||||
|
@ -230,11 +252,12 @@ exports.initialize = function initialize(dataSource, callback) {
|
||||||
|
|
||||||
dataSource.EnumFactory = EnumFactory;
|
dataSource.EnumFactory = EnumFactory;
|
||||||
|
|
||||||
if (callback)
|
if (callback) {
|
||||||
if (dataSource.settings.lazyConnect) {
|
if (dataSource.settings.lazyConnect) {
|
||||||
process.nextTick(function() {
|
process.nextTick(function() {
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
} else
|
} else
|
||||||
dataSource.connector.connect(callback);
|
dataSource.connector.connect(callback);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue