Merge pull request #514 from benighted/parse-date-as-local

Parse date type as local time
This commit is contained in:
Brian C 2014-02-26 06:16:12 -06:00
commit 2716f95257
2 changed files with 5 additions and 3 deletions

View File

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

View File

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