summaryrefslogtreecommitdiffstats
path: root/src/common/misc.cpp
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-10-29 17:53:46 +0100
committerkrzys-h <krzys_h@interia.pl>2014-10-29 17:53:46 +0100
commit6d2fd18b419ddc202fa14cb14c98e8f3d5ecf646 (patch)
tree9075499f6dd08609a229a55a1aa15104ac5b1955 /src/common/misc.cpp
parent61e06149c65fbc61c6d927f527195a9b4a8154dc (diff)
downloadcolobot-6d2fd18b419ddc202fa14cb14c98e8f3d5ecf646.tar.gz
colobot-6d2fd18b419ddc202fa14cb14c98e8f3d5ecf646.tar.bz2
colobot-6d2fd18b419ddc202fa14cb14c98e8f3d5ecf646.zip
Implemented mission timer
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.