+ bool negative = false;
+ if (seconds < 0)
+ {
+ negative = true;
+ seconds = -seconds;
+ if (floor(seconds) != seconds)
+ seconds += 1; // make floor work in the other direction
+ }
+ int minutes = floor(seconds / 60);
+ seconds -= minutes * 60;
+ if (negative)
+ return sprintf("-%d:%02d", minutes, seconds);
+ 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;
+ tm = floor(tm + 0.5);
+ int minutes = floor(tm / acc);
+ int tm_without_minutes = tm - minutes * acc;
+ // NOTE: the start digit of s is a placeholder and won't be displayed
+ string s = ftos(acc * 10 + tm_without_minutes);
+ return strcat(ftos(minutes), ":", substring(s, 1, 2), ".", substring(s, 3, hundredths ? 2 : 1));