]> sigrok.org Git - pulseview.git/blobdiff - pv/util.cpp
SamplingBar: Use nicer time format in the tooltip.
[pulseview.git] / pv / util.cpp
index 28e0dfde50d2fb9230219c5bce3b18e58a70b2bc..a54bdcaf8f957e8df5b462b5594ef2842afae3e5 100644 (file)
@@ -55,5 +55,18 @@ QString format_time(double t, unsigned int prefix,
        return s;
 }
 
+QString format_second(double second)
+{
+       unsigned int i = 0;
+       int exp = - FirstSIPrefixPower;
+
+       while ((second * pow(10.0, exp)) > 999.0 && i < countof(SIPrefixes) - 1) {
+               i++;
+               exp -= 3;
+       }
+
+       return format_time(second, i, 0, false);
+}
+
 } // namespace util
 } // namespace pv