MCPcopy Create free account
hub / github.com/OpenZWave/open-zwave / GetAsString

Method GetAsString

cpp/src/platform/unix/TimeStampImpl.cpp:110–125  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Return a string representation -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

108// Return a string representation
109//-----------------------------------------------------------------------------
110string TimeStampImpl::GetAsString
111(
112)
113{
114 char str[100];
115 // use threadsafe verion of localtime. Reported by nihilus, 2019-04
116 // https://www.gnu.org/software/libc/manual/html_node/Broken_002ddown-Time.html#Broken_002ddown-Time
117 struct tm *tm, xtm;
118 memset(&xtm, 0, sizeof(xtm));
119 tm = localtime_r( &m_stamp.tv_sec, &xtm);
120
121 snprintf( str, sizeof(str), "%04d-%02d-%02d %02d:%02d:%02d:%03d ",
122 tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
123 tm->tm_hour, tm->tm_min, tm->tm_sec, (int)(m_stamp.tv_nsec / (1000*1000)) );
124 return str;
125}
126
127//-----------------------------------------------------------------------------
128// <TimeStampImpl::operator->

Callers

nothing calls this directly

Calls 1

localtime_rFunction · 0.85

Tested by

no test coverage detected