MCPcopy Create free account
hub / github.com/CobaltFusion/DebugViewPP / FormatDuration

Function FormatDuration

DebugView++/MainFrame.cpp:289–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289std::wstring FormatDuration(double seconds)
290{
291 int minutes = FloorTo<int>(seconds / 60);
292 seconds -= 60 * minutes;
293
294 int hours = minutes / 60;
295 minutes -= 60 * hours;
296
297 int days = hours / 24;
298 hours -= 24 * days;
299
300 if (days > 0)
301 return wstringbuilder() << FormatUnits(days, L"day") << L" " << FormatUnits(hours, L"hour");
302
303 if (hours > 0)
304 return wstringbuilder() << FormatUnits(hours, L"hour") << L" " << FormatUnits(minutes, L"minute");
305
306 if (minutes > 0)
307 return wstringbuilder() << FormatUnits(minutes, L"minute") << L" " << FormatUnits(FloorTo<int>(seconds), L"second");
308
309 static const wchar_t* units[] = { L"s", L"ms", L"�s", L"ns", nullptr };
310 const wchar_t** unit = units;
311 while (*unit != nullptr && seconds > 0 && seconds < 1)
312 {
313 seconds *= 1e3;
314 ++unit;
315 }
316
317 return wstringbuilder() << std::fixed << std::setprecision(3) << seconds << L" " << *unit;
318}
319
320std::wstring FormatDateTime(const SYSTEMTIME& systemTime)
321{

Callers 1

GetSelectionInfoTextMethod · 0.85

Calls 1

FormatUnitsFunction · 0.85

Tested by

no test coverage detected