[Rcpp-commits] r2796 - in pkg/Rcpp: . inst/include/Rcpp src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Sat Dec 18 05:07:56 CET 2010
Author: edd
Date: 2010-12-18 05:07:55 +0100 (Sat, 18 Dec 2010)
New Revision: 2796
Modified:
pkg/Rcpp/ChangeLog
pkg/Rcpp/inst/include/Rcpp/Datetime.h
pkg/Rcpp/src/Date.cpp
pkg/Rcpp/src/Datetime.cpp
Log:
corrections to Date and Datetime constructors from std::string
Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog 2010-12-17 16:16:42 UTC (rev 2795)
+++ pkg/Rcpp/ChangeLog 2010-12-18 04:07:55 UTC (rev 2796)
@@ -1,3 +1,14 @@
+2010-12-17 Dirk Eddelbuettel <edd at debian.org>
+
+ * inst/include/Rcpp/Datetime.h: correct default format to use %OS for
+ fractional seconds and not the popular typo %OS (i.e. ooh, not zero)
+
+ * src/Datetime.cpp: add missing as.POSIXct() after strptime for
+ constructor from string as we then the constructor from double
+
+ * src/Date.cpp: add missing as.Date() after strptime for constructor
+ from string as then use the constructor from int
+
2010-12-13 Romain Francois <romain at r-enthusiasts.com>
* inst/include/Rcpp/vector/string_proxy.h: List::Proxy did not
Modified: pkg/Rcpp/inst/include/Rcpp/Datetime.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/Datetime.h 2010-12-17 16:16:42 UTC (rev 2795)
+++ pkg/Rcpp/inst/include/Rcpp/Datetime.h 2010-12-18 04:07:55 UTC (rev 2796)
@@ -31,7 +31,7 @@
Datetime();
Datetime(SEXP s);
Datetime(const double &dt); // from double, just like POSIXct
- Datetime(const std::string &s, const std::string &fmt="%Y-%m-%d %H:%M:%0S");
+ Datetime(const std::string &s, const std::string &fmt="%Y-%m-%d %H:%M:%OS");
Datetime(const Datetime ©);
~Datetime() {};
Modified: pkg/Rcpp/src/Date.cpp
===================================================================
--- pkg/Rcpp/src/Date.cpp 2010-12-17 16:16:42 UTC (rev 2795)
+++ pkg/Rcpp/src/Date.cpp 2010-12-18 04:07:55 UTC (rev 2796)
@@ -54,7 +54,8 @@
Date::Date(const std::string &s, const std::string &fmt) {
Rcpp::Function strptime("strptime"); // we cheat and call strptime() from R
- m_d = Rcpp::as<int>(strptime(s, fmt, "UTC"));
+ Rcpp::Function asDate("as.Date"); // and we need to convert to Date
+ m_d = Rcpp::as<int>(asDate(strptime(s, fmt, "UTC")));
update_tm();
}
Modified: pkg/Rcpp/src/Datetime.cpp
===================================================================
--- pkg/Rcpp/src/Datetime.cpp 2010-12-17 16:16:42 UTC (rev 2795)
+++ pkg/Rcpp/src/Datetime.cpp 2010-12-18 04:07:55 UTC (rev 2796)
@@ -46,7 +46,8 @@
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));
+ Rcpp::Function asPOSIXct("as.POSIXct"); // and we need to convert to POSIXct
+ m_dt = Rcpp::as<double>(asPOSIXct(strptime(s, fmt)));
update_tm();
}
More information about the Rcpp-commits
mailing list