MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / format

Method format

inst/include/Rcpp/date_datetime/Datetime.h:75–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73 operator double() const { return m_dt; }
74
75 inline std::string format(const char *fmt = "%Y-%m-%d %H:%M:%S") const {
76 char txtiso[64], txtsec[64];
77 time_t t = static_cast<time_t>(std::floor(m_dt));
78 struct tm temp = *localtime(&t); // localtime, not gmtime
79 size_t res = ::strftime(txtiso, 63, fmt, &temp);
80 if (res == 0) {
81 return std::string("");
82 } else {
83 res = ::snprintf(txtsec, 63, "%s.%06d", txtiso, m_us);
84 if (res <= 0) {
85 return std::string("");
86 } else {
87 return std::string(txtsec);
88 }
89 }
90 }
91
92 friend inline std::ostream &operator<<(std::ostream & s, const Datetime d);
93

Callers 1

Datetime.hFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected