return sprintf("%d:%02d", minutes, seconds);
}
+/// \param[in] tm integer clocked time in tenths or hundredths, CANNOT be negative
+/// \param[in] hundredths if true append hundredths too, otherwise only tenths
+/// \return clocked time as "m:ss.t" or "m:ss.th" string (rounded)
+ERASEABLE
+string clockedtime_tostring(int tm, bool hundredths)
+{
+ if (tm < 0)
+ return strcat("0:00:0", hundredths ? "0" : "");
+ int acc = hundredths ? 6000 : 600;
+ int seconds = floor(tm + 0.5);
+ int minutes = floor(seconds / acc);
+ seconds -= minutes * acc;
+ // NOTE: the start digit of s is a placeholder and won't be displayed
+ string s = ftos(acc * 10 + seconds);
+ return strcat(ftos(minutes), ":", substring(s, 1, 2), ".", substring(s, 3, hundredths ? 2 : 1));
+}
+
+#define mmsss(tm) clockedtime_tostring(tm, false)
+#define mmssss(tm) clockedtime_tostring(tm, true)
+
ERASEABLE
string format_time(float seconds)
{
else return sprintf(_("%02d:%02d:%02d"), hours, minutes, seconds);
}
-ERASEABLE
-string mmsss(float tenths)
-{
- tenths = floor(tenths + 0.5);
- float minutes = floor(tenths / 600);
- tenths -= minutes * 600;
- string s = ftos(1000 + tenths);
- return strcat(ftos(minutes), ":", substring(s, 1, 2), ".", substring(s, 3, 1));
-}
-
-ERASEABLE
-string mmssss(float hundredths)
-{
- hundredths = floor(hundredths + 0.5);
- float minutes = floor(hundredths / 6000);
- hundredths -= minutes * 6000;
- string s = ftos(10000 + hundredths);
- return strcat(ftos(minutes), ":", substring(s, 1, 2), ".", substring(s, 3, 2));
-}
-
int ColorTranslateMode;
ERASEABLE