Skip to content

Commit

Permalink
use getDate instead of getDay. fixes sidorares#89
Browse files Browse the repository at this point in the history
  • Loading branch information
sidorares committed Apr 24, 2014
1 parent 9e1d54c commit ab28dfc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/packets/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
4 changes: 2 additions & 2 deletions test/integration/connection/test-custom-date-parameter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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}]);
});

0 comments on commit ab28dfc

Please sign in to comment.