X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Futil.cpp;h=62f0ee1f67002b33ef2816bef15ccd3679dc4a00;hp=28e0dfde50d2fb9230219c5bce3b18e58a70b2bc;hb=f3d66e52ed6b454ea7a0662d5e6367e230116a2b;hpb=f0c9f81c03d2c1d1fa59c357a88d25f6a3128651 diff --git a/pv/util.cpp b/pv/util.cpp index 28e0dfde..62f0ee1f 100644 --- a/pv/util.cpp +++ b/pv/util.cpp @@ -18,7 +18,7 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "util.h" +#include "util.hpp" #include @@ -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