MCPcopy Create free account
hub / github.com/cinience/RedisStudio / ConvertHumanTimeDuration

Method ConvertHumanTimeDuration

RedisStudio/Base/Util.cpp:9–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace Base {
8
9std::string Util::ConvertHumanTimeDuration(long long seconds)
10{
11 std::stringstream sb;
12 if (seconds == 0) {
13 return "0 secs";
14 }
15 if (seconds >= 86400) {
16 sb << seconds / 86400;
17 sb << " days";
18 seconds -= (seconds / 86400) * 86400;
19 }
20 if (seconds >= 3600) {
21 if (sb.str().size() > 0) {
22 sb << " ";
23 }
24 sb << seconds / 3600;
25 sb << "hrs" ;
26 seconds -= (seconds / 3600) * 3600;
27 }
28 if (seconds >= 60) {
29 if (sb.str().size() > 0) {
30 sb << " ";
31 }
32 sb << seconds / 60 << "mins";
33 seconds -= (seconds / 60) * 60;
34 }
35 if (seconds > 0) {
36 if (sb.str().size() > 0) {
37 sb << " ";
38 }
39 sb << seconds;
40 sb << "secs";
41 }
42
43 return sb.str();
44}
45
46std::string Util::GetUniqueMachineID()
47{

Callers

nothing calls this directly

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected