mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 10:41:50 +00:00
Add days to time-to-string converter.
This commit is contained in:
parent
d04126eabe
commit
0d76ccfb71
@ -71,13 +71,21 @@ static const char* TimeToString( int64_t ns )
|
|||||||
const auto s = int64_t( ns - m * ( 1000ll * 1000 * 1000 * 60 ) ) / ( 1000. * 1000. * 1000. );
|
const auto s = int64_t( ns - m * ( 1000ll * 1000 * 1000 * 60 ) ) / ( 1000. * 1000. * 1000. );
|
||||||
sprintf( buf, "%s%" PRIi64 ":%04.1f", sign, m, s );
|
sprintf( buf, "%s%" PRIi64 ":%04.1f", sign, m, s );
|
||||||
}
|
}
|
||||||
else
|
else if( ns < 1000ll * 1000 * 1000 * 60 * 60 * 24 )
|
||||||
{
|
{
|
||||||
const auto h = int64_t( ns / ( 1000ll * 1000 * 1000 * 60 * 60 ) );
|
const auto h = int64_t( ns / ( 1000ll * 1000 * 1000 * 60 * 60 ) );
|
||||||
const auto m = int64_t( ns / ( 1000ll * 1000 * 1000 * 60 ) - h * 60 );
|
const auto m = int64_t( ns / ( 1000ll * 1000 * 1000 * 60 ) - h * 60 );
|
||||||
const auto s = int64_t( ns / ( 1000ll * 1000 * 1000 ) - h * ( 60 * 60 ) - m * 60 );
|
const auto s = int64_t( ns / ( 1000ll * 1000 * 1000 ) - h * ( 60 * 60 ) - m * 60 );
|
||||||
sprintf( buf, "%s%" PRIi64 ":%02" PRIi64 ":%02" PRIi64, sign, h, m, s );
|
sprintf( buf, "%s%" PRIi64 ":%02" PRIi64 ":%02" PRIi64, sign, h, m, s );
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const auto d = int64_t( ns / ( 1000ll * 1000 * 1000 * 60 * 60 * 24 ) );
|
||||||
|
const auto h = int64_t( ns / ( 1000ll * 1000 * 1000 * 60 * 60 ) - d * 24 );
|
||||||
|
const auto m = int64_t( ns / ( 1000ll * 1000 * 1000 * 60 ) - d * ( 60 * 24 ) - h * 60 );
|
||||||
|
const auto s = int64_t( ns / ( 1000ll * 1000 * 1000 ) - d * ( 60 * 60 * 24 ) - h * ( 60 * 60 ) - m * 60 );
|
||||||
|
sprintf( buf, "%s%" PRIi64 "d%02" PRIi64 ":%02" PRIi64 ":%02" PRIi64, sign, d, h, m, s );
|
||||||
|
}
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user