[Rcpp-devel] Rcpp::Date bug

Dominick Samperi djsamperi at gmail.com
Sun Dec 5 01:13:16 CET 2010


On Sat, Dec 4, 2010 at 3:22 PM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> 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.
>

Thanks.

Another small issue: the getHour() method of Rcpp::Datetime appears
to return GMT time. Is there an easy way to convert to localtime?


> Dirk
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20101204/e7e10367/attachment.htm>


More information about the Rcpp-devel mailing list