Preserve sub-second time precision (#1624)

Found via pjdfstests.  References #897.  References #1589.
This commit is contained in:
Andrew Gaul
2021-04-18 13:11:12 +09:00
committed by GitHub
parent 706e3cbebd
commit 7f3e423bbe
7 changed files with 127 additions and 82 deletions

View File

@ -55,6 +55,17 @@ template std::string str(unsigned long value);
template std::string str(long long value);
template std::string str(unsigned long long value);
template<> std::string str(struct timespec value) {
std::ostringstream s;
s << value.tv_sec;
if(value.tv_nsec != 0){
char buf[16];
snprintf(buf, sizeof(buf), "%09lld", static_cast<long long>(value.tv_nsec));
s << "." << buf;
}
return s.str();
}
//-------------------------------------------------------------------
// Functions
//-------------------------------------------------------------------