date offset fixed
gitea/salix/test This commit looks good Details

This commit is contained in:
Gerard 2019-02-27 17:04:32 +01:00
parent 87e8be0ede
commit 9a7bd834df
6 changed files with 25 additions and 34 deletions

View File

@ -28,14 +28,8 @@ class DatePicker extends Component {
onValueUpdate() {
if (this.vp.selectedDates.length) {
let date = this.vp.selectedDates[0];
if (!this.isLocale && !this._iniOptions.enableTime) {
let now = new Date();
let offset = now.getTimezoneOffset() * 60000;
date.setHours(0, 0, 0, 0);
date.setTime(date.getTime() - offset);
}
let offset = date.getTimezoneOffset() * 60000;
date.setTime(date.getTime() - offset);
this._model = date;
} else
this.model = null;
@ -67,8 +61,16 @@ class DatePicker extends Component {
set model(value) {
this._model = value;
this.dateValue = value ? new Date(value) : null;
this.vp.setDate(this.dateValue);
this.dateValue = value;
let date;
if (value && this.iniOptions.enableTime) {
date = new Date(value);
let offset = date.getTimezoneOffset() * 60000;
date.setTime(date.getTime() + offset);
} else
date = value;
this.vp.setDate(date);
this.mdlUpdate();
}
@ -84,6 +86,7 @@ class DatePicker extends Component {
$onDestroy() {
this.vp.destroy();
this.dateValue = undefined;
}
}
DatePicker.$inject = ['$element', '$scope', '$translate', '$attrs'];
@ -91,12 +94,12 @@ DatePicker.$inject = ['$element', '$scope', '$translate', '$attrs'];
ngModule.component('vnDatePicker', {
template: require('./date-picker.html'),
bindings: {
iniOptions: '<?',
model: '=',
label: '@?',
name: '@?',
disabled: '<?',
rule: '<?',
iniOptions: '<?',
isLocale: '<?'
},
controller: DatePicker

View File

@ -9,8 +9,9 @@ dateTime.$inject = ['$filter'];
export default function dateTime($filter) {
return function(input, format) {
let value = typeof input === 'string' ? new Date(input) : input;
let value = new Date(input);
let offset = value.getTimezoneOffset() * 60000;
value.setTime(value.getTime() + offset);
return $filter('date')(value, format);
};
}

View File

@ -424,8 +424,7 @@ function dockerWait() {
user: dbConf.username,
password: dbConf.password,
host: dbConf.host,
port: dbConf.port,
dateStrings: true
port: dbConf.port
};
log('Waiting for MySQL init process...');

View File

@ -22,7 +22,6 @@ class VnMySQL extends MySQL {
return v < 10 ? '0' + v : v;
}
}
fromColumnValue(prop, val) {
if (val == null || !prop || prop.type !== Date)
return MySQL.prototype.fromColumnValue.call(this, prop, val);
@ -47,17 +46,6 @@ class VnMySQL extends MySQL {
* @return {Promise} The operation promise
*/
executeP(query, params, options = {}, cb) {
if (params) {
for (let param of params) {
if (param && typeof param.getMonth === 'function' || this.isIsoDate(param)) {
if (this.isIsoDate(param)) param = new Date(param);
let locale = new Date(param);
let offset = locale.getTimezoneOffset() * 60000;
param.setTime(param.getTime() - offset);
}
}
}
return new Promise((resolve, reject) => {
this.execute(query, params, options, (error, response) => {
if (cb)

View File

@ -13,7 +13,7 @@
"description": "Identifier"
},
"landed": {
"type": "date",
"type": "Date",
"required": true,
"mysql": {
"columnName": "date_send"
@ -63,19 +63,19 @@
}
},
"created": {
"type": "date",
"type": "Date",
"mysql": {
"columnName": "date_make"
}
},
"firstRowStamp": {
"type": "date",
"type": "Date",
"mysql": {
"columnName": "first_row_stamp"
}
},
"confirmed": {
"type": "date",
"type": "Date",
"mysql": {
"columnName": "confirm_date"
}

View File

@ -13,11 +13,11 @@
"description": "Identifier"
},
"shipped": {
"type": "date",
"type": "Date",
"required": true
},
"landed": {
"type": "date"
"type": "Date"
},
"nickname": {
"type": "String"
@ -32,7 +32,7 @@
"type": "Number"
},
"created": {
"type": "date"
"type": "Date"
},
"isDeleted": {
"type": "boolean"