[Rcpp-commits] r498 - in pkg: inst inst/unitTests src/Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Jan 28 09:16:54 CET 2010


Author: romain
Date: 2010-01-28 09:16:53 +0100 (Thu, 28 Jan 2010)
New Revision: 498

Modified:
   pkg/inst/ChangeLog
   pkg/inst/unitTests/runit.RcppResultSet.R
   pkg/src/Rcpp/CharacterVector.h
Log:
use as.numeric when comparing POSIXct times to avoid timezone issues

Modified: pkg/inst/ChangeLog
===================================================================
--- pkg/inst/ChangeLog	2010-01-28 03:47:24 UTC (rev 497)
+++ pkg/inst/ChangeLog	2010-01-28 08:16:53 UTC (rev 498)
@@ -1,3 +1,10 @@
+2010-01-28  Romain Francois <francoisromain at free.fr>
+
+	* src/Rcpp/CharacterVector.h: minor bug fix in assign
+
+	* inst/unitTest/runit.RcppResultSet.R: compare time using 
+	as.numeric to avoid timezone problems
+
 2010-01-27  Dirk Eddelbuettel  <edd at debian.org>
 
 	* inst/unitTests/runit.RcppMatrix.R: added

Modified: pkg/inst/unitTests/runit.RcppResultSet.R
===================================================================
--- pkg/inst/unitTests/runit.RcppResultSet.R	2010-01-28 03:47:24 UTC (rev 497)
+++ pkg/inst/unitTests/runit.RcppResultSet.R	2010-01-28 08:16:53 UTC (rev 498)
@@ -113,8 +113,13 @@
              rs.add("foo", y);
   	     return rs.getReturnList();';
      funx <- cfunction(signature(x="numeric"), src, Rcpp=TRUE)
-     posixt <- as.POSIXct("2000-01-01 01:02:03.456", "%Y-%m-%d %H:%M:%OS")
-     checkEquals(funx(as.numeric(posixt))[[1]], posixt, msg = "RcppResultSet.RcppDatetime")
+     # setting tz = "UTC" because otherwise the format gets set as the tz
+     posixt <- as.POSIXct("2000-01-01 01:02:03.456", "%Y-%m-%d %H:%M:%OS", tz = "UTC" )
+     result <- funx(as.numeric(posixt))[[1]]
+     # RcppDateTime discards the timezone, so the only reliable way to 
+     # compare these times is to compare the numeric values
+     checkEquals( as.numeric(result), as.numeric(posixt), 
+     	msg = "RcppResultSet.RcppDatetime")
 }
 
 test.RcppResultSet.RcppDatetimeVector <- function() {

Modified: pkg/src/Rcpp/CharacterVector.h
===================================================================
--- pkg/src/Rcpp/CharacterVector.h	2010-01-28 03:47:24 UTC (rev 497)
+++ pkg/src/Rcpp/CharacterVector.h	2010-01-28 08:16:53 UTC (rev 498)
@@ -69,7 +69,7 @@
 	
 #ifdef HAS_INIT_LISTS
 	CharacterVector( std::initializer_list<std::string> list ) : VectorBase() {
-		assign( list.begin(), list.size() ) ;
+		assign( list.begin(), list.end() ) ;
 	}
 #endif
 



More information about the Rcpp-commits mailing list