diff --git a/front/Dockerfile b/front/Dockerfile index d6fe5d4f8..098ee161e 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -1,5 +1,6 @@ FROM debian:stretch-slim EXPOSE 80 +ENV TZ Europe/Madrid ARG DEBIAN_FRONTEND=noninteractive RUN apt-get update \ diff --git a/front/core/components/calendar/index.js b/front/core/components/calendar/index.js index fbc3932cf..cc90846f7 100644 --- a/front/core/components/calendar/index.js +++ b/front/core/components/calendar/index.js @@ -71,8 +71,6 @@ export default class Calendar extends Component { date.getFullYear(), date.getMonth(), 1); - this.applyOffset(newDate); - return newDate; } @@ -87,15 +85,9 @@ export default class Calendar extends Component { date.getFullYear(), date.getMonth() + 1, 0); - this.applyOffset(newDate); - return newDate; } - applyOffset(date) { - date.setTime(date.getTime() - date.getTimezoneOffset() * 60000); - } - repaint() { const firstWeekday = this.firstDay(this.currentMonth).getDay(); const previousLastDay = this.lastDay(this.previousMonth).getDate(); @@ -127,14 +119,10 @@ export default class Calendar extends Component { const curDate = new Date(); curDate.setHours(0, 0, 0, 0); - this.applyOffset(curDate); - const newDate = new Date( date.getFullYear(), date.getMonth(), day); - this.applyOffset(newDate); - let event = this.events.find(event => { return event.date >= newDate && event.date <= newDate; }); diff --git a/loopback/server/connectors/vn-mysql.js b/loopback/server/connectors/vn-mysql.js index 3df0878c9..03418307b 100644 --- a/loopback/server/connectors/vn-mysql.js +++ b/loopback/server/connectors/vn-mysql.js @@ -1,4 +1,3 @@ - const mysql = require('mysql'); const ParameterizedSQL = require('loopback-connector').ParameterizedSQL; const MySQL = require('loopback-connector-mysql').MySQL; @@ -24,6 +23,23 @@ 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; + } + + 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(). * @@ -34,6 +50,18 @@ 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); + console.log(param); + } + } + } + return new Promise((resolve, reject) => { this.execute(query, params, options, (error, response) => { if (cb)