[Rcpp-devel] Rcpp::Date bug

Dirk Eddelbuettel edd at debian.org
Sat Dec 4 21:22:36 CET 2010


On 4 December 2010 at 15:04, Dominick Samperi wrote:
| getYear() method adds 1900 when it shouldn't, so 2001 becoms 3901,
| for example.

Confirmed:

R> require(inline, quiet=TRUE, warn=FALSE)
R> require(Rcpp, quiet=TRUE, warn=FALSE)
R> 
R> foo <- cxxfunction(signature(sDate="Date"), '
+   Rcpp::Date d(sDate);
+   return(Rcpp::List::create(Rcpp::Named("day")      = d.getDay(),
+                             Rcpp::Named("month")    = d.getMonth(),
+                             Rcpp::Named("year")     = d.getYear(),
+                             Rcpp::Named("weekeday") = d.getWeekday(),
+                             Rcpp::Named("yearday")  = d.getYearday()));
+   ', plugin="Rcpp")
R> 
R> foo(Sys.Date())
$day
[1] 4

$month
[1] 12

$year
[1] 3910

$weekeday
[1] 7

$yearday
[1] 338

R>

Now fixed in rev2714.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com


More information about the Rcpp-devel mailing list