|
1 |
| -// Copyright (C) 2013 Dirk Eddelbuettel and Romain Francois |
| 1 | +// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*- |
| 2 | +// |
| 3 | +// Copyright (C) 2013 - 2015 Dirk Eddelbuettel and Romain Francois |
2 | 4 | //
|
3 | 5 | // This file is part of Rcpp.
|
4 | 6 | //
|
|
18 | 20 | #ifndef Rcpp_api_meat_Datetime_h
|
19 | 21 | #define Rcpp_api_meat_Datetime_h
|
20 | 22 |
|
21 |
| -namespace Rcpp{ |
| 23 | +namespace Rcpp { |
22 | 24 |
|
23 | 25 | inline Datetime::Datetime(SEXP d) {
|
24 |
| - m_dt = Rcpp::as<double>(d); |
25 |
| - update_tm(); |
| 26 | + m_dt = Rcpp::as<double>(d); |
| 27 | + update_tm(); |
26 | 28 | }
|
27 | 29 |
|
28 | 30 | inline Datetime::Datetime(const std::string &s, const std::string &fmt) {
|
29 |
| - Rcpp::Function strptime("strptime"); // we cheat and call strptime() from R |
30 |
| - Rcpp::Function asPOSIXct("as.POSIXct"); // and we need to convert to POSIXct |
31 |
| - m_dt = Rcpp::as<double>(asPOSIXct(strptime(s, fmt))); |
32 |
| - update_tm(); |
| 31 | + Rcpp::Function strptime("strptime"); // we cheat and call strptime() from R |
| 32 | + Rcpp::Function asPOSIXct("as.POSIXct"); // and we need to convert to POSIXct |
| 33 | + m_dt = Rcpp::as<double>(asPOSIXct(strptime(s, fmt))); |
| 34 | + update_tm(); |
33 | 35 | }
|
34 | 36 |
|
35 | 37 | template<>
|
36 |
| - inline SEXP wrap_extra_steps<Rcpp::Datetime>( SEXP x ){ |
37 |
| - Rf_setAttrib(x, R_ClassSymbol, internal::getPosixClasses() ); |
38 |
| - return x ; |
| 38 | + inline SEXP wrap_extra_steps<Rcpp::Datetime>(SEXP x) { |
| 39 | + Rf_setAttrib(x, R_ClassSymbol, internal::getPosixClasses()); |
| 40 | + return x ; |
39 | 41 | }
|
40 | 42 |
|
41 | 43 | template <>
|
42 | 44 | inline SEXP wrap<Datetime>(const Datetime &date) {
|
43 |
| - return internal::new_posixt_object( date.getFractionalTimestamp() ) ; |
| 45 | + return internal::new_posixt_object(date.getFractionalTimestamp()); |
44 | 46 | }
|
45 | 47 |
|
46 |
| - |
47 | 48 | }
|
48 | 49 |
|
49 | 50 | #endif
|
0 commit comments