removed offset from agency module
gitea/salix/test This commit looks good Details

This commit is contained in:
Joan Sanchez 2019-02-25 14:02:47 +01:00
parent 94e2f933e9
commit 6068ede6ee
3 changed files with 30 additions and 13 deletions

View File

@ -1,5 +1,6 @@
FROM debian:stretch-slim
EXPOSE 80
ENV TZ Europe/Madrid
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \

View File

@ -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;
});

View File

@ -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)