diff --git a/lib/mysql.js b/lib/mysql.js index 1b56900..13827a7 100644 --- a/lib/mysql.js +++ b/lib/mysql.js @@ -152,6 +152,13 @@ function generateOptions(settings) { options[p] = s[p]; } } + // Legacy UTC Date Processing fallback - SHOULD BE TRANSITIONAL + if (s.legacyUtcDateProcessing === undefined) { + s.legacyUtcDateProcessing = true; + } + if (s.legacyUtcDateProcessing) { + options.timezone = 'Z'; + } } return options; } @@ -307,19 +314,6 @@ MySQL.prototype.updateOrCreate = function(model, data, options, cb) { this._modifyOrCreate(model, data, options, fields, cb); }; -function dateToMysql(val) { - return val.getUTCFullYear() + '-' + - fillZeros(val.getUTCMonth() + 1) + '-' + - fillZeros(val.getUTCDate()) + ' ' + - fillZeros(val.getUTCHours()) + ':' + - fillZeros(val.getUTCMinutes()) + ':' + - fillZeros(val.getUTCSeconds()); - - function fillZeros(v) { - return v < 10 ? '0' + v : v; - } -} - MySQL.prototype.getInsertedId = function(model, info) { var insertedId = info && typeof info.insertId === 'number' ? info.insertId : undefined; @@ -356,7 +350,7 @@ MySQL.prototype.toColumnValue = function(prop, val) { if (!val.toUTCString) { val = new Date(val); } - return dateToMysql(val); + return val; } if (prop.type === Boolean) { return !!val; @@ -417,8 +411,6 @@ MySQL.prototype.fromColumnValue = function(prop, val) { // those separate. if (val == '0000-00-00 00:00:00') { val = null; - } else { - val = new Date(val.toString().replace(/GMT.*$/, 'GMT')); } break; case 'Boolean':