25 #if defined(WIN32) || defined(__WIN32) || defined(__WIN32__)
50 Date(
const std::string &s,
const std::string &fmt=
"%Y-%m-%d");
52 Date(
const unsigned int &mon,
const unsigned int &day,
const unsigned int &year) {
56 if (mon >=
baseYear() && day <= 12 && year <= 31) {
58 m_tm.tm_mon = day - 1;
62 m_tm.tm_mon = mon - 1;
103 operator double()
const {
107 inline std::string
format(
const char *fmt =
"%Y-%m-%d")
const {
111 size_t res = ::strftime(txt, 31, fmt, &temp);
113 return std::string(
"");
115 return std::string(txt);
119 friend inline std::ostream &
operator<<(std::ostream & os,
const Date d);
128 time_t t =
static_cast<time_t
>(24*60*60 *
m_d);
143 template<>
inline double caster<Rcpp::Date,double>(
Rcpp::Date from) {
144 return static_cast<double>(from.
getDate());
146 template<>
inline Rcpp::Date caster<double,Rcpp::Date>(
double from) {
151 template<>
inline SEXP wrap_extra_steps<Rcpp::Date>(SEXP x) {
152 Rf_setAttrib(x, R_ClassSymbol, Rf_mkString(
"Date"));
158 newdate.
m_d += offset;
159 time_t t =
static_cast<time_t
>(24*60*60 * newdate.
m_d);
181 SET_STRING_ELT(datetimeclass, 0, Rf_mkChar(
"POSIXct"));
182 SET_STRING_ELT(datetimeclass, 1, Rf_mkChar(
"POSIXt"));
183 return datetimeclass;
194 Rf_setAttrib(x, R_ClassSymbol, Rf_mkString(
"Date"));
friend Date operator+(const Date &date, int offset)
friend bool operator==(const Date &date1, const Date &date2)
friend bool operator>=(const Date &date1, const Date &date2)
Date(const unsigned int &mon, const unsigned int &day, const unsigned int &year)
friend bool operator<=(const Date &date1, const Date &date2)
friend bool operator<(const Date &date1, const Date &date2)
friend bool operator!=(const Date &date1, const Date &date2)
double getDate(void) const
friend std::ostream & operator<<(std::ostream &os, const Date d)
friend double operator-(const Date &date1, const Date &date2)
friend bool operator>(const Date &date1, const Date &date2)
std::string format(const char *fmt="%Y-%m-%d") const
static unsigned int baseYear()
double dt(double x, double n, int lg)
SEXP new_posixt_object(double d)
SEXP new_date_object(double d)
bool is_na< REALSXP >(double x)
bool operator>=(const Date &d1, const Date &d2)
bool operator!=(const Date &d1, const Date &d2)
double operator-(const Date &d1, const Date &d2)
bool operator>(const Date &d1, const Date &d2)
attribute_hidden struct tm * gmtime_(const time_t *const x)
attribute_hidden double mktime00(struct tm &tm)
std::ostream & operator<<(std::ostream &os, const Date d)
bool operator<(const Date &d1, const Date &d2)
bool operator==(const Date &d1, const Date &d2)
bool operator<=(const Date &d1, const Date &d2)
Date operator+(const Date &date, int offset)