X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Futil.cpp;h=a54bdcaf8f957e8df5b462b5594ef2842afae3e5;hp=28e0dfde50d2fb9230219c5bce3b18e58a70b2bc;hb=62974f456595f3f6b9804a8f0fb993b4766d61e7;hpb=f0c9f81c03d2c1d1fa59c357a88d25f6a3128651 diff --git a/pv/util.cpp b/pv/util.cpp index 28e0dfde..a54bdcaf 100644 --- a/pv/util.cpp +++ b/pv/util.cpp @@ -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