22 std::string formattedTime =
"0:00.000";
26 std::stringstream timeAsStringstream;
27 timeAsStringstream << time;
28 std::string timeAsString = timeAsStringstream.str();
30 int minutes = floor(time / (1000 * 60));
31 int seconds = floor((time - (minutes * 60 * 1000)) / 1000);
33 if(timeAsString.length() > 3)
35 tseconds = atoi(timeAsString.substr((timeAsString.length() - 3)).c_str());
38 char formattedCharArray[8];
39 sprintf(formattedCharArray,
"%d:%02d.%03d", minutes, seconds, tseconds);
41 formattedTime = std::string(formattedCharArray);
54 std::string formattedTime =
"00:00:00";
58 int hours = floor(time / 60 / 60);
59 int minutes = floor((time - (hours * 60 * 60)) / 60);
60 int seconds = (time - (hours * 60 * 60) - (minutes * 60));
64 char formattedCharArray[10];
65 sprintf(formattedCharArray,
"%04d:%02d:%02d", hours, minutes, seconds);
66 formattedTime = std::string(formattedCharArray);
70 char formattedCharArray[9];
71 sprintf(formattedCharArray,
"%03d:%02d:%02d", hours, minutes, seconds);
72 formattedTime = std::string(formattedCharArray);
76 char formattedCharArray[8];
77 sprintf(formattedCharArray,
"%02d:%02d:%02d", hours, minutes, seconds);
78 formattedTime = std::string(formattedCharArray);
91 time_t now = time(NULL);
92 strftime(buffer, 20,
"%Y-%m-%d %H:%M:%S", localtime(&now));
94 return std::string(buffer);
static std::string FormatSeconds(int time)
Formats time to 00:00:00 format.
Definition: Time.h:52
Contains utilities to format map times.
Definition: Time.h:12
static std::string FormatTime(int time)
Formats time to 0:00.000 format.
Definition: Time.h:20
static std::string Current()
Returns the current time in yyyy-mm-dd hh:mm:ss format.
Definition: Time.h:88