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

Function gmtime_mktime

inst/tinytest/cpp/dates.cpp:200–213  ·  view source on GitHub ↗

[[Rcpp::export]]

Source from the content-addressed store, hash-verified

198
199// [[Rcpp::export]]
200Date gmtime_mktime(Date d) {
201 const int baseYear = 1900;
202 struct tm tm;
203 tm.tm_sec = tm.tm_min = tm.tm_hour = tm.tm_isdst = 0;
204
205 tm.tm_mday = d.getDay();
206 tm.tm_mon = d.getMonth() - 1; // range 0 to 11
207 tm.tm_year = d.getYear() - baseYear;
208 time_t tmp = mktime00(tm); // use mktime() replacement borrowed from R
209
210 struct tm chk = *gmtime_(&tmp);
211 Date newd(chk.tm_year, chk.tm_mon + 1, chk.tm_mday);
212 return newd;
213}
214
215// [[Rcpp::export]]
216double test_mktime(Date d) {

Callers

nothing calls this directly

Calls 5

mktime00Function · 0.50
gmtime_Function · 0.50
getDayMethod · 0.45
getMonthMethod · 0.45
getYearMethod · 0.45

Tested by

no test coverage detected