Permalink
Browse files

Parse date type as local time

  • Loading branch information...
benighted committed Jan 26, 2014
1 parent 51a28c2 commit b81a60a2605ae8c77e794b02830a4feadb3f57f6
Showing with 5 additions and 3 deletions.
  1. +2 −1 lib/types/textParsers.js
  2. +3 −2 test/integration/client/type-coercion-tests.js
View
@@ -14,7 +14,8 @@ var parseDate = function(isoDate) {
return null;
} else {
//it is a date in YYYY-MM-DD format
- return new Date(isoDate);
+ //add time portion to force js to parse as local time
+ return new Date(isoDate + ' 00:00:00');
}
}
var isBC = /BC$/.test(isoDate);
@@ -202,13 +202,14 @@ helper.pg.connect(helper.config, assert.calls(function(err, client, done) {
if(!helper.config.binary) {
test("postgres date type", function() {
var client = helper.client();
+ var testDate = new Date (2010, 9, 31);
client.on('error', function(err) {
console.log(err);
client.end();
});
- client.query("SELECT '2010-10-31'::date", assert.calls(function(err, result){
+ client.query("SELECT $1::date", [testDate], assert.calls(function(err, result){
assert.isNull(err);
- assert.UTCDate(result.rows[0].date, 2010, 9, 31, 0, 0, 0, 0);
+ assert.strictEqual(result.rows[0].date.toString(), testDate.toString());
}));
client.on('drain', client.end.bind(client));
});

0 comments on commit b81a60a

Please sign in to comment.