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

Method update_tm

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

update m_tm based on m_dt

Source from the content-addressed store, hash-verified

98
99 // update m_tm based on m_dt
100 void update_tm() {
101 if (R_FINITE(m_dt)) {
102 double dt = std::floor(m_dt);
103 time_t t = static_cast<time_t>(dt);
104 m_tm = *gmtime_(&t);
105 // m_us is fractional (micro)secs as diff. between (fractional) m_dt and m_tm
106 m_us = static_cast<int>(::Rf_fround( (m_dt - dt) * 1.0e6, 0.0));
107 } else {
108 m_dt = NA_REAL; // NaN and Inf need it set
109 m_tm.tm_sec = m_tm.tm_min = m_tm.tm_hour = m_tm.tm_isdst = NA_INTEGER;
110 m_tm.tm_min = m_tm.tm_hour = m_tm.tm_mday = m_tm.tm_mon = m_tm.tm_year = NA_INTEGER;
111 m_us = NA_INTEGER;
112 }
113 }
114
115 // 1900 as per POSIX mktime() et al
116 static inline unsigned int baseYear() {

Callers

nothing calls this directly

Calls 1

gmtime_Function · 0.50

Tested by

no test coverage detected