date offset
gitea/salix/test This commit looks good
Details
gitea/salix/test This commit looks good
Details
This commit is contained in:
parent
a389ca46a2
commit
dd4f4e39fb
|
@ -36,6 +36,11 @@ class VnMySQL extends MySQL {
|
||||||
return date;
|
return date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isIsoDate(dateString) {
|
||||||
|
let isoRegexp = /^(-?(?:[1-9][0-9]*)?[0-9]{4})-(1[0-2]|0[1-9])-(3[01]|0[1-9]|[12][0-9])T(2[0-3]|[01][0-9]):([0-5][0-9]):([0-5][0-9])(.[0-9]+)?(Z)?$/g;
|
||||||
|
return isoRegexp.test(dateString);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Promisified version of execute().
|
* Promisified version of execute().
|
||||||
*
|
*
|
||||||
|
@ -48,10 +53,12 @@ class VnMySQL extends MySQL {
|
||||||
executeP(query, params, options = {}, cb) {
|
executeP(query, params, options = {}, cb) {
|
||||||
if (params) {
|
if (params) {
|
||||||
for (let param of params) {
|
for (let param of params) {
|
||||||
if (param && typeof param.getMonth === 'function') {
|
if (param && typeof param.getMonth === 'function' || this.isIsoDate(param)) {
|
||||||
|
if (this.isIsoDate(param)) param = new Date(param);
|
||||||
let locale = new Date(param);
|
let locale = new Date(param);
|
||||||
let offset = locale.getTimezoneOffset() * 60000;
|
let offset = locale.getTimezoneOffset() * 60000;
|
||||||
param.setTime(param.getTime() - offset);
|
param.setTime(param.getTime() - offset);
|
||||||
|
console.log(param);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue