Permalink
Browse files

Fixed timestamptz handling again.

Still needs to explicitly set the DATESTYLE on connect.
  • Loading branch information...
1 parent 46e4456 commit dd3ea80ee3f3c8e6fd80c711b8b352f6f6d32a41 Aurynn Shaw committed Feb 2, 2011
Showing with 10 additions and 2 deletions.
  1. +10 −2 lib/postgres-pure.js
View
@@ -1034,15 +1034,23 @@ function Connection(args) {
case 1114: // Timestamp, no timezone
value = new Date(value);
case 1184: // Timestamp, with timezone
+ // Initial value:
+ // "2011-02-01 21:00:52.353444-07"
+ // Needs to become:
+ // "2011-02-01 21:00:52.353 GMT-0700"
if (value[value.length-1].toLowerCase() == 'z') {
// It's in UTC time
// So, we add the appropriate modifiers.
- value = new Date(value.slice(0, value.length-1) + " GMT+0000" );
+ var tz = value.slice(0, value.length-1);
+ tz = tz.slice(0, tz.length-4);
+ value = new Date(tz + " GMT+0000" );
+ console.log(value);
}
else {
var tz = value.slice(value.length-3, value.length); // last three.
var orig = value;
- value = new Date(value.slice(0, value.length-3) + " GMT"+tz+"00");
+ orig = orig.slice(0, orig.length-7);
+ value = new Date(orig + " GMT"+tz+"00");
}
}
}

0 comments on commit dd3ea80

Please sign in to comment.