added to misc: timespec_to_stream_with_unit() for printing times either is seconds or miliseconds
This commit is contained in:
@@ -1509,6 +1509,34 @@ void timespec_to_stream(timespec & val, pt::Stream & stream)
|
||||
}
|
||||
|
||||
|
||||
void timespec_to_stream_with_unit(timespec & val, pt::Stream & stream)
|
||||
{
|
||||
char buf[50];
|
||||
bool is_ms = false;
|
||||
|
||||
double val_double = timespec_to_double(val);
|
||||
|
||||
if( val_double < 0.1 )
|
||||
{
|
||||
is_ms = true;
|
||||
val_double = val_double * 1000;
|
||||
}
|
||||
|
||||
sprintf(buf, "%f", val_double);
|
||||
SetNonZeroDigitsAfterComma(buf, 2);
|
||||
|
||||
stream << buf;
|
||||
|
||||
if( is_ms )
|
||||
{
|
||||
stream << "ms";
|
||||
}
|
||||
else
|
||||
{
|
||||
stream << "s";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Winix
|
||||
|
||||
Reference in New Issue
Block a user