From ab28dfca839728dfe40d941091902185d7c19b57 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Thu, 24 Apr 2014 11:31:51 +1000 Subject: [PATCH] use getDate instead of getDay. fixes #89 --- lib/packets/execute.js | 2 +- test/integration/connection/test-custom-date-parameter.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/packets/execute.js b/lib/packets/execute.js index f42608cb2a..9dbb1d358f 100644 --- a/lib/packets/execute.js +++ b/lib/packets/execute.js @@ -33,7 +33,7 @@ Execute.prototype.toPacket = function() if (toString.call(this.parameters[i]) == '[object Date]') { var d = this.parameters[i]; // TODO: move to asMysqlDateTime() - this.parameters[i] = [d.getFullYear(), d.getMonth() + 1, d.getDay()].join('-') + + this.parameters[i] = [d.getFullYear(), d.getMonth() + 1, d.getDate()].join('-') + ' ' + [d.getHours(), d.getMinutes(), d.getSeconds()].join(':'); } if (Buffer.isBuffer(this.parameters[i])) { diff --git a/test/integration/connection/test-custom-date-parameter.js b/test/integration/connection/test-custom-date-parameter.js index f417b5a06c..dae6fa7bf8 100644 --- a/test/integration/connection/test-custom-date-parameter.js +++ b/test/integration/connection/test-custom-date-parameter.js @@ -12,7 +12,7 @@ Date = function() { return CustomDate; }(); -connection.execute('SELECT UNIX_TIMESTAMP(?) t', [new Date('1990-01-01 UTC')], function(err, _rows, _fields) { +connection.execute('SELECT UNIX_TIMESTAMP(?) t', [new Date('1990-08-08 UTC')], function(err, _rows, _fields) { if (err) throw err; rows = _rows; console.log(_rows, _fields); @@ -21,5 +21,5 @@ connection.execute('SELECT UNIX_TIMESTAMP(?) t', [new Date('1990-01-01 UTC')], f connection.end(); process.on('exit', function() { - assert.deepEqual(rows, [{t: 631152000}]); + assert.deepEqual(rows, [{t: 650073600}]); });