@@ -151,19 +151,23 @@ test("timestampz round trip", function() {
151151} ) ;
152152
153153if ( ! helper . config . binary ) {
154- test ( 'early AD & BC date ' , function ( ) {
154+ test ( 'date range extremes ' , function ( ) {
155155 var client = helper . client ( ) ;
156156 client . on ( 'error' , function ( err ) {
157157 console . log ( err ) ;
158158 client . end ( ) ;
159159 } ) ;
160160
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 ) ;
163167 } ) )
164168
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 ) ;
167171 } ) )
168172
169173 client . on ( 'drain' , client . end . bind ( client ) ) ;
0 commit comments