Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed timestamptz handling again.

Still needs to explicitly set the DATESTYLE on connect.
  • Loading branch information...
commit dd3ea80ee3f3c8e6fd80c711b8b352f6f6d32a41 1 parent 46e4456
authored February 01, 2011

Showing 1 changed file with 10 additions and 2 deletions. Show diff stats Hide diff stats

  1. 12  lib/postgres-pure.js
12  lib/postgres-pure.js
@@ -1034,15 +1034,23 @@ function Connection(args) {
1034 1034
                     case 1114: // Timestamp, no timezone
1035 1035
                         value = new Date(value);
1036 1036
                     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"
1037 1041
                         if (value[value.length-1].toLowerCase() == 'z') {
1038 1042
                             // It's in UTC time
1039 1043
                             // 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);
1041 1048
                         }
1042 1049
                         else {
1043 1050
                             var tz = value.slice(value.length-3, value.length); // last three.
1044 1051
                             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");
1046 1054
                         }
1047 1055
                 }
1048 1056
             }

0 notes on commit dd3ea80

Please sign in to comment.
Something went wrong with that request. Please try again.