summaryrefslogtreecommitdiffstats
path: root/src/common/misc.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/misc.cpp')
-rw-r--r--src/common/misc.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/common/misc.cpp b/src/common/misc.cpp
index 4954fc0..35a5560 100644
--- a/src/common/misc.cpp
+++ b/src/common/misc.cpp
@@ -26,6 +26,8 @@
#include <string.h>
#include <ctype.h>
#include <time.h>
+#include <sstream>
+#include <iomanip>
// Returns a non-accented letter.
@@ -232,6 +234,17 @@ void TimeToAsciiClean(time_t time, char *buffer)
when.tm_hour, when.tm_min);
}
+std::string TimeFormat(float time)
+{
+ int minutes = floor(time/60);
+ double time2 = fmod(time, 60);
+ double seconds;
+ double fraction = modf(time2, &seconds)*100;
+ std::ostringstream sstream;
+ sstream << std::setfill('0') << std::setw(2) << minutes << ":" << std::setfill('0') << std::setw(2) << floor(seconds) << "." << std::setfill('0') << std::setw(2) << floor(fraction);
+ return sstream.str();
+}
+
// Adds an extension to file, if doesn't already one.