@@ -158,20 +158,31 @@ if(!helper.config.binary) {
158158 client . end ( ) ;
159159 } ) ;
160160
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 ) ;
167- } ) )
168-
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 ) ;
171- } ) )
172-
173- client . on ( 'drain' , client . end . bind ( client ) ) ;
174- } )
161+ // Set teh server timeszone to the same as used for the test,
162+ // otherwise (if server's timezone is ahead of GMT) in
163+ // textParsers.js::parseDate() the timezone offest is added to the date;
164+ // in the case of "275760-09-13 00:00:00 GMT" the timevalue overflows.
165+ client . query ( 'SET TIMEZONE TO GMT' , [ ] , assert . success ( function ( res ) {
166+
167+ // PostgreSQL supports date range of 4713 BCE to 294276 CE
168+ // http://www.postgresql.org/docs/9.2/static/datatype-datetime.html
169+ // ECMAScript supports date range of Apr 20 271821 BCE to Sep 13 275760 CE
170+ // http://ecma-international.org/ecma-262/5.1/#sec-15.9.1.1
171+ client . query ( 'SELECT $1::TIMESTAMPTZ as when' , [ "275760-09-13 00:00:00 GMT" ] , assert . success ( function ( res ) {
172+ assert . equal ( res . rows [ 0 ] . when . getFullYear ( ) , 275760 ) ;
173+ } ) ) ;
174+
175+ client . query ( 'SELECT $1::TIMESTAMPTZ as when' , [ "4713-12-31 12:31:59 BC GMT" ] , assert . success ( function ( res ) {
176+ assert . equal ( res . rows [ 0 ] . when . getFullYear ( ) , - 4713 ) ;
177+ } ) ) ;
178+
179+ client . query ( 'SELECT $1::TIMESTAMPTZ as when' , [ "275760-09-13 00:00:00 -15:00" ] , assert . success ( function ( res ) {
180+ assert ( isNaN ( res . rows [ 0 ] . when . getTime ( ) ) ) ;
181+ } ) ) ;
182+
183+ client . on ( 'drain' , client . end . bind ( client ) ) ;
184+ } ) ) ;
185+ } ) ;
175186}
176187
177188helper . pg . connect ( helper . config , assert . calls ( function ( err , client , done ) {
0 commit comments