@@ -151,19 +151,23 @@ test("timestampz round trip", function() {
151
151
} ) ;
152
152
153
153
if ( ! helper . config . binary ) {
154
- test ( 'early AD & BC date ' , function ( ) {
154
+ test ( 'date range extremes ' , function ( ) {
155
155
var client = helper . client ( ) ;
156
156
client . on ( 'error' , function ( err ) {
157
157
console . log ( err ) ;
158
158
client . end ( ) ;
159
159
} ) ;
160
160
161
- client . query ( 'SELECT $1::TIMESTAMPTZ as when' , [ "0062-03-08 14:32:00" ] , assert . success ( function ( res ) {
162
- assert . equal ( res . rows [ 0 ] . when . getFullYear ( ) , 62 ) ;
161
+ // PostgreSQL supports date range of 4713 BCE to 294276 CE
162
+ // http://www.postgresql.org/docs/9.2/static/datatype-datetime.html
163
+ // ECMAScript supports date range of Apr 20 271821 BCE to Sep 13 275760 CE
164
+ // http://ecma-international.org/ecma-262/5.1/#sec-15.9.1.1
165
+ client . query ( 'SELECT $1::TIMESTAMPTZ as when' , [ "275760-09-13 00:00:00 GMT" ] , assert . success ( function ( res ) {
166
+ assert . equal ( res . rows [ 0 ] . when . getFullYear ( ) , 275760 ) ;
163
167
} ) )
164
168
165
- client . query ( 'SELECT $1::TIMESTAMPTZ as when' , [ "0062-03-08 14:32:00 BC" ] , assert . success ( function ( res ) {
166
- assert . equal ( res . rows [ 0 ] . when . getFullYear ( ) , - 62 ) ;
169
+ client . query ( 'SELECT $1::TIMESTAMPTZ as when' , [ "4713-12-31 12:31:59 BC GMT " ] , assert . success ( function ( res ) {
170
+ assert . equal ( res . rows [ 0 ] . when . getFullYear ( ) , - 4713 ) ;
167
171
} ) )
168
172
169
173
client . on ( 'drain' , client . end . bind ( client ) ) ;
0 commit comments