From d04126eabe7269171f097bb20c86497a1a1409d7 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 29 Jul 2018 21:09:11 +0200 Subject: [PATCH] Make time-to-string more readable. --- server/TracyView.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 5eaa9904..0d5b0388 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -68,15 +68,15 @@ static const char* TimeToString( int64_t ns ) else if( ns < 1000ll * 1000 * 1000 * 60 * 60 ) { const auto m = int64_t( ns / ( 1000ll * 1000 * 1000 * 60 ) ); - const auto s = int64_t( ns - m * ( 1000ll * 1000 * 1000 * 60 ) ); - sprintf( buf, "%s%" PRIi64 ":%04.1f", sign, m, s / ( 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 ); } else { 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 s = int64_t( ns - h * ( 1000ll * 1000 * 1000 * 60 * 60 ) - m * ( 1000ll * 1000 * 1000 * 60 ) ); - sprintf( buf, "%s%" PRIi64 ":%02" PRIi64 ":%02" PRIi64, sign, h, m, int64_t( s / ( 1000ll * 1000 * 1000 ) ) ); + 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 ); } return buf; }