Bug #379 Loopback guarda las horas en UTC
This commit is contained in:
parent
813c490c5b
commit
e90ba9d785
|
@ -1,5 +1,4 @@
|
|||
import ngModule from '../../module';
|
||||
import {toJsonDate} from 'core/src/lib/date';
|
||||
|
||||
class Controller {
|
||||
constructor($scope, $http, $translate, vnApp) {
|
||||
|
@ -36,7 +35,7 @@ class Controller {
|
|||
|
||||
let query = `/ticket/api/sales/${this.ticket.id}/priceDifference`;
|
||||
let data = {
|
||||
landed: toJsonDate(this.ticket.landed),
|
||||
landed: this.ticket.landed,
|
||||
addressFk: this.ticket.addressFk,
|
||||
agencyModeFk: this.ticket.agencyModeFk,
|
||||
warehouseFk: this.ticket.warehouseFk
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
|
||||
var mysql = require('mysql');
|
||||
var SqlConnector = require('loopback-connector').SqlConnector;
|
||||
var MySQL = require('loopback-connector-mysql').MySQL;
|
||||
var EnumFactory = require('loopback-connector-mysql').EnumFactory;
|
||||
|
||||
exports.initialize = function(dataSource, callback) {
|
||||
dataSource.driver = mysql;
|
||||
dataSource.connector = new VnMySQL(dataSource.settings);
|
||||
dataSource.connector.dataSource = dataSource;
|
||||
|
||||
var modelBuilder = dataSource.modelBuilder;
|
||||
var defineType = modelBuilder.defineValueType ?
|
||||
modelBuilder.defineValueType.bind(modelBuilder) :
|
||||
modelBuilder.constructor.registerType.bind(modelBuilder.constructor);
|
||||
|
||||
defineType(function Point() {});
|
||||
|
||||
dataSource.EnumFactory = EnumFactory;
|
||||
|
||||
if (callback) {
|
||||
if (dataSource.settings.lazyConnect) {
|
||||
process.nextTick(function() {
|
||||
callback();
|
||||
});
|
||||
} else {
|
||||
dataSource.connector.connect(callback);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
exports.VnMySQL = VnMySQL;
|
||||
|
||||
function VnMySQL(settings) {
|
||||
SqlConnector.call(this, 'mysql', settings);
|
||||
}
|
||||
|
||||
VnMySQL.prototype = Object.create(MySQL.prototype);
|
||||
VnMySQL.constructor = VnMySQL;
|
||||
|
||||
VnMySQL.prototype.toColumnValue = function(prop, val) {
|
||||
if (val == null || !prop || prop.type !== Date)
|
||||
return MySQL.prototype.toColumnValue.call(this, prop, val);
|
||||
|
||||
return val.getFullYear() + '-' +
|
||||
fillZeros(val.getMonth() + 1) + '-' +
|
||||
fillZeros(val.getDate()) + ' ' +
|
||||
fillZeros(val.getHours()) + ':' +
|
||||
fillZeros(val.getMinutes()) + ':' +
|
||||
fillZeros(val.getSeconds());
|
||||
|
||||
function fillZeros(v) {
|
||||
return v < 10 ? '0' + v : v;
|
||||
}
|
||||
};
|
|
@ -3,7 +3,8 @@
|
|||
"connector": "memory"
|
||||
},
|
||||
"vn": {
|
||||
"connector": "mysql",
|
||||
"connector": "vn-mysql",
|
||||
"timezone": "CET",
|
||||
"database": "vn",
|
||||
"debug": false,
|
||||
"host": "${salixHost}",
|
||||
|
@ -14,7 +15,7 @@
|
|||
"acquireTimeout": 20000
|
||||
},
|
||||
"salix": {
|
||||
"connector": "mysql",
|
||||
"connector": "vn-mysql",
|
||||
"database": "salix",
|
||||
"debug": false,
|
||||
"host": "${salixHost}",
|
||||
|
@ -25,7 +26,7 @@
|
|||
"acquireTimeout": 20000
|
||||
},
|
||||
"account": {
|
||||
"connector": "mysql",
|
||||
"connector": "vn-mysql",
|
||||
"database": "account",
|
||||
"debug": false,
|
||||
"host": "${salixHost}",
|
||||
|
@ -36,7 +37,7 @@
|
|||
"acquireTimeout": 20000
|
||||
},
|
||||
"edi": {
|
||||
"connector": "mysql",
|
||||
"connector": "vn-mysql",
|
||||
"database": "edi",
|
||||
"debug": false,
|
||||
"host": "${salixHost}",
|
||||
|
@ -47,7 +48,7 @@
|
|||
"acquireTimeout": 20000
|
||||
},
|
||||
"bs": {
|
||||
"connector": "mysql",
|
||||
"connector": "vn-mysql",
|
||||
"database": "bs",
|
||||
"debug": false,
|
||||
"host": "${salixHost}",
|
||||
|
@ -58,7 +59,7 @@
|
|||
"acquireTimeout": 20000
|
||||
},
|
||||
"hedera": {
|
||||
"connector": "mysql",
|
||||
"connector": "vn-mysql",
|
||||
"database": "hedera",
|
||||
"debug": false,
|
||||
"host": "${salixHost}",
|
||||
|
|
|
@ -1,9 +1,24 @@
|
|||
let loopback = require('loopback');
|
||||
let boot = require('loopback-boot');
|
||||
let DataSource = require('loopback-datasource-juggler').DataSource;
|
||||
let fs = require('fs-extra');
|
||||
let i18n = require('i18n');
|
||||
let path = require('path');
|
||||
|
||||
let _resolveConnector = DataSource._resolveConnector;
|
||||
|
||||
DataSource._resolveConnector = function(name) {
|
||||
let testPath = `${__dirname}/connectors/${name}.js`;
|
||||
|
||||
if (fs.existsSync(testPath))
|
||||
return {
|
||||
connector: require(testPath),
|
||||
error: null
|
||||
};
|
||||
|
||||
return _resolveConnector.apply(this, arguments);
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
loopback: loopback,
|
||||
boot: vnBoot
|
||||
|
|
Loading…
Reference in New Issue