MCPcopy Create free account
hub / github.com/BrunoLevy/geogram / format_time

Function format_time

src/lib/geogram/basic/string.cpp:223–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

221 }
222
223 std::string format_time(double seconds, bool HMS_only) {
224
225 std::string result;
226 if(!HMS_only) {
227 result = String::to_display_string(seconds) + "s";
228 }
229
230 if(seconds >= 60.0) {
231 while(!HMS_only && result.length() <= 10) {
232 result += " ";
233 }
234 int S = int(seconds);
235 int H = S / 3600;
236 S = S % 3600;
237 int M = S / 60;
238 S = S % 60;
239 result += String::format("(%02d:%02d:%02d)",H,M,S);
240 }
241
242 return result;
243 }
244
245 // Reference: https://stackoverflow.com/questions/148403/
246 // utf8-to-from-wide-char-conversion-in-stl

Callers 1

print_elapsed_timeMethod · 0.85

Calls 3

to_display_stringFunction · 0.85
formatFunction · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected