/
lasersquad
/
LogEngine2
Обзор
Документация
Войти
/
lasersquad
/
LogEngine2
Код
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
prj/Builder/testLogEngine2/Shared.cpp
28 строк
832 B
lasersquad@gmail.com
init
02 фев 2024, 20:53
02 фев 2024, 20:53
ee2dd28
Код
Авторство
О чём код?
#include "Shared.h" std::string millisecToStr(long long ms) { int milliseconds = ms % 1000; int seconds = (ms / 1000) % 60; int minutes = (ms / 60000) % 60; int hours = (ms / 3600000) % 24; char buf[100]; #ifdef WIN32 if (hours > 0) sprintf_s(buf, 100, "%u hours %u minutes %u seconds %u ms", hours, minutes, seconds, milliseconds); else if (minutes > 0) sprintf_s(buf, 100, "%u minutes %u seconds %u ms", minutes, seconds, milliseconds); else sprintf_s(buf, 100, "%u seconds %u ms", seconds, milliseconds); #else if (hours > 0) sprintf(buf, "%u hours %u minutes %u seconds %u ms", hours, minutes, seconds, milliseconds); else if (minutes > 0) sprintf(buf, "%u minutes %u seconds %u ms", minutes, seconds, milliseconds); else sprintf(buf, "%u seconds %u ms", seconds, milliseconds); #endif return buf; }