]> sigrok.org Git - pulseview.git/blobdiff - pv/util.cpp
Snapshot: Renamed to Segment
[pulseview.git] / pv / util.cpp
index 28e0dfde50d2fb9230219c5bce3b18e58a70b2bc..62f0ee1f67002b33ef2816bef15ccd3679dc4a00 100644 (file)
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-#include "util.h"
+#include "util.hpp"
 
 #include <extdef.h>
 
@@ -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