fix: clear duration stringify mistakes

This commit is contained in:
Haibo 2018-11-11 16:43:43 +08:00 committed by Nomango
parent a062af4de7
commit f175224e6e
1 changed files with 22 additions and 6 deletions

View File

@ -192,13 +192,29 @@ namespace easy2d
if (milliseconds_ < 0) if (milliseconds_ < 0)
result.append(L"-"); result.append(L"-");
result.append(std::to_wstring(hour)) if (hour)
.append(L"h") {
.append(std::to_wstring(min)) result.append(std::to_wstring(hour)).append(L"h");
.append(L"m") result.append(std::to_wstring(min)).append(L"m");
.append(float_to_str(static_cast<float>(sec) + static_cast<float>(ms) / 1000.f)) }
.append(L"s"); else if(min)
{
result.append(std::to_wstring(min)).append(L"m");
}
if (sec == 0 && ms == 0)
{
result.append(L"0s");
}
else if (ms == 0)
{
result.append(std::to_wstring(sec)).append(L"s");
}
else
{
result.append(float_to_str(static_cast<float>(sec) + static_cast<float>(ms) / 1000.f))
.append(L"s");
}
return result; return result;
} }