2727namespace Rcpp {
2828
2929 class Datetime {
30- public:
30+ public:
3131 Datetime () {
3232 m_dt = 0 ;
3333 update_tm ();
3434 }
3535 Datetime (SEXP s);
36-
36+
3737 // from double, just like POSIXct
3838 Datetime (const double &dt){
3939 m_dt = dt;
4040 update_tm ();
4141 }
4242 Datetime (const std::string &s, const std::string &fmt=" %Y-%m-%d %H:%M:%OS" );
43-
43+
4444 double getFractionalTimestamp (void ) const { return m_dt; }
4545
4646 int getMicroSeconds () const { return m_us; }
@@ -64,7 +64,7 @@ namespace Rcpp {
6464 friend bool operator !=(const Datetime &dt1, const Datetime& dt2);
6565
6666 inline int is_na () const { return traits::is_na<REALSXP>( m_dt ) ; }
67-
67+
6868 private:
6969 double m_dt; // fractional seconds since epoch
7070 struct tm m_tm; // standard time representation
@@ -73,17 +73,17 @@ namespace Rcpp {
7373 // update m_tm based on m_dt
7474 void update_tm () {
7575 if (R_FINITE (m_dt)) {
76- time_t t = static_cast <time_t >(std::floor (m_dt));
76+ time_t t = static_cast <time_t >(std::floor (m_dt));
7777 m_tm = *gmtime_ (&t);
7878 // m_us is fractional (micro)secs as diff. between (fractional) m_dt and m_tm
79- m_us = static_cast <int >(::Rf_fround ( (m_dt - t) * 1.0e6 , 0.0 ));
79+ m_us = static_cast <int >(::Rf_fround ( (m_dt - t) * 1.0e6 , 0.0 ));
8080 } else {
8181 m_dt = NA_REAL; // NaN and Inf need it set
8282 m_tm.tm_sec = m_tm.tm_min = m_tm.tm_hour = m_tm.tm_isdst = NA_INTEGER;
8383 m_tm.tm_min = m_tm.tm_hour = m_tm.tm_mday = m_tm.tm_mon = m_tm.tm_year = NA_INTEGER;
8484 m_us = NA_INTEGER;
8585 }
86- }
86+ }
8787
8888 };
8989
@@ -102,13 +102,13 @@ namespace Rcpp {
102102 }
103103
104104 template <> SEXP wrap_extra_steps<Rcpp::Datetime>( SEXP x ) ;
105-
105+
106106 inline Datetime operator +(const Datetime &datetime, double offset) {
107107 Datetime newdt (datetime.m_dt );
108108 newdt.m_dt += offset;
109- time_t t = static_cast <time_t >(std::floor (newdt.m_dt ));
110- newdt.m_tm = *gmtime_ (&t);
111- newdt.m_us = static_cast <int >(::Rf_fround ( (newdt.m_dt - t) * 1.0e6 , 0.0 ));
109+ time_t t = static_cast <time_t >(std::floor (newdt.m_dt ));
110+ newdt.m_tm = *gmtime_ (&t);
111+ newdt.m_us = static_cast <int >(::Rf_fround ( (newdt.m_dt - t) * 1.0e6 , 0.0 ));
112112 return newdt;
113113 }
114114
0 commit comments