----------------------------------------------------------------------------- Return a string representation -----------------------------------------------------------------------------
| 108 | // Return a string representation |
| 109 | //----------------------------------------------------------------------------- |
| 110 | string 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-> |
nothing calls this directly
no test coverage detected