[Rcpp-commits] r3801 - in pkg/RcppBDT: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Oct 21 17:09:01 CEST 2012


Author: edd
Date: 2012-10-21 17:09:01 +0200 (Sun, 21 Oct 2012)
New Revision: 3801

Modified:
   pkg/RcppBDT/ChangeLog
   pkg/RcppBDT/src/RcppBDTdu.cpp
Log:
added pt addition to du


Modified: pkg/RcppBDT/ChangeLog
===================================================================
--- pkg/RcppBDT/ChangeLog	2012-10-21 14:56:18 UTC (rev 3800)
+++ pkg/RcppBDT/ChangeLog	2012-10-21 15:09:01 UTC (rev 3801)
@@ -1,5 +1,8 @@
 2012-10-21  Dirk Eddelbuettel  <edd at debian.org>
 
+	* src/RcppBDTdu.cpp: Added method to add posix time, and return the
+	resulting posix time object permitting simple mix of duration and time
+
 	* src/RcppBDTpt.cpp: Added addHours(), addMinutes(), addSeconds() and
 	addFractionalSeconds() to posix time class, shadowing Boost's side
 	* src/RcppBDTpt.cpp: Added constructor from numeric

Modified: pkg/RcppBDT/src/RcppBDTdu.cpp
===================================================================
--- pkg/RcppBDT/src/RcppBDTdu.cpp	2012-10-21 14:56:18 UTC (rev 3800)
+++ pkg/RcppBDT/src/RcppBDTdu.cpp	2012-10-21 15:09:01 UTC (rev 3801)
@@ -44,6 +44,12 @@
     void addMilliSeconds(int s) { m_td += boost::posix_time::milliseconds(s); }
     void addMicroSeconds(int s) { m_td += boost::posix_time::microseconds(s); }
     void addNanoSeconds(int s)  { m_td += boost::posix_time::nanoseconds(s); }
+
+    Rcpp::Datetime getAddedPosixtime(SEXP ptsexp)  { 
+        boost::posix_time::ptime pt(Rcpp::as<boost::posix_time::ptime>(ptsexp)); 
+        pt += m_td;
+        return Rcpp::wrap(pt); 
+    }
             
 private:
     boost::posix_time::time_duration m_td;
@@ -73,5 +79,8 @@
         .method("addMilliSeconds",        &bdtDu::addMilliSeconds,        "add given milliseconds to duration object")
         .method("addMicroSeconds",        &bdtDu::addMicroSeconds,        "add given microseconds to duration object")
         .method("addNanoSeconds",         &bdtDu::addNanoSeconds,         "add given nanoseconds to duration object")
+
+        .method("getAddedPosixtime",      &bdtDu::getAddedPosixtime,	  "adds duration to given posix time and returns posix time")
+
     ;
 }



More information about the Rcpp-commits mailing list