[Rcpp-devel] Problem with Rcpp::Datetime
Dirk Eddelbuettel
edd at debian.org
Fri Dec 17 19:10:29 CET 2010
On 17 December 2010 at 12:46, Dominick Samperi wrote:
| In the process of migrating from the classic API I have
| found what appears to be a problem with Rcpp::Datetime.
| There is no unit test for this situation.
|
| Rcpp::Datetime dt("2015-04-15 06:00:00")
| and
| Rcpp::Datetime dt("2015-04-15 06:00:00.0")
| both fail due to a type conversion error.
|
| Here is the original constructor:
| Datetime::Datetime(const std::string &s, const std::string &fmt) {
| Rcpp::Function strptime("strptime"); // we cheat and call
| strptime() from R
| m_dt = Rcpp::as<double>(strptime(s, fmt));
| update_tm();
| }
|
| The problem is that strptime() returns POSIXlt type, not POSIXct type.
Confirmed, and dito for Rcpp::Date() constructed from a string.
| Adding Rcpp::Function asPOSIXct("as.POSIXct") and using it
| to convert seems to fix the problem.
I'll try to look into but may not get to til Sunday.
Dirk
--
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel
mailing list