static void fillSlotsFromTime(PyrSlot * result, struct tm* tm, chrono::system_clock::time_point const & now) { PyrSlot *slots = slotRawObject(result)->slots; SetInt(slots+0, tm->tm_year + 1900); SetInt(slots+1, tm->tm_mon + 1); // 0 based month ?? SetInt(slots+2, tm->tm_mday); SetInt(slots+3, tm->tm_hour); SetInt(slots+4, tm->tm_min); SetInt(slots+5, tm->tm_sec); SetInt(slots+6, tm->tm_wday); SetFloat(slots+7, chrono::duration_cast<chrono::nanoseconds>(now.time_since_epoch()).count() * 1.0e-9); }
// make timestamp string, ie: _20120817_160459_0148 const string openm::makeTimeStamp(const chrono::system_clock::time_point & i_time) { time_t sys_time = chrono::system_clock::to_time_t(i_time); tm * sys_tm = localtime(&sys_time); ostringstream st; st << '_' << setfill('0') << setw(4) << sys_tm->tm_year + 1900 << setw(2) << sys_tm->tm_mon + 1 << setw(2) << sys_tm->tm_mday << '_' << setw(2) << sys_tm->tm_hour << setw(2) << sys_tm->tm_min << setw(2) << sys_tm->tm_sec << '_' << setw(4) << chrono::duration_cast<chrono::milliseconds>(i_time.time_since_epoch()).count() % 1000LL << flush; return st.str(); }