mirror of
https://github.com/microsoft/vcpkg.git
synced 2025-01-18 10:03:02 +08:00
[vcpkg_Chrono] Add missing consts
This commit is contained in:
parent
3a43e19020
commit
9e7275c5df
@ -7,43 +7,43 @@ namespace vcpkg
|
||||
{
|
||||
static std::string format_time_userfriendly(const std::chrono::nanoseconds& nanos)
|
||||
{
|
||||
using std::chrono::hours;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::milliseconds;
|
||||
using std::chrono::microseconds;
|
||||
using std::chrono::nanoseconds;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::hours;
|
||||
using std::chrono::microseconds;
|
||||
using std::chrono::milliseconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::nanoseconds;
|
||||
using std::chrono::seconds;
|
||||
|
||||
const double nanos_as_double = static_cast<double>(nanos.count());
|
||||
|
||||
if (duration_cast<hours>(nanos) > hours())
|
||||
{
|
||||
auto t = nanos_as_double / duration_cast<nanoseconds>(hours(1)).count();
|
||||
const auto t = nanos_as_double / duration_cast<nanoseconds>(hours(1)).count();
|
||||
return Strings::format("%.4g h", t);
|
||||
}
|
||||
|
||||
if (duration_cast<minutes>(nanos) > minutes())
|
||||
{
|
||||
auto t = nanos_as_double / duration_cast<nanoseconds>(minutes(1)).count();
|
||||
const auto t = nanos_as_double / duration_cast<nanoseconds>(minutes(1)).count();
|
||||
return Strings::format("%.4g min", t);
|
||||
}
|
||||
|
||||
if (duration_cast<seconds>(nanos) > seconds())
|
||||
{
|
||||
auto t = nanos_as_double / duration_cast<nanoseconds>(seconds(1)).count();
|
||||
const auto t = nanos_as_double / duration_cast<nanoseconds>(seconds(1)).count();
|
||||
return Strings::format("%.4g s", t);
|
||||
}
|
||||
|
||||
if (duration_cast<milliseconds>(nanos) > milliseconds())
|
||||
{
|
||||
auto t = nanos_as_double / duration_cast<nanoseconds>(milliseconds(1)).count();
|
||||
const auto t = nanos_as_double / duration_cast<nanoseconds>(milliseconds(1)).count();
|
||||
return Strings::format("%.4g ms", t);
|
||||
}
|
||||
|
||||
if (duration_cast<microseconds>(nanos) > microseconds())
|
||||
{
|
||||
auto t = nanos_as_double / duration_cast<nanoseconds>(microseconds(1)).count();
|
||||
const auto t = nanos_as_double / duration_cast<nanoseconds>(microseconds(1)).count();
|
||||
return Strings::format("%.4g us", t);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user