Skip to content

Commit dd3ea80

Browse files
author
Aurynn Shaw
committed
Fixed timestamptz handling again.
Still needs to explicitly set the DATESTYLE on connect.
1 parent 46e4456 commit dd3ea80

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lib/postgres-pure.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,15 +1034,23 @@ function Connection(args) {
10341034
case 1114: // Timestamp, no timezone
10351035
value = new Date(value);
10361036
case 1184: // Timestamp, with timezone
1037+
// Initial value:
1038+
// "2011-02-01 21:00:52.353444-07"
1039+
// Needs to become:
1040+
// "2011-02-01 21:00:52.353 GMT-0700"
10371041
if (value[value.length-1].toLowerCase() == 'z') {
10381042
// It's in UTC time
10391043
// So, we add the appropriate modifiers.
1040-
value = new Date(value.slice(0, value.length-1) + " GMT+0000" );
1044+
var tz = value.slice(0, value.length-1);
1045+
tz = tz.slice(0, tz.length-4);
1046+
value = new Date(tz + " GMT+0000" );
1047+
console.log(value);
10411048
}
10421049
else {
10431050
var tz = value.slice(value.length-3, value.length); // last three.
10441051
var orig = value;
1045-
value = new Date(value.slice(0, value.length-3) + " GMT"+tz+"00");
1052+
orig = orig.slice(0, orig.length-7);
1053+
value = new Date(orig + " GMT"+tz+"00");
10461054
}
10471055
}
10481056
}

0 commit comments

Comments
 (0)