diff --git a/src/base/system.cpp b/src/base/system.cpp index 4f6142289..8f565a074 100644 --- a/src/base/system.cpp +++ b/src/base/system.cpp @@ -3428,7 +3428,7 @@ int str_time(int64_t centisecs, int format, char *buffer, int buffer_size) int str_time_float(float secs, int format, char *buffer, int buffer_size) { - return str_time(llroundf(secs * 100), format, buffer, buffer_size); + return str_time(llroundf(secs * 1000) / 10, format, buffer, buffer_size); } void str_escape(char **dst, const char *src, const char *end) diff --git a/src/test/str.cpp b/src/test/str.cpp index 917fe79bd..ff083fd39 100644 --- a/src/test/str.cpp +++ b/src/test/str.cpp @@ -685,6 +685,9 @@ TEST(Str, TimeFloat) EXPECT_EQ(str_time_float(12.16, TIME_HOURS_CENTISECS, aBuf, sizeof(aBuf)), 8); EXPECT_STREQ(aBuf, "00:12.16"); + + EXPECT_EQ(str_time_float(22.995, TIME_MINS, aBuf, sizeof(aBuf)), 5); + EXPECT_STREQ(aBuf, "00:22"); } TEST(Str, HasCc)